Download the PHP package permafrost-dev/text-classifier without Composer
On this page you can find all versions of the php package permafrost-dev/text-classifier. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download permafrost-dev/text-classifier
More information about permafrost-dev/text-classifier
Files in permafrost-dev/text-classifier
Package text-classifier
Short Description Assigns input text a category based on a training model
License MIT
Informations about the package text-classifier
text-classifier
Performs basic text classification using algorithms such as Naive-Bayes.
Installation:
You may install text-classifier using composer:
composer require permafrost-dev/text-classifier
Note: The higher-quality and more complete training data used to train the model, the more accurate the classifications will be.
Example - Email Address Classification
A common use-case for classifying text is to determine whether or not an email is spam or not spam. While that's beyond the scope of this example, we can try to determine if a given email address is spam or not spam based on its features. Note: all email addresses used for training/examples were randomly generated. If your email address somehow ended up within the sample data, please contact [email protected] and it will be promptly removed.
Resulting output:
classification for '[email protected]': spam
classification for '[email protected]': valid
This method can easily be applied to other areas for spam checking, such as classifiying user-provided domain names.
Example - Sentiment Analysis
See examples/sentiment.php
for a working demo.
Resulting output:
this is fantastic - positive
this is terrible! - negative
With more robust pre-processing and tokenizing, these methods can be applied to other data, such as determining whether or not an email message is likely a spam message, whether a given article is of interest to a user based on basic preferences, and so on.
This does only go so far, however - machine learning is recommended when highly-accurate results are needed.