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

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +14 -5
main.py CHANGED
@@ -1,13 +1,22 @@
1
  import chardet
2
  import spacy
3
- from gliner_spacy import GLiNERComponent
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  # Load SpaCy and add GLiNER to the pipeline
6
  nlp = spacy.load("en_core_web_lg")
7
- nlp.add_pipe("gliner_spacy", config={
8
- "labels": ["PERSON", "ORGANIZATION", "LOCATION", "DISEASE"],
9
- "model": "urchade/gliner_multi_pii-v1"
10
- }, last=True)
11
 
12
  def detect_encoding(file_bytes):
13
  result = chardet.detect(file_bytes)
 
1
  import chardet
2
  import spacy
3
+
4
+ # ------------------------
5
+ # CONFIGURATION
6
+ # ------------------------
7
+ custom_spacy_config = {
8
+ "gliner_model": "urchade/gliner_multi_pii-v1",
9
+ "labels": [
10
+ "person", "organization", "company", "country",
11
+ "medical condition", "credit card brand",
12
+ ],
13
+ "threshold": 0.39,
14
+ "style": "ent",
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):
22
  result = chardet.detect(file_bytes)