goberoi commited on
Commit
9d25ef8
·
verified ·
1 Parent(s): f3df499

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +6 -1
main.py CHANGED
@@ -1,5 +1,6 @@
1
  import chardet
2
  import spacy
 
3
 
4
  # ------------------------
5
  # CONFIGURATION
@@ -15,7 +16,11 @@ custom_spacy_config = {
15
  }
16
 
17
  # Load SpaCy and add GLiNER to the pipeline
18
- nlp = spacy.load("en_core_web_lg")
 
 
 
 
19
  nlp.add_pipe("gliner_spacy", config=custom_spacy_config)
20
 
21
  def detect_encoding(file_bytes):
 
1
  import chardet
2
  import spacy
3
+ from spacy.cli import download
4
 
5
  # ------------------------
6
  # CONFIGURATION
 
16
  }
17
 
18
  # Load SpaCy and add GLiNER to the pipeline
19
+ try:
20
+ nlp = spacy.load("en_core_web_lg")
21
+ except OSError:
22
+ download("en_core_web_lg")
23
+ nlp = spacy.load("en_core_web_lg")
24
  nlp.add_pipe("gliner_spacy", config=custom_spacy_config)
25
 
26
  def detect_encoding(file_bytes):