ZPM07 commited on
Commit
974c371
·
verified ·
1 Parent(s): 1ee6898

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +26 -4
README.md CHANGED
@@ -29,12 +29,34 @@ license: mit
29
  ```python
30
  from transformers import pipeline
31
 
32
- ner = pipeline("ner", model="ZPM07/sculptor_NER")
 
 
 
 
 
 
33
  text = "3 подхода по 10 приседаний с весом 50 кг"
34
- results = ner(text)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
- for entity in results:
37
- print(f"{entity['word']} -> {entity['entity']} (confidence: {entity['score']:.2f})")
 
 
38
  ```
39
 
40
  ## Пример вывода
 
29
  ```python
30
  from transformers import pipeline
31
 
32
+ ner_pipeline = pipeline(
33
+ "ner",
34
+ model="ZPM07/sculptor_NER",
35
+ aggregation_strategy="first",
36
+ device=0
37
+ )
38
+
39
  text = "3 подхода по 10 приседаний с весом 50 кг"
40
+ entities = ner_pipeline(text)
41
+
42
+ def clean_results(entities):
43
+ cleaned = []
44
+ for entity in entities:
45
+ word = entity['word'].replace('Ġ', ' ').strip()
46
+ if word:
47
+ cleaned.append({
48
+ 'word': word,
49
+ 'entity': entity['entity_group'],
50
+ 'score': round(entity['score'], 4),
51
+ 'start': entity['start'],
52
+ 'end': entity['end']
53
+ })
54
+ return cleaned
55
 
56
+ cleaned_entities = clean_results(entities)
57
+ print("Найденные сущности:")
58
+ for entity in cleaned_entities:
59
+ print(f"- {entity['word']} -> {entity['entity']} (доверие: {entity['score']:.2f}, позиция: {entity['start']}-{entity['end']})")
60
  ```
61
 
62
  ## Пример вывода