-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/visual-ner' into release/531
# Conflicts: # nlu/pipe/col_substitution/col_name_substitution_utils.py # nlu/pipe/col_substitution/substitution_map_OCR.py # nlu/universe/component_universes.py
- Loading branch information
Showing
23 changed files
with
1,179 additions
and
40 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
36 changes: 18 additions & 18 deletions
36
nlu/components/embeddings/sentence_mpnet/MPNetSentenceEmbedding.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
from sparknlp.annotator import MPNetEmbeddings | ||
|
||
|
||
class MPNetSentence: | ||
@staticmethod | ||
def get_default_model(): | ||
return MPNetEmbeddings.pretrained() \ | ||
.setInputCols(["documents"]) \ | ||
.setOutputCol("mpnet_embeddings") | ||
|
||
@staticmethod | ||
def get_pretrained_model(name, language, bucket=None): | ||
return MPNetEmbeddings.pretrained(name,language,bucket) \ | ||
.setInputCols(["documents"]) \ | ||
.setOutputCol("mpnet_embeddings") | ||
|
||
|
||
|
||
# from sparknlp.annotator import MPNetEmbeddings | ||
# | ||
# | ||
# class MPNetSentence: | ||
# @staticmethod | ||
# def get_default_model(): | ||
# return MPNetEmbeddings.pretrained() \ | ||
# .setInputCols(["documents"]) \ | ||
# .setOutputCol("mpnet_embeddings") | ||
# | ||
# @staticmethod | ||
# def get_pretrained_model(name, language, bucket=None): | ||
# return MPNetEmbeddings.pretrained(name,language,bucket) \ | ||
# .setInputCols(["documents"]) \ | ||
# .setOutputCol("mpnet_embeddings") | ||
# | ||
# | ||
# |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class HocrTokenizer: | ||
@staticmethod | ||
def get_default_model(): | ||
from sparkocr.transformers import HocrTokenizer | ||
return HocrTokenizer() \ | ||
.setInputCol("hocr") \ | ||
.setOutputCol("text_tokenized") |
Empty file.
Empty file.
8 changes: 8 additions & 0 deletions
8
nlu/ocr_components/visual_ner/visual_document_ner/visual_document_ner.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class VisualDocumentNer: | ||
@staticmethod | ||
def get_default_model(): | ||
from sparkocr.transformers import VisualDocumentNer | ||
return VisualDocumentNer()\ | ||
.pretrained("lilt_roberta_funsd_v1", "en", "clinical/ocr")\ | ||
.setInputCols(["text_tokenized", "image"])\ | ||
.setOutputCol("text_entity") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import os | ||
import sys | ||
|
||
sys.path.append(os.getcwd()) | ||
import unittest | ||
import nlu | ||
|
||
os.environ["PYTHONPATH"] = "F:/Work/repos/nlu" | ||
os.environ['PYSPARK_PYTHON'] = sys.executable | ||
os.environ['PYSPARK_DRIVER_PYTHON'] = sys.executable | ||
from johnsnowlabs import nlp, visual | ||
|
||
# nlp.install(json_license_path='license.json',visual=True) | ||
nlp.start(visual=True) | ||
|
||
class OcrTest(unittest.TestCase): | ||
|
||
def test_classify_document(self): | ||
# nlu.auth(SPARK_NLP_LICENSE,AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,JSL_SECRET, OCR_LICENSE, OCR_SECRET) | ||
# text that we generate PDF to has to come from an image struct! | ||
# We need convert text to img struct! | ||
p = nlu.load('en.lilt_roberta_funds.v1').predict('ocr_ner.png',output_level='chunk') | ||
for i,j in p.iterrows(): | ||
print(i,'---->',j) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |