posextract
posextract offers grammatical information extraction methods designed for the analysis of historical and contemporary textual corpora. It traverses the syntactic dependency relations between parts-of-speech and returns sequences of words that share a grammatical relationship. See our article for more. You can also download posextract for pypi with pip.
Usage
extract_triplesto extract subject-verb-object (SVO) and subject-verb-adjective complement (SVA) triplesextract_adj_noun_pairsto extract adjective-noun pairsextract_subj_verb_pairsto extract subject-verb pairs
Required Paramters:
inputcan be the name of a csv file or an input stringoutputname of the output file
Optional Paramters:
--data_columnspecify the column to extract triples from.--id_columnspecify a unique ID field if csv file is given.--file-delimiterspecify comma, pipe, or tab. Default is comma.--post-combine-adjcombine triples (adjective predicate with object)--add-auxiliaryextract future and past tense triples.--prep-phraseextract the . Default set to false.--no-compound-nounExtract just the subject or object (e.g. "Indian Government" is extracted as just "Government").--lemmaspecify whether to lemmatize parts-of-speech. Default is non-lemmatized.--verboseprint
Examples
Interactive:
Extract grammatical triples.
from posextract import grammatical_triples
triples = grammatical_triples.extract(['Landlords may exercise oppression.', 'The soldiers were ill.'])
for triple in triples:
print(triple)
# Output: Landlords exercise oppression, soldiers were ill
Extract grammatical triples using different options from default:
from posextract.util import TripleExtractorOptions
triples = grammatical_triples.extract(sent, TripleExtractorOptions(prep_phrase = True))
Or extract adjectives and the nouns they modify.
from posextract import adj_noun_pairs
adj_noun = adj_noun_pairs.extract()
Or extract subjects and their verbs.
from posextract import subj_verb_pairs
subj_verb = subj_verb_pairs.extract()
Over CLI:
posextract can extract grammatical triples from text:
python -m posextract.extract_triples "Landlords may exercise oppression." output.csv
# Output: Landlords exercise oppression
posextract can extract SVO/SVA relationships separately or it can combine the adjective as part of a SVO triple:
python -m posextract.extract_triples "The soldiers were terminally ill." output.csv --post-combine-adj
# Output: soldiers were terminally, soldiers were ill
python -m posextract.extract_triples "The soldiers were terminally ill." output.csv --post-combine-adj
# Output: soldiers were terminally ill
If provided a .csv file:
python -m posextract.extract_triples --data_column sentence --id_column sentence_id input.csv output.csv
For More Information...
... see our Wiki:
Metadata
Release files for posextract 1.2.3
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 |
|---|---|---|---|---|
| posextract-1.2.3.tar.gz | 15.1 kB | Without provenance | Details for posextract-1.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| posextract-1.2.3-py3-none-any.whl | Python 3 | none | any | Details for posextract-1.2.3-py3-none-any.whl |
Total release size: 34.3 kB
Release files / posextract-1.2.3.tar.gz
| Download URL | posextract-1.2.3.tar.gz |
|---|---|
| Size | 15.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
59a2e4bdef272be81d524a24003c2b6d66a1fd561b3f2f4df0b017b0676fbaf4
|
|
BLAKE2b-256 checksum How to use checksums |
bb8d94accbd509c2dca90b15d8a103cc8f0ca9c4f0f9d6cc5f5b6991bbbbfe88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / posextract-1.2.3-py3-none-any.whl
| Download URL | posextract-1.2.3-py3-none-any.whl |
|---|---|
| Size | 19.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8cf42f61c3edfe2f711b3b59ce45baaa818dd1530574e08d893ddae080057dc2
|
|
BLAKE2b-256 checksum How to use checksums |
50dcc05708e6398efc456caf4a872df084c59eac3fc66d053d6f08aac2974df8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Security for posextract 1.2.3
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.