traopia commited on
Commit
06ceb44
·
1 Parent(s): 034236c
Files changed (1) hide show
  1. src/generate_queries_alternative.py +11 -1
src/generate_queries_alternative.py CHANGED
@@ -6,10 +6,20 @@ import uuid
6
  import chromadb
7
  import spacy
8
  import numpy as np
9
- nlp = spacy.load("en_core_web_sm")
10
  import os
11
  #os.environ["TOKENIZERS_PARALLELISM"] = "false"
12
 
 
 
 
 
 
 
 
 
 
 
 
13
  wikibase_properties_id = {'instance of': 'P2',
14
  'reference URL': 'P24',
15
  'start time': 'P15',
 
6
  import chromadb
7
  import spacy
8
  import numpy as np
 
9
  import os
10
  #os.environ["TOKENIZERS_PARALLELISM"] = "false"
11
 
12
+ import spacy
13
+
14
+ def get_nlp():
15
+ try:
16
+ return spacy.load("en_core_web_sm")
17
+ except OSError:
18
+ from spacy.cli import download
19
+ download("en_core_web_sm")
20
+ return spacy.load("en_core_web_sm")
21
+ nlp = get_nlp()
22
+
23
  wikibase_properties_id = {'instance of': 'P2',
24
  'reference URL': 'P24',
25
  'start time': 'P15',