medansoftware/naive-bayes-text-classification

Installs: 23

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/medansoftware/naive-bayes-text-classification

1.0.0 2022-05-08 20:06 UTC

This package is auto-updated.

Last update: 2025-09-24 00:26:28 UTC


README

Installation

Through Composer

composer require medansoftware/naive-bayes-text-classification

Standalone File

You can download standalone file here

Usage

require ('vendor/autoload.php');

$data = array(
	array(
		'text' => 'Hello, Good morning',
		'class' => 'greeting'
	),
	array(
		'text' => 'Hello, Good afternoon',
		'class' => 'greeting'
	),
	array(
		'text' => 'Hello, Good night',
		'class' => 'greeting'
	),
	array(
		'text' => 'How are you?',
		'class' => 'about-me'
	),
	array(
		'text' => 'How old are you?',
		'class' => 'about-me'
	),
	array(
		'text' => 'Where are you',
		'class' => 'about-me'
	),
	array(
		'text' => 'What\'s the time now?',
		'class' => 'information-time'
	),
	array(
		'text' => 'What\'s day today?',
		'class' => 'information-time'
	),
	array(
		'text' => 'What\'s day today?',
		'class' => 'information-time'
	)
);

$naive_bayes = new Algorithm\Naive_Bayes\Text_Classification;

$naive_bayes->training($data);

echo $naive_bayes->predict('Hello sir What\'s time now'); // information-time