https://github.com/keithweaver/ibm-watson-php-sdk
PHP SDK for IBM Watson. Making easier to build Watson powered apps in PHP.
https://github.com/keithweaver/ibm-watson-php-sdk
classifier document-conversion ibm ibm-bluemix ibm-watson ibm-watson-api ibm-watson-services machine-learning natural-language natural-language-processing retrieve-and-rank
Last synced: 27 days ago
JSON representation
PHP SDK for IBM Watson. Making easier to build Watson powered apps in PHP.
- Host: GitHub
- URL: https://github.com/keithweaver/ibm-watson-php-sdk
- Owner: keithweaver
- License: apache-2.0
- Created: 2016-11-28T21:42:56.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-10T17:53:58.000Z (almost 9 years ago)
- Last Synced: 2025-08-11T06:26:52.286Z (6 months ago)
- Topics: classifier, document-conversion, ibm, ibm-bluemix, ibm-watson, ibm-watson-api, ibm-watson-services, machine-learning, natural-language, natural-language-processing, retrieve-and-rank
- Language: PHP
- Homepage:
- Size: 676 KB
- Stars: 7
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ibm-watson-php-sdk
## Installing Using Composer
```
composer require kweaver00/watson_php
```
or
```
composer require kweaver00/watson_php dev-master
```
## Supported Services
[Natural Language Classifier](https://github.com/kweaver00/unofficial-ibm-watson-php-sdk#natural-language-classifier)
[Retrieve and Rank](https://github.com/kweaver00/unofficial-ibm-watson-php-sdk#retrieve-and-rank)
[Document Conversion](https://github.com/kweaver00/unofficial-ibm-watson-php-sdk#document-conversion)
## Natural Language Classifier
### Creating A New Object
```
$naturalLangObj = new \Kweaver\Watson\NaturalLanguageClassifier();
```
### API Methods
**[Create classifier](https://www.ibm.com/watson/developercloud/natural-language-classifier/api/v1/#create_classifier)** - Sends data to create and train a classifier and returns information about the new classifier.
**[List classifiers](https://www.ibm.com/watson/developercloud/natural-language-classifier/api/v1/#get_classifiers)** - Retrieves the list of classifiers for the service instance. Returns an empty array if no classifiers are available.
**[Get information about a classifier](https://www.ibm.com/watson/developercloud/natural-language-classifier/api/v1/#get_status)** - Returns status and other information about a classifier
**[Delete classifier](https://www.ibm.com/watson/developercloud/natural-language-classifier/api/v1/#delete_classifier)** - Deletes a classifier.
**[Classify](https://www.ibm.com/watson/developercloud/natural-language-classifier/api/v1/#classify)** - Returns label information for the input. The status must be "Available" before you can classify calls. Use the Get information about a classifier method to retrieve the status.
### Example
```
require_once "/vendor/autoload.php";
$naturalLangObj = new \Kweaver\Watson\NaturalLanguageClassifier();
$naturalLangObj->setServiceCredentials("YOUR_WATSON_SERVICE_CREDENTIALS_USER_NAME","YOUR_WATSON_SERVICE_CREDENTIALS_PASSWORD");
$localFilePathForTrainingMetaDataJSON = realpath("./new_training_data_meta_data.json");
$localFilePathForTrainingData = realpath("./weather_data_train.csv");
//Creating a new classifier
$response = $naturalLangObj->create($localFilePathForTrainingData,$localFilePathForTrainingMetaDataJSON);
```
## Retrieve and Rank
## Document Conversion
### Creating A New Object
```
$documentConversionObj = new \Kweaver\Watson\DocumentConversion();
```
### API Methods
**[Convert a document](https://www.ibm.com/watson/developercloud/document-conversion/api/v1/#convert-document)** - Converts a document to answer units, HTML or text. This method accepts a multipart/form-data request. Upload the document as the "file" form part and the configuration as the "config" form part.
### Example
```
require_once "/vendor/autoload.php";
$documentConversionObj = new \Kweaver\Watson\DocumentConversion();
$documentConversionObj->setServiceCredentials("YOUR_USERNAME_FOR_THE_DOC_CONVERSION_SERVICE","YOUR_PASSWORD");
$configFilePath = realpath('./config.json');
$uploadedFilePath = realpath('./sample.pdf');
$version = date('Y-m-d');
$result = $documentConversionObj->convert($configFilePath, $uploadedFilePath, $version);
```