deeplotx 0.9.6__tar.gz → 0.9.7b0__tar.gz

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.
Files changed (45) hide show
  1. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/PKG-INFO +1 -1
  2. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/encoder/encoder.py +2 -9
  3. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/encoder/longformer_encoder.py +2 -9
  4. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/ner/bert_ner.py +4 -9
  5. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/util/read_file.py +11 -0
  6. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx.egg-info/PKG-INFO +1 -1
  7. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/pyproject.toml +1 -1
  8. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/LICENSE +0 -0
  9. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/README.md +0 -0
  10. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/__init__.py +0 -0
  11. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/encoder/__init__.py +0 -0
  12. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/encoder/long_text_encoder.py +0 -0
  13. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/ner/__init__.py +0 -0
  14. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/ner/base_ner.py +0 -0
  15. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/ner/n2g/__init__.py +0 -0
  16. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/ner/named_entity.py +0 -0
  17. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/nn/__init__.py +0 -0
  18. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/nn/attention.py +0 -0
  19. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/nn/auto_regression.py +0 -0
  20. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/nn/base_neural_network.py +0 -0
  21. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/nn/feed_forward.py +0 -0
  22. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/nn/linear_regression.py +0 -0
  23. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/nn/logistic_regression.py +0 -0
  24. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/nn/long_context_auto_regression.py +0 -0
  25. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/nn/long_context_recursive_sequential.py +0 -0
  26. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/nn/multi_head_attention.py +0 -0
  27. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/nn/multi_head_feed_forward.py +0 -0
  28. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/nn/recursive_sequential.py +0 -0
  29. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/nn/roformer_encoder.py +0 -0
  30. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/nn/rope.py +0 -0
  31. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/nn/softmax_regression.py +0 -0
  32. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/similarity/__init__.py +0 -0
  33. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/similarity/distribution.py +0 -0
  34. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/similarity/set.py +0 -0
  35. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/similarity/vector.py +0 -0
  36. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/trainer/__init__.py +0 -0
  37. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/trainer/base_trainer.py +0 -0
  38. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/trainer/text_binary_classification_trainer.py +0 -0
  39. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/util/__init__.py +0 -0
  40. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx/util/hash.py +0 -0
  41. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx.egg-info/SOURCES.txt +0 -0
  42. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx.egg-info/dependency_links.txt +0 -0
  43. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx.egg-info/requires.txt +0 -0
  44. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/deeplotx.egg-info/top_level.txt +0 -0
  45. {deeplotx-0.9.6 → deeplotx-0.9.7b0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deeplotx
3
- Version: 0.9.6
3
+ Version: 0.9.7b0
4
4
  Summary: An out-of-the-box long-text NLP framework.
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -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 ConnectTimeout:
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 ConnectTimeout:
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)
@@ -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 ConnectTimeout:
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:
@@ -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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deeplotx
3
- Version: 0.9.6
3
+ Version: 0.9.7b0
4
4
  Summary: An out-of-the-box long-text NLP framework.
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "deeplotx"
3
- version = '0.9.6'
3
+ version = '0.9.7.beta'
4
4
  description = "An out-of-the-box long-text NLP framework."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
File without changes
File without changes
File without changes
File without changes