text-peccavi commited on
Commit
09f13aa
·
verified ·
1 Parent(s): fbdbef2

Update utils/non_melting_point.py

Browse files
Files changed (1) hide show
  1. utils/non_melting_point.py +14 -0
utils/non_melting_point.py CHANGED
@@ -8,6 +8,8 @@ import re
8
  from tqdm import tqdm
9
  from spacy.cli import download
10
 
 
 
11
 
12
  # Logging setup
13
  logging.basicConfig(level=logging.WARNING, format="%(asctime)s - %(levelname)s - %(message)s")
@@ -25,6 +27,18 @@ class NgramProcessor:
25
  if models is None:
26
  models = ["en_core_web_trf"]
27
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  # Load specified model
29
  self.models = {}
30
  for model_name in models:
 
8
  from tqdm import tqdm
9
  from spacy.cli import download
10
 
11
+ # Add imports for the curated transformer support
12
+ from spacy.util import registry
13
 
14
  # Logging setup
15
  logging.basicConfig(level=logging.WARNING, format="%(asctime)s - %(levelname)s - %(message)s")
 
27
  if models is None:
28
  models = ["en_core_web_trf"]
29
 
30
+ # Check and register curated transformer if needed
31
+ if "curated_transformer" not in registry.factories.get_names("pipe", "en"):
32
+ try:
33
+ # Try to import and register the curated transformer
34
+ import spacy_curated_transformers
35
+ from spacy_curated_transformers import CuratedTransformer
36
+ from spacy.language import Language
37
+ Language.factory("curated_transformer", func=CuratedTransformer)
38
+ tqdm.write("[NgramProcessor] Registered curated_transformer factory")
39
+ except ImportError:
40
+ tqdm.write("[NgramProcessor] Warning: spacy_curated_transformers not found. Some models may not load correctly.")
41
+
42
  # Load specified model
43
  self.models = {}
44
  for model_name in models: