Skip to main content

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

This is Spacy Universe Project

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_md")
text = "he gives me something"
doc = nlp(text)


dep_list = tags.create_dep_list(doc)
elements = tags.create_elements(dep_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"

how to get prep phrase

nlp = spacy.load("en_core_web_md")

text = "The Eureka client handles all aspects of service instance registration and deregistration"
doc =  nlp(text)
dep_list = tags.create_dep_list(doc)
custom = ElementsFactory.make_custom_elements(dep_list, doc=doc, option="prep")
phrase = custom.option

print(phrase.prep_groups)
# [of service instance registration and deregistration]

License

Distributed under the terms of the MIT license, "sent-pattern" is free and open source software

Project details


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.9.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sent_pattern-0.0.9-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file sent-pattern-0.0.9.tar.gz.

File metadata

  • Download URL: sent-pattern-0.0.9.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for sent-pattern-0.0.9.tar.gz
Algorithm Hash digest
SHA256 b609ff39eff9ec6975071b51f15590ca2f35613f995703d467033f2d3b36a632
MD5 12fe1e92225908d9bd1814f399c562ea
BLAKE2b-256 685e68c67c24cca6971819f4fb28a67e743c2a5a26d4f0e4e8fa30e4e926d95d

See more details on using hashes here.

File details

Details for the file sent_pattern-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: sent_pattern-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for sent_pattern-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 b2b9327f10be82b4c740a3fc36d27c6a3b74278526a09ec000424c45dbd569e0
MD5 15ba0484a18c764afd6d37527d380ec8
BLAKE2b-256 00e9b5da933e78a2363a93f0868e6e7ebd3210ad3e640c254fa2af519d381704

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page