Skip to content

NaturalLanguageClassifier

Michael edited this page Mar 21, 2017 · 2 revisions
namespace WatsonSDK\Services;

The Natural Language Classifier service understands the intent behind text and returns a corresponding classification, complete with a confidence score. For example “What is the weather like today? or “Is it hot out?” or “Is it going to be nice today?” are all ways of asking about “temperature”. Use NLC to answer questions in a contact center, create chatbots, categorize volumes of written content and more.

public class NaturalLanguageClassifier extends WatsonService

Used to initialize a NaturalLanguageClassifier instance from the instance of WatsonCredential.

function __construct(WatsonCredential $credential);

Perform the classify of the given variables of text and classifier ID.

public function classify($text, $classifier_id);

Sends data to create and train a classifier and returns information about the new classifier.

public function createClassifier($training_file_path, $language = self::LANGUAGE_EN, $name = NULL);

Retrieves the list of classifiers for the service instance.

public function listClassifiers();

Returns status and other information about a classifier.

public function getClassifier($classifier_id);

Deletes a classifier.

public function deleteClassifier($classifier_id);

Sample

$nlc = new NaturalLanguageClassifier(WatsonCredential::initWithCredentials('your_username', 'your_password'));

$result = $nlc->classify('your text to be classified.', 'your classifier id');
Clone this wiki locally