-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,228 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
""" | ||
Resolve Annotator Classes in the Pipeline to Extractor Configs and Methods | ||
Every Annotator should have 2 configs. Some might offor multuple configs/method pairs, based on model_anno_obj/NLP reference. | ||
- default/minimalistic -> Just the results of the annotations, no confidences or extra metadata | ||
- with meta -> A config that leverages white/black list and gets the most relevant metadata | ||
- with positions -> With Begins/Ends | ||
- with sentence references -> Reeturn the sentence/chunk no. reference from the metadata. | ||
If a document has multi-sentences, this will map a label back to a corrosponding sentence | ||
""" | ||
# from nlu.pipe.col_substitution.col_substitution_HC import * | ||
from nlu.pipe.col_substitution.col_substitution_OS import * | ||
from nlu.pipe.col_substitution.col_substitution_OCR import * | ||
|
||
from sparkocr.transformers import * | ||
|
||
OCR_anno2substitution_fn = { | ||
VisualDocumentClassifier : { | ||
'default': substitute_document_classifier_text_cols , | ||
}, | ||
VisualDocumentNerLilt : { | ||
'default': substitute_document_ner_cols, | ||
}, | ||
|
||
} |
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
Oops, something went wrong.