0
インテントは、私が以下のリンクの助けを借りて達成することができるPOSタグを基にしています。スペイシーを使用して同様の結果を達成しようとしTruecasing - SpaCy
How can I best determine the correct capitalization for a word?
?
def truecase(doc):
truecased_sents = [] # list of truecased sentences
tagged_sent = token.tag_([word.lower() for token in doc])
normalized_sent = [w.capitalize() if t in ["NN","NNS"] else w for (w,t) in tagged_sent]
normalized_sent[0] = normalized_sent[0].capitalize()
string = re.sub(" (?=[\.,'!?:;])", "", ' '.join(normalized_sent))
return string
それはトークンとしてグローバルに宣言し、この問題を解決する方法
tagged_sent = token.tag_([word.lower() for token in doc])
NameError: global name 'token' is not defined
このエラーをスローします。私のアプローチは正しいのですか?