I working on a dataset, I did the pos_tagging using nltk. Now I want to know which sequence of grammar is most common in my rows, then I want to define a chunk grammar based on a common grammar sequence. Can you please tell me how to do it in python? Thank you
-
$\begingroup$ You would need to extract n-grams of POS tags for various lengths N and count their frequency. $\endgroup$– ErwanJan 24, 2022 at 21:23
-
$\begingroup$ I need to know the grammar sequence followed by most of the sentences. e.g, Noun>Verb> DT>Noun>Pronoun etc....... $\endgroup$– aadil ganiJan 25, 2022 at 17:23
-
$\begingroup$ Yes, as I said the first step is to compute all the POS n-grams frequencies. You have several options to do this, personally I would simply code it myself (it's not very complex) but otherwise you can prepare the list of POS tags as if they are words and feed this to CountVectorizer. $\endgroup$– ErwanJan 25, 2022 at 18:18