Skip to content

Classifies texts using a previously generated lexicon.

License

Notifications You must be signed in to change notification settings

javifmz/lexicon-based-classifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lexicon-based Classifier

Classifies texts using a previously generated lexicon. The lexicon contains a list of weighted terms for each of the classification labels. The weights of these terms are added to each label, and the label with the higher weight is chosen.

Lexicon format example

{
  "positive": [
    { "term": "excellent", "weight": 1.0 },
    { "term": "good", "weight": 0.7 }
  ],
  "negative": [
    { "term": "horrible", "weight": 1.0 },
    { "term": "bad", "weight": 0.8 }
  ],
}

Basic usage

classifier = LexiconBasedClassifier(lexicon)
prediction = classifier.predict(X)

Usage with different prediction indexes

labels = [ "positive", "negative" ]
classifier = LexiconBasedClassifier(lexicon, labels=labels)
prediction = classifier.predict(X)

Execute the example

python -m lbclassifier_example

About

Classifies texts using a previously generated lexicon.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages