-2

Let's say I have multiple sentences(Not a paragraph) like Sentence A,B,C and so on in a csv file. And I want to calculate the matrix of words in each sentence using N-gram(Unigrams or Bigrams). So that I can get a calculated N-gram vector for each sentence from my Matrix easily. How do I do it?

PS:I have tried several methods but all of them calculate N-gram for either a sentence or a whole paragraph!

Hamid
  • 15
  • 1
  • 6
  • 1
    Possible duplicate of [What are ngram counts and how to implement using nltk?](https://stackoverflow.com/questions/12821201/what-are-ngram-counts-and-how-to-implement-using-nltk) – Yuval Raz Sep 05 '17 at 10:11
  • @YuvalRaz The question that has been answered in the link is different from mine :) – Hamid Sep 05 '17 at 10:20

1 Answers1

-1

you can try using a pandas data frame and use "apply" on every row

import pandas as pd

x = pd.read_csv("the_santances.csv")

x.apply("the function that calculates the ngram")
Yuval Raz
  • 96
  • 7