deeplotx 0.9.6__py3-none-any.whl → 0.9.7b0__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.
- deeplotx/encoder/encoder.py +2 -9
- deeplotx/encoder/longformer_encoder.py +2 -9
- deeplotx/ner/bert_ner.py +4 -9
- deeplotx/util/read_file.py +11 -0
- {deeplotx-0.9.6.dist-info → deeplotx-0.9.7b0.dist-info}/METADATA +1 -1
- {deeplotx-0.9.6.dist-info → deeplotx-0.9.7b0.dist-info}/RECORD +9 -9
- {deeplotx-0.9.6.dist-info → deeplotx-0.9.7b0.dist-info}/WHEEL +0 -0
- {deeplotx-0.9.6.dist-info → deeplotx-0.9.7b0.dist-info}/licenses/LICENSE +0 -0
- {deeplotx-0.9.6.dist-info → deeplotx-0.9.7b0.dist-info}/top_level.txt +0 -0
deeplotx/encoder/encoder.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
import logging
|
2
2
|
import os
|
3
3
|
import math
|
4
|
-
from requests.exceptions import ConnectTimeout, SSLError
|
5
4
|
|
6
5
|
import torch
|
7
6
|
from torch import nn
|
7
|
+
from requests.exceptions import RequestException
|
8
8
|
from transformers import AutoTokenizer, AutoModel
|
9
9
|
|
10
10
|
from deeplotx import __ROOT__
|
@@ -26,14 +26,7 @@ class Encoder(nn.Module):
|
|
26
26
|
self.encoder = AutoModel.from_pretrained(pretrained_model_name_or_path=model_name_or_path,
|
27
27
|
cache_dir=CACHE_PATH, _from_auto=True,
|
28
28
|
trust_remote_code=True).to(self.device)
|
29
|
-
except
|
30
|
-
self.tokenizer = AutoTokenizer.from_pretrained(pretrained_model_name_or_path=model_name_or_path,
|
31
|
-
cache_dir=CACHE_PATH, _from_auto=True,
|
32
|
-
trust_remote_code=True, local_files_only=True)
|
33
|
-
self.encoder = AutoModel.from_pretrained(pretrained_model_name_or_path=model_name_or_path,
|
34
|
-
cache_dir=CACHE_PATH, _from_auto=True,
|
35
|
-
trust_remote_code=True, local_files_only=True).to(self.device)
|
36
|
-
except SSLError:
|
29
|
+
except RequestException:
|
37
30
|
self.tokenizer = AutoTokenizer.from_pretrained(pretrained_model_name_or_path=model_name_or_path,
|
38
31
|
cache_dir=CACHE_PATH, _from_auto=True,
|
39
32
|
trust_remote_code=True, local_files_only=True)
|
@@ -3,8 +3,8 @@ import os
|
|
3
3
|
|
4
4
|
import torch
|
5
5
|
from torch import nn
|
6
|
+
from requests.exceptions import RequestException
|
6
7
|
from transformers import AutoModel, AutoTokenizer
|
7
|
-
from requests.exceptions import ConnectTimeout, SSLError
|
8
8
|
|
9
9
|
from deeplotx import __ROOT__
|
10
10
|
|
@@ -25,14 +25,7 @@ class LongformerEncoder(nn.Module):
|
|
25
25
|
self.encoder = AutoModel.from_pretrained(pretrained_model_name_or_path=model_name_or_path,
|
26
26
|
cache_dir=CACHE_PATH, _from_auto=True,
|
27
27
|
trust_remote_code=True).to(self.device)
|
28
|
-
except
|
29
|
-
self.tokenizer = AutoTokenizer.from_pretrained(pretrained_model_name_or_path=model_name_or_path,
|
30
|
-
cache_dir=CACHE_PATH, _from_auto=True,
|
31
|
-
trust_remote_code=True, local_files_only=True)
|
32
|
-
self.encoder = AutoModel.from_pretrained(pretrained_model_name_or_path=model_name_or_path,
|
33
|
-
cache_dir=CACHE_PATH, _from_auto=True,
|
34
|
-
trust_remote_code=True, local_files_only=True).to(self.device)
|
35
|
-
except SSLError:
|
28
|
+
except RequestException:
|
36
29
|
self.tokenizer = AutoTokenizer.from_pretrained(pretrained_model_name_or_path=model_name_or_path,
|
37
30
|
cache_dir=CACHE_PATH, _from_auto=True,
|
38
31
|
trust_remote_code=True, local_files_only=True)
|
deeplotx/ner/bert_ner.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import logging
|
2
2
|
import os
|
3
|
-
from requests.exceptions import ConnectTimeout, SSLError
|
4
3
|
|
5
4
|
import torch
|
5
|
+
from requests.exceptions import RequestException
|
6
6
|
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
|
7
7
|
|
8
8
|
from deeplotx import __ROOT__
|
@@ -30,14 +30,7 @@ class BertNER(BaseNER):
|
|
30
30
|
self.encoder = AutoModelForTokenClassification.from_pretrained(pretrained_model_name_or_path=model_name_or_path,
|
31
31
|
cache_dir=CACHE_PATH, _from_auto=True,
|
32
32
|
trust_remote_code=True).to(self.device)
|
33
|
-
except
|
34
|
-
self.tokenizer = AutoTokenizer.from_pretrained(pretrained_model_name_or_path=model_name_or_path,
|
35
|
-
cache_dir=CACHE_PATH, _from_auto=True,
|
36
|
-
trust_remote_code=True, local_files_only=True)
|
37
|
-
self.encoder = AutoModelForTokenClassification.from_pretrained(pretrained_model_name_or_path=model_name_or_path,
|
38
|
-
cache_dir=CACHE_PATH, _from_auto=True,
|
39
|
-
trust_remote_code=True, local_files_only=True).to(self.device)
|
40
|
-
except SSLError:
|
33
|
+
except RequestException:
|
41
34
|
self.tokenizer = AutoTokenizer.from_pretrained(pretrained_model_name_or_path=model_name_or_path,
|
42
35
|
cache_dir=CACHE_PATH, _from_auto=True,
|
43
36
|
trust_remote_code=True, local_files_only=True)
|
@@ -74,6 +67,8 @@ class BertNER(BaseNER):
|
|
74
67
|
break
|
75
68
|
for ent in entities:
|
76
69
|
ent[0] = ent[0].strip()
|
70
|
+
if len(ent[0]) < 1:
|
71
|
+
ent[0] = ' '
|
77
72
|
# stripping
|
78
73
|
while not ent[0][0].isalpha():
|
79
74
|
if len(ent[0]) < 2:
|
deeplotx/util/read_file.py
CHANGED
@@ -13,6 +13,17 @@ def read_file(path: str, encoding: str = 'utf-8') -> str:
|
|
13
13
|
pass
|
14
14
|
|
15
15
|
|
16
|
+
def write_file(content: str | bytes, path: str, encoding: str = 'utf-8') -> str:
|
17
|
+
os.makedirs(os.path.dirname(path), exist_ok=True)
|
18
|
+
if isinstance(content, bytes):
|
19
|
+
with open(path, mode='wb') as f:
|
20
|
+
f.write(content)
|
21
|
+
return path
|
22
|
+
with open(path, mode='w', encoding=encoding) as f:
|
23
|
+
f.write(content)
|
24
|
+
return path
|
25
|
+
|
26
|
+
|
16
27
|
def get_files(path: str) -> list:
|
17
28
|
if os.path.exists(path):
|
18
29
|
entries = os.listdir(path)
|
@@ -1,11 +1,11 @@
|
|
1
1
|
deeplotx/__init__.py,sha256=x4CbJuW20al6S5KkKyrReeuwNGv04JGoqtGUyx-ACtg,1356
|
2
2
|
deeplotx/encoder/__init__.py,sha256=BrsF5_4O-4pfihYF2wjExDOoAY-03kGJTH-Mhez4tsE,129
|
3
|
-
deeplotx/encoder/encoder.py,sha256=
|
3
|
+
deeplotx/encoder/encoder.py,sha256=uJswUSrYVDWP84HeCD40R9KgXGPUEa080konv7jEp8I,3539
|
4
4
|
deeplotx/encoder/long_text_encoder.py,sha256=4oRa9FqfGNZ8-gq14UKuhDkZC0A1Xi-wKmbQsn-uZ58,3966
|
5
|
-
deeplotx/encoder/longformer_encoder.py,sha256=
|
5
|
+
deeplotx/encoder/longformer_encoder.py,sha256=mfAI_NE3QQZhvGHbZkP7S6g0Jj59wmLWQ9QW7HOjqm0,2876
|
6
6
|
deeplotx/ner/__init__.py,sha256=Rss1pup9HzHZCG8U9ub8niWa9zRjWCy3Z7zg378KZQg,114
|
7
7
|
deeplotx/ner/base_ner.py,sha256=pZTl50OrHH_FJm4rKp9iuixeOE6FX_AzgDXD32aXsN0,204
|
8
|
-
deeplotx/ner/bert_ner.py,sha256=
|
8
|
+
deeplotx/ner/bert_ner.py,sha256=6al5iMc8gb3XuJf7dbJd-noXShLYmRoLXTd8L1-wYMM,8581
|
9
9
|
deeplotx/ner/named_entity.py,sha256=c6XufIwH6yloJ-ccUjagf4mBl1XbbYDT8xyEJJ_-ZNs,269
|
10
10
|
deeplotx/ner/n2g/__init__.py,sha256=b6fOWJVLaOCtoz8Qlp8NWQbL5lUSbn6H3-8fnVNIPi0,3940
|
11
11
|
deeplotx/nn/__init__.py,sha256=YILwbxb-NHdiJjfOwBKH8F7PuZSDZSrGpTznPDucTro,710
|
@@ -32,9 +32,9 @@ deeplotx/trainer/base_trainer.py,sha256=z0MeAT-rRYmjeBXt0ckt7J1itYArR0Cx02wHesXU
|
|
32
32
|
deeplotx/trainer/text_binary_classification_trainer.py,sha256=TFxOX8rWU_zKliI9zm7F5ZH7snR2d-sk95s3pfTmm78,6601
|
33
33
|
deeplotx/util/__init__.py,sha256=5CH4MTeSgsmCe3LPMfvKoSBpwh6jDSBuHVElJvzQzgs,90
|
34
34
|
deeplotx/util/hash.py,sha256=qbNU3RLBWGQYFVte9WZBAkZ1BkdjCXiKLDaKPN54KFk,662
|
35
|
-
deeplotx/util/read_file.py,sha256=
|
36
|
-
deeplotx-0.9.
|
37
|
-
deeplotx-0.9.
|
38
|
-
deeplotx-0.9.
|
39
|
-
deeplotx-0.9.
|
40
|
-
deeplotx-0.9.
|
35
|
+
deeplotx/util/read_file.py,sha256=O9nieNgAGQ7Ct1EFxCdcgL6hVs5s2Vw_ItcUK6VeTwY,981
|
36
|
+
deeplotx-0.9.7b0.dist-info/licenses/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
|
37
|
+
deeplotx-0.9.7b0.dist-info/METADATA,sha256=TFuaNIUCzu6JefhA33sDyBV-Wh3PHgCWclCDKKICfT4,14444
|
38
|
+
deeplotx-0.9.7b0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
39
|
+
deeplotx-0.9.7b0.dist-info/top_level.txt,sha256=hKg4pVDXZ-WWxkRfJFczRIll1Sv7VyfKCmzHLXbuh1U,9
|
40
|
+
deeplotx-0.9.7b0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|