次の列を持つ pandas データフレームがあります。
列 1
['if', 'you', 'think', 'she', "'s", 'cute', 'now', ',', 'you', 'should', 'have', 'see', 'her', 'a', 'couple', 'of', 'year', 'ago', '.']
['uh', ',', 'yeah', '.', 'just', 'a', 'fax', '.']
列 2
if you think she 's cute now , you should have see her a couple of year ago .
uh , yeah . just a fax .
等
私の目標は、データフレームのバイグラム、トライグラム、クアドリグラム (具体的には、既に見出し語化されている列 2) をカウントすることです。
私は次のことを試しました:
import nltk
from nltk import bigrams
from nltk import trigrams
trig = trigrams(df ["Column2"])
print (trig)
ただし、次のエラーがあります
<generator object trigrams at 0x0000013C757F1C48>
私の最終的な目標は、トップXのバイグラム、トリグラムなどを印刷できるようにすることです.