Skip to main content

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 text
  • direct_speech_wordcount - word count of all the extracted quotes
  • ratio - 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}

Metadata

Release files for direct-speech-extractor-ru 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for direct-speech-extractor-ru 0.0.2
File Size Uploaded Provenance Actions
direct_speech_extractor_ru-0.0.2.tar.gz 8.1 kB Without provenance Details for direct_speech_extractor_ru-0.0.2.tar.gz

Release files / direct_speech_extractor_ru-0.0.2.tar.gz

Download URL direct_speech_extractor_ru-0.0.2.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
076e261ea6f743eb86eeb5444598f6da28adead1a07b51c9a955146641d8f147
BLAKE2b-256 checksum
How to use checksums
da983f0bdc1b210aa8375661ba424373f689681a887a4a2ea88e902a0e0ed3a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.11

Security for direct-speech-extractor-ru 0.0.2

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.

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page