Natural Language Processing
Table of contents
N-gram character models
A sequence of written symbols of length n is called an n-gram with special case “unigram” for 1-gram, “bigram” for 2-gram, and “trigram” for 3-gram. A model of the probability distribution of n-letter sequences is thus called an n-gram model.
Character Level Unigrams :-
Character Level Bigrams :-
Character Level Triigrams :-
Text Classification
Given a text of some kind, to decide which of a predefined set of classes it belongs to is called text classification. Language identification , genre classification ,sentiment analysis and spam detection are examples of text classification.
The classifier below is a naive Bayes model over the character trigrams of each language, trained on 24000 words of English, French and German books from aima-data. The training is done offline (trainLanguageModels.js), and the page loads only the counts of the 1000 most frequent trigrams of each language (28 KB, 11 KB compressed), instead of the 400 KB of training text. On texts not used in training it is right 82% of the time on a single word, 94% on three words and almost always on ten.