-
-
Save ageitgey/99debc6682295d1580fff1b803648dd4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import spacy | |
import textacy.extract | |
# Load the large English NLP model | |
nlp = spacy.load('en_core_web_lg') | |
# The text we want to examine | |
text = """London is the capital and most populous city of England and the United Kingdom. | |
Standing on the River Thames in the south east of the island of Great Britain, | |
London has been a major settlement for two millennia. It was founded by the Romans, | |
who named it Londinium. | |
""" | |
# Parse the document with spaCy | |
doc = nlp(text) | |
# Extract semi-structured statements | |
statements = textacy.extract.semistructured_statements(doc, "London") | |
# Print the results | |
print("Here are the things I know about London:") | |
for statement in statements: | |
subject, verb, fact = statement | |
print(f" - {fact}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The textacy.extract API has changed. The function
semistructured_statements
no longer takes in only two positional arguments.