1 回答

TA貢獻(xiàn)1817條經(jīng)驗(yàn) 獲得超14個(gè)贊
這是一個(gè)使用 spacy 的簡(jiǎn)單示例:
import spacy
import pandas as pd
# load english language model
nlp = spacy.load('en_core_web_sm',disable=['ner','textcat'])
text = "I ate an apple pie, yesterday."
# create spacy
doc = nlp(text)
pos = ""
for token in doc:
pos += token.pos_ + " "
# create dataframe
df = pd.DataFrame([[text, pos]], columns=['Sentence', 'Structure'])
print(df)
輸出是:
Sentence Structure
0 I ate an apple pie, yesterday. PRON VERB DET NOUN NOUN PUNCT NOUN PUNCT
添加回答
舉報(bào)