Update README.md
Browse files
README.md
CHANGED
|
@@ -29,12 +29,34 @@ license: mit
|
|
| 29 |
```python
|
| 30 |
from transformers import pipeline
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
text = "3 подхода по 10 приседаний с весом 50 кг"
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
| 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 |
## Пример вывода
|