Nlp Api
This module provides interfaces for interacting with various NLP APIs, including the Italian NLP API and the CoNLL API.
Classes:
Name | Description |
---|---|
ItaliaNLAPI |
Interface for interacting with the Italian NLP API. |
ConllAPISingleton |
Singleton class for interacting with the CoNLL API. |
Attributes:
Name | Type | Description |
---|---|---|
None |
|
Functions:
Name | Description |
---|---|
None |
|
ConllAPISingleton
Singleton class for interacting with the CoNLL API.
Attributes:
Name | Type | Description |
---|---|---|
_instance |
ConllAPISingleton
|
Singleton instance of the class. |
_models |
dict[str, str]
|
Dictionary mapping languages to their best performing models. |
Methods:
Name | Description |
---|---|
__new__ |
Creates a new instance of the class if one does not already exist. |
Source code in apps/annotator/code/services/NLP_API.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
|
ItaliaNLAPI
Interface for interacting with the Italian NLP API.
Attributes:
Name | Type | Description |
---|---|---|
_instance |
ItaliaNLAPI
|
Singleton instance of the class. |
_server_address |
str
|
Address of the Italian NLP API server. |
_max_term_len |
int
|
Maximum length of terms. |
_term_extraction_configs |
dict
|
Configuration for term extraction. |
Methods:
Name | Description |
---|---|
upload_document |
Uploads a document to the server. |
wait_for_named_entity_tag |
Waits for named entity tagging to complete. |
wait_for_pos_tagging |
Waits for POS tagging to complete. |
execute_term_extraction |
Executes term extraction on the document. |
Source code in apps/annotator/code/services/NLP_API.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
execute_term_extraction(doc_id, configuration=None, apply_contrast=True, n_try=60)
Executes term extraction on the document.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
doc_id
|
str
|
ID of the document. |
required |
configuration
|
dict
|
Configuration for term extraction, by default None. |
None
|
apply_contrast
|
bool
|
Whether to apply contrast in term extraction, by default True. |
True
|
n_try
|
int
|
Number of attempts to check for term extraction completion, by default 60. |
60
|
Returns:
Type | Description |
---|---|
DataFrame
|
DataFrame containing extracted terms. |
Source code in apps/annotator/code/services/NLP_API.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
upload_document(text, language, async_call=True)
Uploads a document to the server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
Text of the document to upload. |
required |
language
|
str
|
Language of the document. |
required |
async_call
|
bool
|
Whether to make the API call asynchronously, by default True. |
True
|
Returns:
Type | Description |
---|---|
str
|
ID of the uploaded document. |
Source code in apps/annotator/code/services/NLP_API.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
wait_for_named_entity_tag(doc_id)
Waits for named entity tagging to complete.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
doc_id
|
str
|
ID of the document. |
required |
Source code in apps/annotator/code/services/NLP_API.py
116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
wait_for_pos_tagging(doc_id)
Waits for POS tagging to complete.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
doc_id
|
str
|
ID of the document. |
required |
Source code in apps/annotator/code/services/NLP_API.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|