project that interpret English sentences to improve your ability to read English sentences correctly.
Project description
Sent Pattern
This package categorizes English sentences into one of five basic sentence patterns and identifies the subject, verb, object, and other components. The five basic sentence patterns are based on C. T. Onions's Advanced English Syntax and are frequently used when teaching English in Japan.
Influence of His Grammar on English Language Education in Japan
Quick Start
Installation
pip install sent-pattern
Usage
import spacy
nlp = spacy.load("en_core_web_lg")
nlp.add_pipe("span_noun")
nlp.add_pipe("sent_pattern")
text = "he gives me something"
doc = nlp(text)
pattern = doc._.sentpattern
print(pattern)
# FourthSentencePattern (class)
print(pattern.subject.root)
# he (Token)
print(pattern.verb.root)
# give (Token)
If you want to know the sentence pattern without using components, we recommend using method directly
import spacy
from sent_pattern import tags
nlp = spacy.load("en_core_web_lg")
text = "he gives me something"
doc = nlp(text)
dep_list = tags.create_dep_list(doc)
lemma_list = tags.create_lemma_list(doc)
elements = tags.create_elements(dep_list, lemma_list)
pattern = tags.create_sent_pattern(elements)
print(pattern.subject.root.text)
# he (string)
print(dep_list)
# {'ROOT': [gives], 'dative': [me], 'dobj': [something], 'nsubj': [he]}
print(pattern.abbreviation)
# "SVOO"
License
Distributed under the terms of the MIT license, "sent-pattern" is free and open source software
Universe Project
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
sent-pattern-0.0.2.tar.gz
(9.5 kB
view hashes)
Built Distribution
Close
Hashes for sent_pattern-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 018d7c821d39da326a9067b1f4918aa2656073bd21fed6ad41e660e6d6cf58cd |
|
MD5 | 010ebcb40830fe38c95d2f39a3dafe99 |
|
BLAKE2b-256 | b89d8ceff0dff39982a3084c3489bc99b497c45ec680c9d05c3612d1763ef584 |