2017 © Pedro PelĂĄez
 

library php-nltk-client

PHP client implementation for szyku/nltk-api

image

szyku/php-nltk-client

PHP client implementation for szyku/nltk-api

  • Sunday, May 21, 2017
  • by szyku90
  • Repository
  • 1 Watchers
  • 1 Stars
  • 24 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

PHP NLTK API Client Build Status

This is a PHP client for szyku/nltk-api which exposes python's NLTK resources and WordNet database through a friendly API., (*1)

The aim of this client is to provide a comfortable and intuitive way of interacting with the NLTK API., (*2)

Installation

This package was tested for PHP >= 5.6., (*3)

Composer:, (*4)

composer require szyku/php-nltk-client

Git clone:, (*5)

git clone git@github.com:szyku/php-nltk-client.git

Or download zip:, (*6)

wget https://github.com/szyku/php-nltk-client/archive/master.zip 

Or tarball:, (*7)

wget https://github.com/szyku/php-nltk-client/archive/master.tar.gz

How to use it

Easy to setup:, (*8)

require __DIR__ . '/vendor/autoload.php';

use GuzzleHttp\Psr7\Uri;
use Szyku\NLTK\Client;
use GuzzleHttp\Client as Guzzle;

$uri = new Uri("http://localhost:5000");
$guzzle = new Guzzle(['base_uri' => $uri]);
// or just $guzzle = new Guzzle(['base_uri' => 'http://localhost:5000']);

$nltkClient = new Client($guzzle);

How to query definitions with handy methods:, (*9)

use Szyku\NLTK\Request\Dictionary\DefinitionLookupRequest;
use Szyku\NLTK\Request\Dictionary\SimilarLookupRequest;
use Szyku\NLTK\Request\Lemma\LemmatizationRequestBuilder as Builder;
use Szyku\NLTK\Request\Tagger\TaggingRequestBuilder as TaggerBuilder;

$similarWordsToCastle = SimilarLookupRequest::noun('castle');
$definitionsForRA = DefinitionLookupRequest::noun('rheumatoid arthritis');

$sentenceTagging = TaggerBuilder::create()
    ->add('He is a cunning man.')
    ->addMany(['Before and after.', 'Ups and downs'])
    ->build();

$lemmatizeSentence = Builder::create()
    ->adjective('biggest')
    ->noun('dogs')
    ->verb('fought')
    ->adverb('loudly')
    ->findAllFor('at')
    ->build();

// results are hydrated to objects like WordLookupResponse or LemmatizationResponse
$castleResult = $nltkClient->dictionary($similarWordsToCastle);
$raResult = $nltkClient->dictionary($definitionsForRA);
$lemmatizationResult = $nltkClient->lemmatization($lemmatizeSentence);
$taggingResult = $nltkClient->tagging($sentenceTagging);

// easy to consume
echo "Time taken in seconds: " . $castleResult->lookupTime();
echo "Searched for: " . $castleResult->queriedPhrase();

foreach ($castleResult->results() as $result) {
    echo $result->phrase() . ": " . $result->definition();
}
// prints "palace: A large and stately mansion"

The Versions

21/05 2017

dev-master

9999999-dev https://github.com/szyku/nltk-api

PHP client implementation for szyku/nltk-api

  Sources   Download

MIT

The Requires

 

The Development Requires

by Szymon SzymaƄski

21/05 2017

v1.1.2

1.1.2.0 https://github.com/szyku/nltk-api

PHP client implementation for szyku/nltk-api

  Sources   Download

MIT

The Requires

 

The Development Requires

by Szymon SzymaƄski

21/05 2017

dev-constant-correction

dev-constant-correction https://github.com/szyku/nltk-api

PHP client implementation for szyku/nltk-api

  Sources   Download

MIT

The Requires

 

The Development Requires

by Szymon SzymaƄski

21/05 2017

v1.1.1

1.1.1.0 https://github.com/szyku/nltk-api

PHP client implementation for szyku/nltk-api

  Sources   Download

MIT

The Requires

 

The Development Requires

by Szymon SzymaƄski

21/05 2017

dev-typofix

dev-typofix https://github.com/szyku/nltk-api

PHP client implementation for szyku/nltk-api

  Sources   Download

MIT

The Requires

 

The Development Requires

by Szymon SzymaƄski

17/05 2017

v1.1

1.1.0.0 https://github.com/szyku/nltk-api

PHP client implementation for szyku/nltk-api

  Sources   Download

MIT

The Requires

 

The Development Requires

by Szymon SzymaƄski

04/05 2017

v1.0

1.0.0.0 https://github.com/szyku/nltk-api

PHP client implementation for szyku/nltk-api

  Sources   Download

MIT

The Requires

 

The Development Requires

by Szymon SzymaƄski