Direct speech extractor for texts in Russian
Project description
Direct Speech Extractor
Python package for extracting direct speech from texts in Russian
Returned attributes for the list of extracted quotes:
text_wordcount
- word count of the whole textdirect_speech_wordcount
- word count of all the extracted quotesratio
- ratio of the extracted quotes to the whole text (direct_speech_wordcount to text_wordcount)
Installation
Install the package using pip:
pip install direct-speech-extractor-ru
Usage
>>> from direct-speech-extractor-ru import Extractor
>>> text = """Он добр и чувствителен, но вспыльчив. Когда на почте кто-нибудь из посетителей протестует, не соглашается или просто начинает рассуждать, то Михаил Аверьяныч багровеет, трясется всем телом и кричит громовым голосом: «Замолчать!», так что за почтовым отделением давно уже установилась репутация учреждения, в котором страшно бывать. Михаил Аверьяныч уважает и любит Андрея Ефимыча за образованность и благородство души, к прочим же обывателям относится свысока, как к своим подчиненным.
– А вот и я! – говорит он, входя к Андрею Ефимычу. – Здравствуйте, мой дорогой! Небось я уже надоел вам, а?
– Напротив, очень рад, – отвечает ему доктор. – Я всегда рад вам."""
In order to extract all the quotes, use the direct_spech() method:
>>> extract_direct = Extractor(text)
>>> extracted = extract_direct.direct_speech()
>>> extracted
[' «Замолчать!»',
'– А вот и я!',
'– Здравствуйте, мой дорогой! Небось я уже надоел вам, а?',
'– Напротив, очень рад,',
'– Я всегда рад вам.']
In order to extract information about the word counts and the ratio, use the method statistics():
>>> extract_direct.statistics(extracted)
{'text_wordcount': 97,
'direct_speech_wordcount': 21,
'ratio': 0.21649484536082475}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file direct_speech_extractor_ru-0.0.2.tar.gz
.
File metadata
- Download URL: direct_speech_extractor_ru-0.0.2.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 076e261ea6f743eb86eeb5444598f6da28adead1a07b51c9a955146641d8f147 |
|
MD5 | 882eda5f35f0ebb4c9070efa6025297b |
|
BLAKE2b-256 | da983f0bdc1b210aa8375661ba424373f689681a887a4a2ea88e902a0e0ed3a6 |