### Quantization Data Transformation Source: https://natasha.github.io/navec Example showing the conversion of 32-bit float values into 8-bit integer codes. ```text Было: -0.220 -0.071 0.320 -0.279 0.376 0.409 0.340 -0.329 0.400 0.046 0.870 -0.163 0.075 0.198 -0.357 -0.279 0.267 0.239 0.111 0.057 0.746 -0.240 -0.254 0.504 0.202 0.212 0.570 0.529 0.088 0.444 **-0.005** **-0.003** -0.350 -0.001 0.472 0.635 -0.170 0.677 0.212 0.202 **-0.030** 0.279 0.229 -0.475 **-0.031** Стало: 63 105 215 49 225 230 219 39 228 143 255 78 152 187 34 49 204 198 163 146 253 58 55 240 188 191 246 243 155 234 **127** **127** 35 128 237 249 76 251 191 188 **118** 207 195 18 **118** ``` -------------------------------- ### Example of NER Tagging for PER, LOC, and ORG Source: https://natasha.github.io/nerus This example shows the application of Named Entity Recognition (NER) tags for Person (PER), Location (LOC), and Organization (ORG) in Russian text, highlighting specific entities within a news report. ```text Вице-премьер по социальным вопросам Татьяна Голикова рассказала, в каких регионах России зафиксирована наиболее PER───────────── LOC─── высокая смертность от рака, сообщает РИА Новости. По словам Голиковой, чаще всего онкологические заболевания ORG──────── PER────── ``` -------------------------------- ### Run Tomita-algfio NER Docker Container Source: https://natasha.github.io/naeval This command starts the Tomita-algfio NER model within a Docker container, exposing it on port 8080. Use this to run the model and send text for analysis. ```bash $ docker run -p 8080:8080 natasha/tomita-algfio 2020-07-02 11:09:19 BIN: 'tomita-linux64', CONFIG: 'algfio' 2020-07-02 11:09:19 Listening http://0.0.0.0:8080 ``` -------------------------------- ### Example of NER and LOC Tagging in Russian Text Source: https://natasha.github.io/nerus This example demonstrates how Named Entity Recognition (NER) and Location (LOC) tags are applied to Russian text, showing the identification of organizations and geographical entities. ```text Выборы Верховного совета Аджарской автономной республики назначены в соответствии с 241-ой статьей ORG────────────── LOC──────────────────────────── и 4-м пунктом 10-й статьи Конституционного закона Грузии <О статусе Аджарской автономной республики>. LOC─── LOC─────────────────~~~~~~~~~~~ Следственное управление при прокуратуре требует наказать премьера Якутии. ORG────────────────────~~~~~~~~~~~~~~~~ LOC─── Начальник полигона <Игумново> в Нижегородской области осужден за загрязнение атмосферы и грунтовых вод. ORG~~~~~ LOC────────────────── ``` -------------------------------- ### View CoNLL-U annotation format Source: https://natasha.github.io/nerus Example of the CoNLL-U structure used in the Nerus dataset for morphological, syntactic, and named entity tagging. ```text # newdoc id = 0 # sent_id = 0_0 # text = Вице-премьер по социальным вопросам Татьяна Голикова рассказала, в каких регионах России зафиксирована ... 1 Вице-премьер _ NOUN _ Animacy=Anim|Case=Nom|Gend... 7 nsubj _ Tag=O 2 по _ ADP _ _ 4 case _ Tag=O 3 социальным _ ADJ _ Case=Dat|Degree=Pos|Number... 4 amod _ Tag=O 4 вопросам _ NOUN _ Animacy=Inan|Case=Dat|Gend... 1 nmod _ Tag=O 5 Татьяна _ PROPN _ Animacy=Anim|Case=Nom|Gend... 1 appos _ Tag=B-PER 6 Голикова _ PROPN _ Animacy=Anim|Case=Nom|Gend... 5 flat:name _ Tag=I-PER 7 рассказала _ VERB _ Aspect=Perf|Gender=Fem|Moo... 0 root _ Tag=O 8 , _ PUNCT _ _ 13 punct _ Tag=O 9 в _ ADP _ _ 11 case _ Tag=O 10 каких _ DET _ Case=Loc|Number=Plur 11 det _ Tag=O 11 регионах _ NOUN _ Animacy=Inan|Case=Loc|Gend... 13 obl _ Tag=O 12 России _ PROPN _ Animacy=Inan|Case=Gen|Gend... 11 nmod _ Tag=B-LOC 13 зафиксирована _ VERB _ Aspect=Perf|Gender=Fem|Num... 7 ccomp _ Tag=O 14 наиболее _ ADV _ Degree=Pos 15 advmod _ Tag=O 15 высокая _ ADJ _ Case=Nom|Degree=Pos|Gender... 16 amod _ Tag=O 16 смертность _ NOUN _ Animacy=Inan|Case=Nom|Gend... 13 nsubj _ Tag=O 17 от _ ADP _ _ 18 case _ Tag=O 18 рака _ NOUN _ Animacy=Inan|Case=Gen|Gend... 16 nmod _ Tag=O 19 , _ PUNCT _ _ 20 punct _ Tag=O 20 сообщает _ VERB _ Aspect=Imp|Mood=Ind|Number... 0 root _ Tag=O 21 РИА _ PROPN _ Animacy=Inan|Case=Nom|Gend... 20 nsubj _ Tag=B-ORG 22 Новости _ PROPN _ Animacy=Inan|Case=Nom|Gend... 21 appos _ Tag=I-ORG 23 . _ PUNCT _ _ 20 punct _ Tag=O # sent_id = 0_1 ``` -------------------------------- ### Load Nerus Data and Get First Document Source: https://natasha.github.io/nerus Use the `load_nerus` function to load data from a .conllu.gz file. This function returns a generator, so `next()` is used to retrieve the first document. ```python from nerus import load_nerus docs = load_nerus('nerus_lenta.conllu.gz') doc = next(docs) ``` -------------------------------- ### Print Syntactic Annotations for a Sentence Source: https://natasha.github.io/nerus Access the `sents` attribute of a NerusDoc object to get sentences, then access the `syntax` attribute of a sentence and call `print()` to visualize syntactic dependency relations. ```python sent.syntax.print() ``` -------------------------------- ### NER Span Transformation Example Source: https://natasha.github.io/naeval Illustrates the transformation of nested and overlapping NER spans from a 'Было' (Before) format to a simplified 'Стало' (After) format, standardizing entity types. ```text Было Теперь, как утверждают в Х5 Retail Group, куда входят org_name─────── Org──────────── сети магазинов "Пятерочка", "Перекресток" и "Карусель", org_descr───── org_name─ org_name─── org_name Org────────────────────── org_descr───── Org───────────────────────────────────── org_descr───── Org────────────────────────────────────────────────── о повышении цен сообщили два поставщика рыбы и морепродуктов и компания, поставляющая овощи и фрукты. Стало Теперь, как утверждают в Х5 Retail Group, куда входят ORG──────────── сети магазинов "Пятерочка", "Перекресток" и "Карусель", ORG────── ORG──────── ORG───── о повышении цен сообщили два поставщика рыбы и морепродуктов и компания, поставляющая овощи и фрукты. ``` -------------------------------- ### Print Morphological Annotations for a Sentence Source: https://natasha.github.io/nerus Access the `sents` attribute of a NerusDoc object to get sentences, then access the `morph` attribute of a sentence and call `print()` to visualize morphological tags. ```python sent = doc.sents[0] sent.morph.print() ``` -------------------------------- ### Tokenize and Sentenize Russian Text Source: https://natasha.github.io/razdel Use tokenize to split text into tokens and sentenize to split text into sentences. Both functions return objects containing the start and stop indices along with the extracted text. ```python >>> from razdel import tokenize, sentenize >>> text = 'Кружка-термос на 0.5л (50/64 см³, 516;...)' >>> tokens = list(tokenize(text)) >>> tokens [Substring(start=0, stop=13, text='Кружка-термос'), Substring(start=14, stop=16, text='на'), Substring(start=17, stop=20, text='0.5'), Substring(start=20, stop=21, text='л'), Substring(start=22, stop=23, text='(') ...] >>> text = ''' ... - "Так в чем же дело?" - "Не ра-ду-ют". ... И т. д. и т. п. В общем, вся газета ... ''' >>> list(sentenize(text)) [Substring(start=1, stop=23, text='- "Так в чем же дело?"'), Substring(start=24, stop=40, text='- "Не ра-ду-ют".'), Substring(start=41, stop=56, text='И т. д. и т. п.'), Substring(start=57, stop=76, text='В общем, вся газета')] ``` -------------------------------- ### Initialize Pullenti Python Client Source: https://natasha.github.io/naeval This Python code initializes a client to connect to the PullentiServer. Ensure the server is running and accessible on the specified host and port. ```python >>> from pullenti_client import Client >>> client = Client('localhost', 8080) ``` -------------------------------- ### Run Pullenti-Server Docker Container Source: https://natasha.github.io/naeval This command launches the Pullenti-Server, a C# web server for the Pullenti NER system, in a Docker container. It listens on port 8080 and loads specified analyzers. ```bash $ docker run -p 8080:8080 pullenti/pullenti-server 2020-07-02 11:42:02 [INFO] Init Pullenti v3.21 ... 2020-07-02 11:42:02 [INFO] Load lang: ru, en 2020-07-02 11:42:03 [INFO] Load analyzer: geo, org, person 2020-07-02 11:42:05 [INFO] Listen prefix: http://*:8080/ ``` -------------------------------- ### Load Lenta.ru dataset Source: https://natasha.github.io/corus Demonstrates loading the Lenta.ru news dataset using the load_lenta function. ```python >>> from corus import load_lenta # Находим в реестре Corus ссылку на Lenta.ru, загружаем: # wget https://github.com/yutkin/Lenta.Ru-News-Dataset/... >>> path = 'lenta-ru-news.csv.gz' >>> records = load_lenta(path) # 2ГБ, 750K articles >>> next(records) LentaRecord( url='https://lenta.ru/news/2018/12/14/cancer/', title='Названы регионы России с\xa0самой высокой ... text='Вице-премьер по социальным вопросам Татьяна ... topic='Россия', tags='Общество' ) ``` -------------------------------- ### Load Taiga dataset Source: https://natasha.github.io/corus Demonstrates loading the Taiga dataset using specific loader functions for metadata and content. ```python >>> from corus import load_taiga_proza_metas, load_taiga_proza >>> path = 'taiga/proza_ru.zip' >>> metas = load_taiga_proza_metas(path) >>> records = load_taiga_proza(path, metas) >>> next(records) TaigaRecord( id='20151231005', meta=Meta( id='20151231005', timestamp=datetime.datetime(2015, 12, 31, 23, 40), genre='Малые формы', topic='миниатюры', author=Author( name='Кальб', readers=7973, texts=92681, url='http://www.proza.ru/avtor/sadshoot' ), title='С Новым Годом!', url='http://www.proza.ru/2015/12/31/1875' ), text='...Искры улыбок...\n... затмят фейерверки..\n...' ) ``` -------------------------------- ### Integrate Navec with PyTorch Source: https://natasha.github.io/navec Loading a Navec model and using NavecEmbedding to retrieve embeddings for specific tokens. ```python >>> import torch >>> from navec import Navec >>> from slovnet.model.emb import NavecEmbedding >>> path = 'hudlit_12B_500K_300d_100q.tar' # 51MB >>> navec = Navec.load(path) # ~1 sec, ~100MB RAM >>> words = ['навек', '', ''] >>> ids = [navec.vocab[_] for _ in words] >>> emb = NavecEmbedding(navec) >>> input = torch.tensor(ids) >>> emb(input) # 3 x 300 tensor([[ 4.2000e-01, 3.6666e-01, 1.7728e-01, [ 1.6954e-01, -4.6063e-01, 5.4519e-01, [ 0.0000e+00, 0.0000e+00, 0.0000e+00, ... ``` -------------------------------- ### Syntactic Parsing Visualization Source: https://natasha.github.io/ Visual representation of the syntactic dependency tree for a sample Russian sentence. ```text ┌────────► Бурятия amod │ ┌► и cc │ └─ Забайкальский ┌──►│ край conj ┌─│ ┌─│ ┌─────── переданы │ │ │ │ │ ┌────► из case │ │ │ │ │ │ ┌──► Сибирского amod │ │ │ │ │ │ │ ┌► федерального amod │ │ │ └─└►└─└─└─ округа obl │ │ │ │ ┌► ( punct │ │ │ └►┌─└─ СФО parataxis │ │ │ └──► ) punct │ │ │ ┌► в case │ │ └──────►┌─└─ состав obl │ └───────┌─└──► Дальневосточного nmod │ │ ┌► ( punct │ └►┌─└─ ДФО parataxis │ └──► ) punct └──────────────► . punct ``` -------------------------------- ### Load Slovnet Models and Embeddings Source: https://natasha.github.io/ner Load Navec embeddings and various Slovnet models (Morph, Syntax, NER). Ensure embeddings are linked to models for efficient memory usage. ```python >>> navec = Navec.load('navec_news_v1_1B.tar') # 25MB >>> morph = Morph.load('slovnet_morph_news_v1.tar') # 2MB >>> syntax = Syntax.load('slovnet_syntax_news_v1.tar') # 3MB >>> ner = NER.load('slovnet_ner_news_v1.tar') # 2MB # 25 + 2 + 3 + 2 вместо 25+2 + 25+3 + 25+2 >>> morph.navec(navec) >>> syntax.navec(navec) >>> ner.navec(navec) ``` -------------------------------- ### Morphological Analysis Output Source: https://natasha.github.io/ Detailed morphological tagging for the tokens in a sample Russian sentence. ```text Бурятия PROPN|Animacy=Inan|Case=Nom|Gender=Fem|Number=Sing и CCONJ Забайкальский ADJ|Case=Nom|Degree=Pos|Gender=Masc|Number=Sing край NOUN|Animacy=Inan|Case=Nom|Gender=Masc|Number=Sing переданы VERB|Aspect=Perf|Number=Plur|Tense=Past|Variant=Short|VerbForm=Part|Voice=Pass из ADP Сибирского ADJ|Case=Gen|Degree=Pos|Gender=Masc|Number=Sing федерального ADJ|Case=Gen|Degree=Pos|Gender=Masc|Number=Sing округа NOUN|Animacy=Inan|Case=Gen|Gender=Masc|Number=Sing ( PUNCT СФО PROPN|Animacy=Inan|Case=Nom|Gender=Masc|Number=Sing ) PUNCT в ADP состав NOUN|Animacy=Inan|Case=Acc|Gender=Masc|Number=Sing Дальневосточного ADJ|Case=Gen|Degree=Pos|Gender=Masc|Number=Sing ( PUNCT ДФО PROPN|Animacy=Inan|Case=Gen|Gender=Masc|Number=Sing ) PUNCT . PUNCT ``` -------------------------------- ### Analyze Text with Pullenti Python Client Source: https://natasha.github.io/naeval This Python code sends text to the PullentiServer for analysis and retrieves the results. The 'result.graph' attribute contains the structured entity information. ```python >>> text = 'Глава государства Дмитрий Медведев и ' \ ... 'Председатель Правительства РФ Владимир Путин ' \ ... 'выразили глубочайшие соболезнования семье актрисы' >>> result = client(text) >>> result.graph ``` -------------------------------- ### Send Text to Tomita-algfio NER API Source: https://natasha.github.io/naeval This cURL command sends a POST request with text data to the running Tomita-algfio NER service. The service will return structured data identifying entities. ```bash $ curl -X POST http://localhost:8080 --data \ 'Глава государства Дмитрий Медведев и Председатель \ Правительства РФ Владимир Путин выразили глубочайшие \ соболезнования семье актрисы' ``` -------------------------------- ### Print NER Annotations for a Document Source: https://natasha.github.io/nerus Access the `ner` attribute of a NerusDoc object and call the `print()` method to visualize Named Entity Recognition tags. ```python doc.ner.print() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.