roberthsu2003 commited on
Commit
58ff653
·
verified ·
1 Parent(s): 14b9e33

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +12 -9
README.md CHANGED
@@ -42,17 +42,20 @@ It achieves the following results on the evaluation set:
42
  ```python
43
  from transformers import pipeline
44
 
45
- ner_pipe = pipeline("token-classification", model='roberthsu2003/models_for_ner',aggregation_strategy="simple")
46
- inputs = "徐國堂在台北上班"
47
  res = ner_pipe(inputs)
48
-
49
- ner_result = {}
50
  for r in res:
51
- if r["entity_group"] not in ner_datasets:
52
- ner_result[r['entity_group']] = []
53
- ner_result[r['entity_group']].append(inputs[r['start']:r['end']])
54
- ner_result
55
-
 
 
 
56
  #==output==
57
  {'PER': ['徐國堂'], 'LOC': ['台北']}
58
  ```
 
42
  ```python
43
  from transformers import pipeline
44
 
45
+ ner_pipe = pipeline('token-classification', model='roberthsu2003/models_for_ner',aggregation_strategy='simple')
46
+ inputs = '徐國堂在台北上班'
47
  res = ner_pipe(inputs)
48
+ print(res)
49
+ res_result = {}
50
  for r in res:
51
+ entity_name = r['entity_group']
52
+ start = r['start']
53
+ end = r['end']
54
+ if entity_name not in res_result:
55
+ res_result[entity_name] = []
56
+ res_result[entity_name].append(inputs[start:end])
57
+
58
+ res_result
59
  #==output==
60
  {'PER': ['徐國堂'], 'LOC': ['台北']}
61
  ```