How to use n-gram by document matrix instead of word by document matrix ?

477 views
Skip to first unread message

ChamingaD

unread,
Apr 21, 2012, 5:09:18 AM4/21/12
to gen...@googlegroups.com
I went through a research paper. They mention that accuracy of LSA can be increase by using n-gram by document matrix instead of word by document matrix.

How can i do that with Gensim ? Is it possible ?
Automated Essay Scoring Using Generalized Latent Semantic Analysis.pdf

Fil

unread,
Apr 22, 2012, 4:30:58 AM4/22/12
to gen...@googlegroups.com, chami...@gmail.com
Would you maybe rewrite your input texts into a set of (say) tri-grams.

e.g. the previous sentence you would rewrite as

"wou oul uld you mayb ayb ybe rew ewr wri rit ite …"

then feed to gensim.
--
Fil

ChamingaD

unread,
Apr 22, 2012, 6:17:00 AM4/22/12
to gen...@googlegroups.com, chami...@gmail.com
Hmm. I didn't get what you said :/

Fil

unread,
Apr 22, 2012, 12:53:18 PM4/22/12
to gen...@googlegroups.com, chami...@gmail.com
Just compute the trigrams for each of your texts and make that the
text you analyze with gensim? or maybe I didn't understand your
question.

--
Fil

IKS Public

unread,
Apr 22, 2012, 1:47:35 PM4/22/12
to gen...@googlegroups.com
I just did it the hard way by adding w(i-1) and w(i) as the string w(i-1)+w(i) - i use "*" as begin end. Then i weed out infrequent cases with the gensim command

IKS Public

unread,
Apr 22, 2012, 1:50:15 PM4/22/12
to gen...@googlegroups.com
Oops i put an otherwise illegal char in between like

W(i)+'-'+w(i+1)

This avoids single words that look like bigrams


On Apr 22, 2012, at 5:17 AM, ChamingaD <chami...@gmail.com> wrote:

Reply all
Reply to author
Forward
0 new messages