0
さて、今ではnltkでカスタムタグを設定するコードがあります。私はNLTKのPOSタガーをバックグラウンドとして使用して、カスタムタグで自分のタグ付き文章を練習するトリグラムタグャーを使用します。これはまともに動作しますが、私はspacyのPOSタガーで同じことをしたいと思っています。これを行う方法はありますか?ここでスペイシーで抽出されたすべてのトークンのリストが含まれていspacyを使用したカスタムPOSタグ付け
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)