1
$\begingroup$

I have a DataFrame with 4 columns: 'Headline', 'Body_ID', 'Stance', 'articleBody', with 'Headline' and 'articleBody containing cleaned and tokenized words. I want to find bi-grams using nltk and have this so far:

bigram_measures = nltk.collocations.BigramAssocMeasures()
articleBody_biGram_finder = df_2['articleBody'].apply(lambda x: BigramCollocationFinder.from_words(x))

I'm having trouble with the last step of applying the articleBody_biGram_finder with bigram_measures. I've tried multiple iterations of lambda with list comprehension but am getting nowhere.

my most recent attempts:

df_2['articleBody_scored'] = score_ngrams(bigram_measures.raw_freq) for item in articleBody_biGram_finder

df_2['articleBody_scored'] = articleBody_biGram_finder.apply(lambda x: BigramCollocationFinder.score_ngrams(bigram_measures.raw_freq))

$\endgroup$
0
$\begingroup$

df_2['bigram_scored'] = df_2['bigram_finder'].apply(lambda x: x.score_ngrams(bigram_measures.raw_freq))

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.