0
좋아, 지금은 코드가 nltk와 사용자 정의 태그를 할 수 있습니다. 나는 NLTK의 POS tagger를 trigram tagger가있는 backoff로 사용하여 사용자 정의 태그로 자신의 tagged sentence를 교육합니다. 이것은 훌륭하게 작동하지만 나는 spacy의 POS tagger로 똑같이 할 수 있기를 원한다. 이것을 할 수있는 방법이 있습니까? 여기 적응에 의해 추출 된 모든 토큰의 목록을 포함맞춤 POS 태그와 spacy
import string
import nltk
from nltk.tokenize import RegexpTokenizer
from nltk.corpus import stopwords
import nltk.tag, nltk.data
tagger = nltk.TrigramTagger(train_sents, backoff=nltk.data.load(nltk.tag._POS_TAGGER))
def tagSentence(sentence):
# Method to tag sentence according to the tagger that is trained.
sentence = sentence.lower()
tokens = nltk.word_tokenize(sentence)
filtered_words = [w for w in tokens if not w in stopwords.words('english')]
" ".join(filtered_words)
return tagger.tag(filtered_words)