mirror of https://github.com/explosion/spaCy.git
Improve landing example [ci skip]
This commit is contained in:
parent
a841324034
commit
dcd6e06c47
|
@ -23,32 +23,29 @@ import Link from '../components/link'
|
||||||
import BenchmarksChoi from 'usage/_benchmarks-choi.md'
|
import BenchmarksChoi from 'usage/_benchmarks-choi.md'
|
||||||
|
|
||||||
const CODE_EXAMPLE = `# pip install spacy
|
const CODE_EXAMPLE = `# pip install spacy
|
||||||
# python -m spacy download en_core_web_md
|
# python -m spacy download en_core_web_sm
|
||||||
|
|
||||||
import spacy
|
import spacy
|
||||||
|
|
||||||
# Load English tokenizer, tagger, parser, NER and word vectors
|
# Load English tokenizer, tagger, parser, NER and word vectors
|
||||||
nlp = spacy.load("en_core_web_md")
|
nlp = spacy.load("en_core_web_sm")
|
||||||
|
|
||||||
# Process whole documents
|
# Process whole documents
|
||||||
text = (u"When Sebastian Thrun started working on self-driving cars at "
|
text = ("When Sebastian Thrun started working on self-driving cars at "
|
||||||
u"Google in 2007, few people outside of the company took him "
|
"Google in 2007, few people outside of the company took him "
|
||||||
u"seriously. “I can tell you very senior CEOs of major American "
|
"seriously. “I can tell you very senior CEOs of major American "
|
||||||
u"car companies would shake my hand and turn away because I wasn’t "
|
"car companies would shake my hand and turn away because I wasn’t "
|
||||||
u"worth talking to,” said Thrun, now the co-founder and CEO of "
|
"worth talking to,” said Thrun, in an interview with Recode earlier "
|
||||||
u"online higher education startup Udacity, in an interview with "
|
"this week.")
|
||||||
u"Recode earlier this week.")
|
|
||||||
doc = nlp(text)
|
doc = nlp(text)
|
||||||
|
|
||||||
|
# Analyze syntax
|
||||||
|
print("Noun phrases:", [chunk.text for chunk in doc.noun_chunks])
|
||||||
|
print("Verbs:", [token.lemma_ for token in doc if token.pos_ == "VERB"])
|
||||||
|
|
||||||
# Find named entities, phrases and concepts
|
# Find named entities, phrases and concepts
|
||||||
for entity in doc.ents:
|
for entity in doc.ents:
|
||||||
print(entity.text, entity.label_)
|
print(entity.text, entity.label_)
|
||||||
|
|
||||||
# Determine semantic similarities
|
|
||||||
doc1 = nlp(u"my fries were super gross")
|
|
||||||
doc2 = nlp(u"such disgusting fries")
|
|
||||||
similarity = doc1.similarity(doc2)
|
|
||||||
print(doc1.text, doc2.text, similarity)
|
|
||||||
`
|
`
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue