Moscow Toponym Extractor
This module contains an extractor of Moscow toponyms from Russian texts using such Python libraries as SpaCy, Natasha, and PyMorphy2.
Returned attributes for extracted Moscow toponym:
toponym- toponym in an inflected form (e.g., Кремле)lemmatized_toponym- toponym in the base form (e.g., Кремль)start_char- start character index (e.g., 79)stop_char- end character index (e.g., 85)
Installation
- Install the package using pip:
pip install moscow-toponyms
- Download ru_core_news_sm
pip install https://github.com/explosion/spacy-models/releases/download/ru_core_news_sm-3.1.0/ru_core_news_sm-3.1.0.tar.gz
Quick start
>>> from moscow_toponyms import QuickExtract
>>> text = "Однажды весною, в час небывало жаркого заката, в Москве, на Патриарших прудах, появились два гражданина."
>>> toponyms = QuickExtract(text)
>>> toponyms.extract()
[{'toponym': 'Патриарших прудах',
'lemmatized_toponym': 'Патриаршие пруды',
'start_char': 60,
'stop_char': 77}]
Usage
>>> from moscow_toponyms import ExtractMosToponyms
>>> text = "Однажды весною, в час небывало жаркого заката, в Москве, на Патриарших прудах, появились два гражданина."
>>> extract_toponyms = ExtractMosToponyms(text)
Using SpaCy extract toponyms and their position in a text, lemmatize extracted toponyms using PyMorphy2:
>>> spacy_extracted = extract_toponyms.spacy_extract()
>>> print(spacy_extracted)
({51: 'смоленский площадь'}, {0: 'саша панкратов'})
>>> spacy_dict = spacy_extracted[0]
>>> spacy_names = spacy_extracted[1]
Using Natasha extract toponyms and their position in a text:
>>> natasha_extractor = extract_toponyms.natasha_extract()
>>> print(natasha_extractor)
({51: ['Смоленской площади', 'Смоленская площадь', 69]}, {0: 'Саша Панкратов'})
>>> natasha_dict = natasha_extractor[0]
>>> natasha_names = natasha_extractor[1]
Add the extracted names to the existing black list for cleaner output:
>>> black_list = extract_toponyms.merging_blacklists(spacy_names, natasha_names)
Filter all extracted toponyms and return only Moscow toponyms in inflected and base forms, their start and end character indices
>>> final_results = extract_toponyms.inner_merging_filtering(black_list, spacy_dict, natasha_dict)
>>> print(final_results)
[{'toponym': 'Смоленской площади', 'lemmatized_toponym': 'Смоленская площадь', 'start_char': 51, 'stop_char': 69}]
Metadata
Release files for moscow-toponyms 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| moscow_toponyms-0.1.0.tar.gz | 269.8 kB | Without provenance | Details for moscow_toponyms-0.1.0.tar.gz |
Release files / moscow_toponyms-0.1.0.tar.gz
| Download URL | moscow_toponyms-0.1.0.tar.gz |
|---|---|
| Size | 269.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d016b2614329afa90b8ed0ddf9d417fd3546ec7c83a848c29a02d7c40082266f
|
|
BLAKE2b-256 checksum How to use checksums |
f23019170152f0f07b6fdf7a8c96e85b1c5e9654a142ad54ea0b8edb4cc51b67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.8
|
Security for moscow-toponyms 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.