spark-nlp 6.1.2rc1__py2.py3-none-any.whl → 6.1.3rc1__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of spark-nlp might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spark-nlp
3
- Version: 6.1.2rc1
3
+ Version: 6.1.3rc1
4
4
  Summary: John Snow Labs Spark NLP is a natural language processing library built on top of Apache Spark ML. It provides simple, performant & accurate NLP annotations for machine learning pipelines, that scale easily in a distributed environment.
5
5
  Home-page: https://github.com/JohnSnowLabs/spark-nlp
6
6
  Author: John Snow Labs
@@ -102,7 +102,7 @@ $ java -version
102
102
  $ conda create -n sparknlp python=3.7 -y
103
103
  $ conda activate sparknlp
104
104
  # spark-nlp by default is based on pyspark 3.x
105
- $ pip install spark-nlp==6.1.1 pyspark==3.3.1
105
+ $ pip install spark-nlp==6.1.3 pyspark==3.3.1
106
106
  ```
107
107
 
108
108
  In Python console or Jupyter `Python3` kernel:
@@ -168,7 +168,7 @@ For a quick example of using pipelines and models take a look at our official [d
168
168
 
169
169
  ### Apache Spark Support
170
170
 
171
- Spark NLP *6.1.1* has been built on top of Apache Spark 3.4 while fully supports Apache Spark 3.0.x, 3.1.x, 3.2.x, 3.3.x, 3.4.x, and 3.5.x
171
+ Spark NLP *6.1.3* has been built on top of Apache Spark 3.4 while fully supports Apache Spark 3.0.x, 3.1.x, 3.2.x, 3.3.x, 3.4.x, and 3.5.x
172
172
 
173
173
  | Spark NLP | Apache Spark 3.5.x | Apache Spark 3.4.x | Apache Spark 3.3.x | Apache Spark 3.2.x | Apache Spark 3.1.x | Apache Spark 3.0.x | Apache Spark 2.4.x | Apache Spark 2.3.x |
174
174
  |-----------|--------------------|--------------------|--------------------|--------------------|--------------------|--------------------|--------------------|--------------------|
@@ -198,7 +198,7 @@ Find out more about 4.x `SparkNLP` versions in our official [documentation](http
198
198
 
199
199
  ### Databricks Support
200
200
 
201
- Spark NLP 6.1.1 has been tested and is compatible with the following runtimes:
201
+ Spark NLP 6.1.3 has been tested and is compatible with the following runtimes:
202
202
 
203
203
  | **CPU** | **GPU** |
204
204
  |--------------------|--------------------|
@@ -216,7 +216,7 @@ We are compatible with older runtimes. For a full list check databricks support
216
216
 
217
217
  ### EMR Support
218
218
 
219
- Spark NLP 6.1.1 has been tested and is compatible with the following EMR releases:
219
+ Spark NLP 6.1.3 has been tested and is compatible with the following EMR releases:
220
220
 
221
221
  | **EMR Release** |
222
222
  |--------------------|
@@ -3,7 +3,7 @@ com/johnsnowlabs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
3
3
  com/johnsnowlabs/ml/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  com/johnsnowlabs/ml/ai/__init__.py,sha256=YQiK2M7U4d8y5irPy_HB8ae0mSpqS9583MH44pnKJXc,295
5
5
  com/johnsnowlabs/nlp/__init__.py,sha256=DPIVXtONO5xXyOk-HB0-sNiHAcco17NN13zPS_6Uw8c,294
6
- sparknlp/__init__.py,sha256=sEwJ50P2C-LGn-MZ8oI6jO6N0OutYSL3b6bCVkOo2wc,13814
6
+ sparknlp/__init__.py,sha256=UR0dRykX67j-Ksuzk5Xe-Mod5qCK24iBjHHa0omOp2w,13814
7
7
  sparknlp/annotation.py,sha256=I5zOxG5vV2RfPZfqN9enT1i4mo6oBcn3Lrzs37QiOiA,5635
8
8
  sparknlp/annotation_audio.py,sha256=iRV_InSVhgvAwSRe9NTbUH9v6OGvTM-FPCpSAKVu0mE,1917
9
9
  sparknlp/annotation_image.py,sha256=xhCe8Ko-77XqWVuuYHFrjKqF6zPd8Z-RY_rmZXNwCXU,2547
@@ -19,10 +19,13 @@ sparknlp/annotator/document_character_text_splitter.py,sha256=oNrOKJAKO2h1wr0bEu
19
19
  sparknlp/annotator/document_normalizer.py,sha256=hU2fG6vaPfdngQapoeSu-_zS_LiBZNp2tcVBGl6eTpk,10973
20
20
  sparknlp/annotator/document_token_splitter.py,sha256=-9xbQ9pVAjcKHQQrSk6Cb7f8W1cblCLwWXTNR8kFptA,7499
21
21
  sparknlp/annotator/document_token_splitter_test.py,sha256=NWO9mwhAIUJFuxPofB3c39iUm_6vKp4pteDsBOTH8ng,2684
22
+ sparknlp/annotator/extractor.py,sha256=GObGwyl602jrt6EbnhZO2-KptrzVRop_5uA8HewpWcc,5303
22
23
  sparknlp/annotator/graph_extraction.py,sha256=b4SB3B_hFgCJT4e5Jcscyxdzfbvw3ujKTa6UNgX5Lhc,14471
23
24
  sparknlp/annotator/lemmatizer.py,sha256=w1nNMln2HgM4O1DOaISo5AGyzzFHuaIDQqWFcr4JmcA,8970
24
25
  sparknlp/annotator/n_gram_generator.py,sha256=KRX5xfxmorOfYQkQHZWkkXjwjC13gDTAXnukwgz6hKU,5274
25
26
  sparknlp/annotator/normalizer.py,sha256=7AkAOB-e8b2uyUBwYoq9HvMPijOwV3wEoxcB3BVsr4w,8780
27
+ sparknlp/annotator/openai_completion.py,sha256=kigEY5G2lZl2THezx-WDDByJKY1Wx99CPoZdkpik9x4,16899
28
+ sparknlp/annotator/openai_embeddings.py,sha256=eVnLK9t1jDOS58K2YHOyHakILG_4rGtzTIWelqieY9g,109860
26
29
  sparknlp/annotator/stemmer.py,sha256=Tl48voyG9wqbT5MAA1hDKW90NorU8rIDhttJxOo1s3Q,2948
27
30
  sparknlp/annotator/stop_words_cleaner.py,sha256=Z9yI9AWDIAXbPM2X6n84voiW31Z20XofCL-tTQNo5ro,7015
28
31
  sparknlp/annotator/tf_ner_dl_graph_builder.py,sha256=ovsRBUfw9lJkuetmrcYRmW1Ll-33sdDPi4xJ0M_Fs7k,6379
@@ -64,6 +67,7 @@ sparknlp/annotator/classifier_dl/mpnet_for_question_answering.py,sha256=w9hHLrQb
64
67
  sparknlp/annotator/classifier_dl/mpnet_for_sequence_classification.py,sha256=M__giFElL6Q3I88QD6OoXDzdQDk_Zp5sS__Kh_XpLdo,7308
65
68
  sparknlp/annotator/classifier_dl/mpnet_for_token_classification.py,sha256=SgFAJcv7ZE3BmJOehK_CjAaueqaaK6PR33zA5aE9-Ww,6754
66
69
  sparknlp/annotator/classifier_dl/multi_classifier_dl.py,sha256=ylKQzS7ROyeKeiOF4BZiIkQV1sfrnfUUQ9LXFSFK_Vo,16045
70
+ sparknlp/annotator/classifier_dl/roberta_bert_for_zero_shot_classification.py,sha256=nP0D_jg8xPFUMP9uGNvmACIqfwAneDddVXbioHLHFJ0,8818
67
71
  sparknlp/annotator/classifier_dl/roberta_for_multiple_choice.py,sha256=SlzkA_fKurWOQDhvWlEBiMUfLgIoaRRglIdENMv7u38,6008
68
72
  sparknlp/annotator/classifier_dl/roberta_for_question_answering.py,sha256=WRxu1uhXnY9C4UHdtJ8qiVGhPSX7sCdSaML0AWHOdJw,6471
69
73
  sparknlp/annotator/classifier_dl/roberta_for_sequence_classification.py,sha256=z97uH5WkG8kPX1Y9qtpLwD7egl0kzbVmxtq4xzZgNNI,7857
@@ -167,8 +171,9 @@ sparknlp/annotator/sentence/sentence_detector_dl.py,sha256=-Osj9Bm9KyZRTAWkOsK9c
167
171
  sparknlp/annotator/sentiment/__init__.py,sha256=Lq3vKaZS1YATLMg0VNXSVtkWL5q5G9taGBvdrvSwnfg,766
168
172
  sparknlp/annotator/sentiment/sentiment_detector.py,sha256=m545NGU0Xzg_PO6_qIfpli1uZj7JQcyFgqe9R6wAPFI,8154
169
173
  sparknlp/annotator/sentiment/vivekn_sentiment.py,sha256=4rpXWDgzU6ddnbrSCp9VdLb2epCc9oZ3c6XcqxEw8nk,9655
170
- sparknlp/annotator/seq2seq/__init__.py,sha256=Aj43G1MuQE0mW7LakCWPjiTkIGl7iHPAnKIwT_DfdIM,1781
174
+ sparknlp/annotator/seq2seq/__init__.py,sha256=aDiph00Hyq7L8uDY0frtyuHtqFodBqTMbixx_nq4z1I,1841
171
175
  sparknlp/annotator/seq2seq/auto_gguf_model.py,sha256=yhZQHMHfp88rQvLHTWyS-8imZrwqp-8RQQwnw6PmHfc,11749
176
+ sparknlp/annotator/seq2seq/auto_gguf_reranker.py,sha256=QpGpyO1_epWzMospTFrfVVLj2KZ_n3gbHN269vo9fbU,12667
172
177
  sparknlp/annotator/seq2seq/auto_gguf_vision_model.py,sha256=swBek2026dW6BOX5O9P8Uq41X2GC71VGW0ADFeUIvs0,15299
173
178
  sparknlp/annotator/seq2seq/bart_transformer.py,sha256=I1flM4yeCzEAKOdQllBC30XuedxVJ7ferkFhZ6gwEbE,18481
174
179
  sparknlp/annotator/seq2seq/cohere_transformer.py,sha256=43LZBVazZMgJRCsN7HaYjVYfJ5hRMV95QZyxMtXq-m4,13496
@@ -215,6 +220,7 @@ sparknlp/base/multi_document_assembler.py,sha256=4htET1fRAeOB6zhsNXsBq5rKZvn-LGD
215
220
  sparknlp/base/prompt_assembler.py,sha256=_C_9MdHqsxUjSOa3TqCV-6sSfSiRyhfHBQG5m7RlqxY,11578
216
221
  sparknlp/base/recursive_pipeline.py,sha256=V9rTnu8KMwgjoceykN9pF1mKGtOkkuiC_n9v8dE3LDk,4279
217
222
  sparknlp/base/table_assembler.py,sha256=Kxu3R2fY6JgCxEc07ibsMsjip6dgcPDHLiWAZ8gC_d8,5102
223
+ sparknlp/base/token2_chunk.py,sha256=FtS2Doav9xL1IrC9ZUU4iXqyipp-iT3g68kZt-7YCcQ,2674
218
224
  sparknlp/base/token_assembler.py,sha256=qiHry07L7mVCqeHSH6hHxLygv1AsfZIE4jy1L75L3Do,5075
219
225
  sparknlp/common/__init__.py,sha256=MJuE__T1YS8f3As7X5sgzHibGjDeiFkQ5vc2bEEf0Ww,1148
220
226
  sparknlp/common/annotator_approach.py,sha256=CbkyaWl6rRX_VaXz2xJCjofijRGJGeJCsqQTDQgNTAw,1765
@@ -228,7 +234,7 @@ sparknlp/common/read_as.py,sha256=imxPGwV7jr4Li_acbo0OAHHRGCBbYv-akzEGaBWEfcY,12
228
234
  sparknlp/common/recursive_annotator_approach.py,sha256=vqugBw22cE3Ff7PIpRlnYFuOlchgL0nM26D8j-NdpqU,1449
229
235
  sparknlp/common/storage.py,sha256=D91H3p8EIjNspjqAYu6ephRpCUtdcAir4_PrAbkIQWE,4842
230
236
  sparknlp/common/utils.py,sha256=Yne6yYcwKxhOZC-U4qfYoDhWUP_6BIaAjI5X_P_df1E,1306
231
- sparknlp/internal/__init__.py,sha256=f5kxLz6bEX8FCMo6lek30MXbn_lDC-dBTI9s_fARblI,40748
237
+ sparknlp/internal/__init__.py,sha256=m7Y7y-IPkB6aJuGUCM54eOueGOEt65C3ujAzN16hegQ,40995
232
238
  sparknlp/internal/annotator_java_ml.py,sha256=UGPoThG0rGXUOXGSQnDzEDW81Mu1s5RPF29v7DFyE3c,1187
233
239
  sparknlp/internal/annotator_transformer.py,sha256=fXmc2IWXGybqZpbEU9obmbdBYPc798y42zvSB4tqV9U,1448
234
240
  sparknlp/internal/extended_java_wrapper.py,sha256=hwP0133-hDiDf5sBF-P3MtUsuuDj1PpQbtGZQIRwzfk,2240
@@ -248,6 +254,7 @@ sparknlp/reader/__init__.py,sha256=-Toj3AIBki-zXPpV8ezFTI2LX1yP_rK2bhpoa8nBkTw,6
248
254
  sparknlp/reader/enums.py,sha256=MNGug9oJ1BBLM1Pbske13kAabalDzHa2kucF5xzFpHs,770
249
255
  sparknlp/reader/pdf_to_text.py,sha256=eWw-cwjosmcSZ9eHso0F5QQoeGBBnwsOhzhCXXvMjZA,7169
250
256
  sparknlp/reader/reader2doc.py,sha256=LRqfaL9nidhlPkJIwTJo7SnGYmNNfOqwEdrsWYGEdnI,7146
257
+ sparknlp/reader/reader2image.py,sha256=JIwgVtznBpSExLl3JX7QY3BT4CUmZf1JWbsSwKLV1aY,3099
251
258
  sparknlp/reader/reader2table.py,sha256=GC6Yz0gQ83S6XKOi329TUNQuAvLrBxysqDkDRZPvcYA,4759
252
259
  sparknlp/reader/sparknlp_reader.py,sha256=MJs8v_ECYaV1SOabI1L_2MkVYEDVImtwgbYypO7DJSY,20623
253
260
  sparknlp/training/__init__.py,sha256=qREi9u-5Vc2VjpL6-XZsyvu5jSEIdIhowW7_kKaqMqo,852
@@ -280,7 +287,7 @@ sparknlp/training/_tf_graph_builders_1x/ner_dl/dataset_encoder.py,sha256=R4yHFN3
280
287
  sparknlp/training/_tf_graph_builders_1x/ner_dl/ner_model.py,sha256=EoCSdcIjqQ3wv13MAuuWrKV8wyVBP0SbOEW41omHlR0,23189
281
288
  sparknlp/training/_tf_graph_builders_1x/ner_dl/ner_model_saver.py,sha256=k5CQ7gKV6HZbZMB8cKLUJuZxoZWlP_DFWdZ--aIDwsc,2356
282
289
  sparknlp/training/_tf_graph_builders_1x/ner_dl/sentence_grouper.py,sha256=pAxjWhjazSX8Vg0MFqJiuRVw1IbnQNSs-8Xp26L4nko,870
283
- spark_nlp-6.1.2rc1.dist-info/METADATA,sha256=4qK5_LPihfkDmSrLBQgH38R_VE5lzDnsygPpOccUTdc,19777
284
- spark_nlp-6.1.2rc1.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
285
- spark_nlp-6.1.2rc1.dist-info/top_level.txt,sha256=uuytur4pyMRw2H_txNY2ZkaucZHUs22QF8-R03ch_-E,13
286
- spark_nlp-6.1.2rc1.dist-info/RECORD,,
290
+ spark_nlp-6.1.3rc1.dist-info/METADATA,sha256=q-hbjHon_67zz6Zp0s7KhdoSSIQw0z9l-tzYPDs6pfU,19777
291
+ spark_nlp-6.1.3rc1.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
292
+ spark_nlp-6.1.3rc1.dist-info/top_level.txt,sha256=uuytur4pyMRw2H_txNY2ZkaucZHUs22QF8-R03ch_-E,13
293
+ spark_nlp-6.1.3rc1.dist-info/RECORD,,
sparknlp/__init__.py CHANGED
@@ -66,7 +66,7 @@ sys.modules['com.johnsnowlabs.ml.ai'] = annotator
66
66
  annotators = annotator
67
67
  embeddings = annotator
68
68
 
69
- __version__ = "6.1.1"
69
+ __version__ = "6.1.3"
70
70
 
71
71
 
72
72
  def start(gpu=False,
@@ -0,0 +1,225 @@
1
+ # Copyright 2017-2023 John Snow Labs
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """Contains classes for RoBertaForZeroShotClassification."""
15
+
16
+ from sparknlp.common import *
17
+
18
+
19
+ class RoBertaForZeroShotClassification(AnnotatorModel,
20
+ HasCaseSensitiveProperties,
21
+ HasBatchedAnnotate,
22
+ HasClassifierActivationProperties,
23
+ HasCandidateLabelsProperties,
24
+ HasEngine):
25
+ """RoBertaForZeroShotClassification using a `ModelForSequenceClassification` trained on NLI (natural language
26
+ inference) tasks. Equivalent of `RoBertaForSequenceClassification` models, but these models don't require a hardcoded
27
+ number of potential classes, they can be chosen at runtime. It usually means it's slower but it is much more
28
+ flexible.
29
+
30
+ Note that the model will loop through all provided labels. So the more labels you have, the
31
+ longer this process will take.
32
+
33
+ Any combination of sequences and labels can be passed and each combination will be posed as a premise/hypothesis
34
+ pair and passed to the pretrained model.
35
+
36
+ Pretrained models can be loaded with :meth:`.pretrained` of the companion
37
+ object:
38
+
39
+ >>> sequenceClassifier = RoBertaForZeroShotClassification.pretrained() \\
40
+ ... .setInputCols(["token", "document"]) \\
41
+ ... .setOutputCol("label")
42
+
43
+ The default model is ``"roberta_base_zero_shot_classifier_nli"``, if no name is
44
+ provided.
45
+
46
+ For available pretrained models please see the `Models Hub
47
+ <https://sparknlp.orgtask=Text+Classification>`__.
48
+
49
+ To see which models are compatible and how to import them see
50
+ `Import Transformers into Spark NLP 🚀
51
+ <https://github.com/JohnSnowLabs/spark-nlp/discussions/5669>`_.
52
+
53
+ ====================== ======================
54
+ Input Annotation types Output Annotation type
55
+ ====================== ======================
56
+ ``DOCUMENT, TOKEN`` ``CATEGORY``
57
+ ====================== ======================
58
+
59
+ Parameters
60
+ ----------
61
+ batchSize
62
+ Batch size. Large values allows faster processing but requires more
63
+ memory, by default 8
64
+ caseSensitive
65
+ Whether to ignore case in tokens for embeddings matching, by default
66
+ True
67
+ configProtoBytes
68
+ ConfigProto from tensorflow, serialized into byte array.
69
+ maxSentenceLength
70
+ Max sentence length to process, by default 128
71
+ coalesceSentences
72
+ Instead of 1 class per sentence (if inputCols is `sentence`) output 1
73
+ class per document by averaging probabilities in all sentences, by
74
+ default False
75
+ activation
76
+ Whether to calculate logits via Softmax or Sigmoid, by default
77
+ `"softmax"`.
78
+
79
+ Examples
80
+ --------
81
+ >>> import sparknlp
82
+ >>> from sparknlp.base import *
83
+ >>> from sparknlp.annotator import *
84
+ >>> from pyspark.ml import Pipeline
85
+ >>> documentAssembler = DocumentAssembler() \\
86
+ ... .setInputCol("text") \\
87
+ ... .setOutputCol("document")
88
+ >>> tokenizer = Tokenizer() \\
89
+ ... .setInputCols(["document"]) \\
90
+ ... .setOutputCol("token")
91
+ >>> sequenceClassifier = RoBertaForZeroShotClassification.pretrained() \\
92
+ ... .setInputCols(["token", "document"]) \\
93
+ ... .setOutputCol("label") \\
94
+ ... .setCaseSensitive(True)
95
+ >>> pipeline = Pipeline().setStages([
96
+ ... documentAssembler,
97
+ ... tokenizer,
98
+ ... sequenceClassifier
99
+ ... ])
100
+ >>> data = spark.createDataFrame([["I loved this movie when I was a child.", "It was pretty boring."]]).toDF("text")
101
+ >>> result = pipeline.fit(data).transform(data)
102
+ >>> result.select("label.result").show(truncate=False)
103
+ +------+
104
+ |result|
105
+ +------+
106
+ |[pos] |
107
+ |[neg] |
108
+ +------+
109
+ """
110
+ name = "RoBertaForZeroShotClassification"
111
+
112
+ inputAnnotatorTypes = [AnnotatorType.DOCUMENT, AnnotatorType.TOKEN]
113
+
114
+ outputAnnotatorType = AnnotatorType.CATEGORY
115
+
116
+ maxSentenceLength = Param(Params._dummy(),
117
+ "maxSentenceLength",
118
+ "Max sentence length to process",
119
+ typeConverter=TypeConverters.toInt)
120
+
121
+ configProtoBytes = Param(Params._dummy(),
122
+ "configProtoBytes",
123
+ "ConfigProto from tensorflow, serialized into byte array. Get with config_proto.SerializeToString()",
124
+ TypeConverters.toListInt)
125
+
126
+ coalesceSentences = Param(Params._dummy(), "coalesceSentences",
127
+ "Instead of 1 class per sentence (if inputCols is '''sentence''') output 1 class per document by averaging probabilities in all sentences.",
128
+ TypeConverters.toBoolean)
129
+
130
+ def getClasses(self):
131
+ """
132
+ Returns labels used to train this model
133
+ """
134
+ return self._call_java("getClasses")
135
+
136
+ def setConfigProtoBytes(self, b):
137
+ """Sets configProto from tensorflow, serialized into byte array.
138
+
139
+ Parameters
140
+ ----------
141
+ b : List[int]
142
+ ConfigProto from tensorflow, serialized into byte array
143
+ """
144
+ return self._set(configProtoBytes=b)
145
+
146
+ def setMaxSentenceLength(self, value):
147
+ """Sets max sentence length to process, by default 128.
148
+
149
+ Parameters
150
+ ----------
151
+ value : int
152
+ Max sentence length to process
153
+ """
154
+ return self._set(maxSentenceLength=value)
155
+
156
+ def setCoalesceSentences(self, value):
157
+ """Instead of 1 class per sentence (if inputCols is '''sentence''') output 1 class per document by averaging
158
+ probabilities in all sentences. Due to max sequence length limit in almost all transformer models such as RoBerta
159
+ (512 tokens), this parameter helps to feed all the sentences into the model and averaging all the probabilities
160
+ for the entire document instead of probabilities per sentence. (Default: true)
161
+
162
+ Parameters
163
+ ----------
164
+ value : bool
165
+ If the output of all sentences will be averaged to one output
166
+ """
167
+ return self._set(coalesceSentences=value)
168
+
169
+ @keyword_only
170
+ def __init__(self, classname="com.johnsnowlabs.nlp.annotators.classifier.dl.RoBertaForZeroShotClassification",
171
+ java_model=None):
172
+ super(RoBertaForZeroShotClassification, self).__init__(
173
+ classname=classname,
174
+ java_model=java_model
175
+ )
176
+ self._setDefault(
177
+ batchSize=8,
178
+ maxSentenceLength=128,
179
+ caseSensitive=True,
180
+ coalesceSentences=False,
181
+ activation="softmax"
182
+ )
183
+
184
+ @staticmethod
185
+ def loadSavedModel(folder, spark_session):
186
+ """Loads a locally saved model.
187
+
188
+ Parameters
189
+ ----------
190
+ folder : str
191
+ Folder of the saved model
192
+ spark_session : pyspark.sql.SparkSession
193
+ The current SparkSession
194
+
195
+ Returns
196
+ -------
197
+ RoBertaForZeroShotClassification
198
+ The restored model
199
+ """
200
+ from sparknlp.internal import _RoBertaForZeroShotClassification
201
+ jModel = _RoBertaForZeroShotClassification(folder, spark_session._jsparkSession)._java_obj
202
+ return RoBertaForZeroShotClassification(java_model=jModel)
203
+
204
+ @staticmethod
205
+ def pretrained(name="roberta_base_zero_shot_classifier_nli", lang="en", remote_loc=None):
206
+ """Downloads and loads a pretrained model.
207
+
208
+ Parameters
209
+ ----------
210
+ name : str, optional
211
+ Name of the pretrained model, by default
212
+ "roberta_base_zero_shot_classifier_nli"
213
+ lang : str, optional
214
+ Language of the pretrained model, by default "en"
215
+ remote_loc : str, optional
216
+ Optional remote address of the resource, by default None. Will use
217
+ Spark NLPs repositories otherwise.
218
+
219
+ Returns
220
+ -------
221
+ RoBertaForZeroShotClassification
222
+ The restored model
223
+ """
224
+ from sparknlp.pretrained import ResourceDownloader
225
+ return ResourceDownloader.downloadModel(RoBertaForZeroShotClassification, name, lang, remote_loc)
@@ -0,0 +1,174 @@
1
+ # Copyright 2017-2025 John Snow Labs
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """Contains classes for Extractor."""
15
+ from sparknlp.common import *
16
+
17
+ class Extractor(AnnotatorModel):
18
+ name = "Extractor"
19
+
20
+ inputAnnotatorTypes = [AnnotatorType.DOCUMENT]
21
+
22
+ outputAnnotatorType = AnnotatorType.CHUNK
23
+
24
+ emailDateTimeTzPattern = Param(Params._dummy(),
25
+ "emailDateTimeTzPattern",
26
+ "Specifies the date-time pattern for email timestamps, including time zone formatting.",
27
+ typeConverter=TypeConverters.toString)
28
+
29
+ emailAddress = Param(
30
+ Params._dummy(),
31
+ "emailAddress",
32
+ "Specifies the pattern for email addresses.",
33
+ typeConverter=TypeConverters.toString
34
+ )
35
+
36
+ ipAddressPattern = Param(
37
+ Params._dummy(),
38
+ "ipAddressPattern",
39
+ "Specifies the pattern for IP addresses.",
40
+ typeConverter=TypeConverters.toString
41
+ )
42
+
43
+ ipAddressNamePattern = Param(
44
+ Params._dummy(),
45
+ "ipAddressNamePattern",
46
+ "Specifies the pattern for IP addresses with names.",
47
+ typeConverter=TypeConverters.toString
48
+ )
49
+
50
+ mapiIdPattern = Param(
51
+ Params._dummy(),
52
+ "mapiIdPattern",
53
+ "Specifies the pattern for MAPI IDs.",
54
+ typeConverter=TypeConverters.toString
55
+ )
56
+
57
+ usPhoneNumbersPattern = Param(
58
+ Params._dummy(),
59
+ "usPhoneNumbersPattern",
60
+ "Specifies the pattern for US phone numbers.",
61
+ typeConverter=TypeConverters.toString
62
+ )
63
+
64
+ imageUrlPattern = Param(
65
+ Params._dummy(),
66
+ "imageUrlPattern",
67
+ "Specifies the pattern for image URLs.",
68
+ typeConverter=TypeConverters.toString
69
+ )
70
+
71
+ textPattern = Param(
72
+ Params._dummy(),
73
+ "textPattern",
74
+ "Specifies the pattern for text after and before.",
75
+ typeConverter=TypeConverters.toString
76
+ )
77
+
78
+ extractorMode = Param(
79
+ Params._dummy(),
80
+ "extractorMode",
81
+ "possible values: " +
82
+ "email_date, email_address, ip_address, ip_address_name, mapi_id, us_phone_numbers, image_urls, bullets, text_after, text_before",
83
+ typeConverter=TypeConverters.toString
84
+ )
85
+
86
+ def setEmailDateTimeTzPattern(self, value):
87
+ """Sets specifies the date-time pattern for email timestamps, including time zone formatting.
88
+
89
+ Parameters
90
+ ----------
91
+ value : str
92
+ Specifies the date-time pattern for email timestamps, including time zone formatting.
93
+ """
94
+ return self._set(emailDateTimeTzPattern=value)
95
+
96
+ def setEmailAddress(self, value):
97
+ """Sets the pattern for email addresses.
98
+
99
+ Parameters
100
+ ----------
101
+ value : str
102
+ Specifies the pattern for email addresses.
103
+ """
104
+ return self._set(emailAddress=value)
105
+
106
+ def setIpAddressPattern(self, value):
107
+ """Sets the pattern for IP addresses.
108
+
109
+ Parameters
110
+ ----------
111
+ value : str
112
+ Specifies the pattern for IP addresses.
113
+ """
114
+ return self._set(ipAddressPattern=value)
115
+
116
+ def setIpAddressNamePattern(self, value):
117
+ """Sets the pattern for IP addresses with names.
118
+
119
+ Parameters
120
+ ----------
121
+ value : str
122
+ Specifies the pattern for IP addresses with names.
123
+ """
124
+ return self._set(ipAddressNamePattern=value)
125
+
126
+ def setMapiIdPattern(self, value):
127
+ """Sets the pattern for MAPI IDs.
128
+
129
+ Parameters
130
+ ----------
131
+ value : str
132
+ Specifies the pattern for MAPI IDs.
133
+ """
134
+ return self._set(mapiIdPattern=value)
135
+
136
+ def setUsPhoneNumbersPattern(self, value):
137
+ """Sets the pattern for US phone numbers.
138
+
139
+ Parameters
140
+ ----------
141
+ value : str
142
+ Specifies the pattern for US phone numbers.
143
+ """
144
+ return self._set(usPhoneNumbersPattern=value)
145
+
146
+ def setImageUrlPattern(self, value):
147
+ """Sets the pattern for image URLs.
148
+
149
+ Parameters
150
+ ----------
151
+ value : str
152
+ Specifies the pattern for image URLs.
153
+ """
154
+ return self._set(imageUrlPattern=value)
155
+
156
+ def setTextPattern(self, value):
157
+ """Sets the pattern for text after and before.
158
+
159
+ Parameters
160
+ ----------
161
+ value : str
162
+ Specifies the pattern for text after and before.
163
+ """
164
+ return self._set(textPattern=value)
165
+
166
+ def setExtractorMode(self, value):
167
+ return self._set(extractorMode=value)
168
+
169
+ @keyword_only
170
+ def __init__(self, classname="com.johnsnowlabs.nlp.annotators.Extractor", java_model=None):
171
+ super(Extractor, self).__init__(
172
+ classname=classname,
173
+ java_model=java_model
174
+ )