PHPackages                             aflorea4/php-nlp-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. aflorea4/php-nlp-client

ActiveLibrary[API Development](/categories/api)

aflorea4/php-nlp-client
=======================

Library for accessing NLP apis (Fixed HTTP header interpretation)

v0.40.7(3y ago)01311MITPHPPHP &gt;=5.6.0

Since Apr 10Pushed 3y agoCompare

[ Source](https://github.com/aflorea4/php-nlp-client)[ Packagist](https://packagist.org/packages/aflorea4/php-nlp-client)[ RSS](/packages/aflorea4-php-nlp-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (12)Used By (1)

PHP NLP-Client
==============

[](#php-nlp-client)

 [![](https://camo.githubusercontent.com/986da80c3848bccae0c585ae9d0f7e55292c9cd813678910ebfc98dc388b61df/687474703a2f2f63646e2e77656236342e636f6d2f6e6c702d6e6f727761792f7068702d6e6c702e706e67)](https://camo.githubusercontent.com/986da80c3848bccae0c585ae9d0f7e55292c9cd813678910ebfc98dc388b61df/687474703a2f2f63646e2e77656236342e636f6d2f6e6c702d6e6f727761792f7068702d6e6c702e706e67)

This is a simple PHP library for performing multilingual Natural Language tasks using Web64's NLP-Server  and other providers.

NLP tasks available through Web64's NLP Server:

- [Language detection](#language-detection)
- [Article Extraction from HTML or URL](#article--metadata-extraction)
- [Entity Extraction](#entitiy-extraction--sentiment-analysis-polyglot) (NER) - Multilingual
- [Sentiment Analysis](#sentiment-analysis) - Multilingual
- [Embeddings / Neighbouring words](#neighbouring-words-embeddings) - Multilingual
- [Summarization](#summarization)

NLP Tasks Available through Stanford's CoreNLP Server:

- [Entity Extraction (NER)](#corenlp---entity-extraction-ner)

NLP Tasks Available through Microsoft Labs API:

- [Concept Graph](#concept-graph)

### Laravel Package

[](#laravel-package)

There is also a Laravel wrapper for this library available here:

Installation
------------

[](#installation)

```
composer require web64/php-nlp-client
```

NLP Server
----------

[](#nlp-server)

Most NLP features in this package requires a running instance of the NLP Server, which is a simple python flask app providing web service api access to common python NLP libraries.

Installation instrcuctions:

Entity Extraction - Named Entity Recognition (NER)
--------------------------------------------------

[](#entity-extraction---named-entity-recognition-ner)

This library provides access to three different methods for entity extraction.

ProviderLanguage SupportProgramming Lang.API Access[Polyglot](https://polyglot.readthedocs.io/en/latest/)40 languagesPythonNLP Server[Spacy](https://spacy.io/)7 languagesPythonNLP Server[CoreNLP](https://stanfordnlp.github.io/CoreNLP/download.html)6 languagesJavaCoreNLP Standalone serverIf you are dealing with text in English or one of the major European language you will get the best results with CoreNLP or Spacy.

The quality of extracted entities with Polyglot is not great, but for many languages it is the only available option at the moment.

Polyglot and Spacy NER is accessible thorough the NLP Server, CoreNLP requires its own standalone java server.

Usage
-----

[](#usage)

### Language detection:

[](#language-detection)

```
$nlp = new \Web64\Nlp\NlpClient('http://localhost:6400/');
$detected_lang = $nlp->language( "The quick brown fox jumps over the lazy dog" );
// 'en'
```

### Article &amp; Metadata Extraction

[](#article--metadata-extraction)

```
// From URL
$nlp = new \Web64\Nlp\NlpClient('http://localhost:6400/');
$newspaper = $nlp->newspaper('https://github.com/web64/nlpserver');

// or from HTML
$html = file_get_contents( 'https://github.com/web64/nlpserver' );
$newspaper = $nlp->newspaper_html( $html );

Array
(
    [article_html] => NLP Server ....
    [authors] => Array()
    [canonical_url] => https://github.com/web64/nlpserver
    [meta_data] => Array()
    [meta_description] => GitHub is where people build software. More than 27 million people use GitHub to discover, fork, and contribute to over 80 million projects.
    [meta_lang] => en
    [source_url] =>
    [text] => NLP Server. Python Flask web service for easy access to multilingual NLP tasks such as language detection, article extraction...
    [title] => web64/nlpserver: NLP Web Service
    [top_image] => https://avatars2.githubusercontent.com/u/76733?s=400&v=4
)
```

### Entitiy Extraction &amp; Sentiment Analysis (Polyglot)

[](#entitiy-extraction--sentiment-analysis-polyglot)

This uses the Polyglot multilingual NLP library to return entities and a sentiment score for given text.Ensure the models for the required languages are downloaded for Polyglot.

```
$polyglot = $nlp->polyglot_entities( $text, 'en' );

$polyglot->getSentiment(); // -1

$polyglot->getEntityTypes();
/*
Array
(
    [Locations] => Array
    (
        [0] => United Kingdom
    )
    [Organizations] =>
    [Persons] => Array
    (
        [0] => Ben
        [1] => Sir Benjamin Hall
        [2] => Benjamin Caunt
    )
)
*/

$polyglot->getLocations();  // Array of Locations
$polyglot->getOrganizations(); // Array of organisations
$polyglot->getPersons(); // Array of people

$polyglot->getEntities();
/*
Returns flat array of all entities
Array
(
    [0] => Ben
    [1] => United Kingdom
    [2] => Sir Benjamin Hall
    [3] => Benjamin Caunt
)
*/
```

### Entity Extraction with Spacy

[](#entity-extraction-with-spacy)

```
$text = "Harvesters is a 1905 oil painting on canvas by the Danish artist Anna Ancher, a member of the artists' community known as the Skagen Painters.";

$nlp = new \Web64\Nlp\NlpClient('http://localhost:6400/');
$entities = $nlp->spacy_entities( $text );
/*
Array
(
    [DATE] => Array
        (
            [0] => 1905
        )

    [NORP] => Array
        (
            [0] => Danish
        )

    [ORG] => Array
        (
            [0] => the Skagen Painters
        )

    [PERSON] => Array
        (
            [0] => Anna Ancher
        )
)
*/
```

English is used by default. To use another language, ensure the Spacy language model is downloaded and add the language as the second parameter

```
$entities = $nlp->spacy_entities( $spanish_text, 'es' );
```

### Sentiment Analysis

[](#sentiment-analysis)

```
$sentiment = $nlp->sentiment( "This is the worst product ever" );
// -1

$sentiment = $nlp->sentiment( "This is great! " );
// 1

// specify language in second parameter for non-english
$sentiment = $nlp->sentiment( $french_text, 'fr' );
```

### Neighbouring words (Embeddings)

[](#neighbouring-words-embeddings)

```
$nlp = new \Web64\Nlp\NlpClient('http://localhost:6400/');
$neighbours = $nlp->neighbours('obama', 'en');
/*
Array
(
    [0] => Bush
    [1] => Reagan
    [2] => Clinton
    [3] => Ahmadinejad
    [4] => Nixon
    [5] => Karzai
    [6] => McCain
    [7] => Biden
    [8] => Huckabee
    [9] => Lula
)
*/
```

### Summarization

[](#summarization)

Extract short summary from a long text

```
$summary = $nlp->summarize( $long_text );
```

### Readability

[](#readability)

Article Extraction using python port of Readability.js

```
$nlp = new \Web64\Nlp\NlpClient( 'http://localhost:6400/' );

// From URL:
$article = $nlp->readability('https://github.com/web64/nlpserver');

// From HTML:
$html = file_get_contents( 'https://github.com/web64/nlpserver' );
$article = $nlp->readability_html( $html );

/*
Array
(
    [article_html] => NLP ServerPython 3 Flask web service for easy access to multilingual NLP tasks ...
    [short_title] => web64/nlpserver: NLP Web Service
    [text] => NLP Server Python 3 Flask web service for easy access to multilingual NLP tasks such as language detection  ...
    [title] => GitHub - web64/nlpserver: NLP Web Service
)
*/
```

CoreNLP - Entity Extraction (NER)
---------------------------------

[](#corenlp---entity-extraction-ner)

CoreNLP has much better quality for NER that Polyglot, but only supports a few languages including English, French, German and Spanish.

Download CoreNLP server (Java) here:

### Install CoreNLP

[](#install-corenlp)

```
# Update download links with latest versions from the download page

wget http://nlp.stanford.edu/software/stanford-corenlp-full-2018-10-05.zip
unzip stanford-corenlp-full-2018-10-05.zip
cd stanford-corenlp-full-2018-02-27

# Download English language model:
wget http://nlp.stanford.edu/software/stanford-english-kbp-corenlp-2018-10-05-models.jar
```

### Running the CoreNLP server

[](#running-the-corenlp-server)

```
# Run the server using all jars in the current directory (e.g., the CoreNLP home directory)
java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 15000

# To run server in as a background process
nohup java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 15000 &
```

When the CoreNLP server is running you can access it on port 9000:

More info about running the CoreNLP Server:

```
$corenlp = new \Web64\Nlp\CoreNlp('http://localhost:9000/');
$entities = $corenlp->entities( $text );
/*
Array
(
    [NATIONALITY] => Array
        (
            [0] => German
            [1] => Turkish
        )
    [ORGANIZATION] => Array
        (
            [0] => Foreign Ministry
        )
    [TITLE] => Array
        (
            [0] => reporter
            [1] => journalist
            [2] => correspondent
        )
    [COUNTRY] => Array
        (
            [0] => Turkey
            [1] => Germany
        )
*/
```

Concept Graph
-------------

[](#concept-graph)

Microsoft Concept Graph For Short Text Understanding:

Find related concepts to provided keyword

```
$concept = new \Web64\Nlp\MsConceptGraph;
$res = $concept->get('php');
/*
Array
(
    [language] => 0.40301612064483
    [technology] => 0.19656786271451
    [programming language] => 0.14456578263131
    [open source technology] => 0.057202288091524
    [scripting language] => 0.049921996879875
    [server side language] => 0.044201768070723
    [web technology] => 0.031201248049922
    [server-side language] => 0.027561102444098
    [server side scripting language] => 0.023920956838274
    [feature] => 0.021840873634945
)
*/
```

Python libraries
----------------

[](#python-libraries)

These are the python libraries used by the NLP Server for the NLP and data extraction tasks.

LibraryURLNLP Task usedlangid.pyLanguage detectionNewspaperArticle &amp; metadata extractionSpacyEntity extractionPolyglotMultilingual NLPprocessing toolkitGensimSummarizationReadabilityArticle extractionOther PHP NLP projects
----------------------

[](#other-php-nlp-projects)

-
-

Contribute
----------

[](#contribute)

Get in touch if you have any feedback or ideas on how to improve this package or the documentation.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~156 days

Recently: every ~320 days

Total

11

Last Release

1399d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/315d245e8480aa5b196fe359fad15855c654ee30f77eb7918bc0fbc6b72070e3?d=identicon)[aflorea4](/maintainers/aflorea4)

---

Top Contributors

[![web64](https://avatars.githubusercontent.com/u/76733?v=4)](https://github.com/web64 "web64 (26 commits)")[![aflorea4](https://avatars.githubusercontent.com/u/5405865?v=4)](https://github.com/aflorea4 "aflorea4 (3 commits)")

---

Tags

nlpnatural-languagelanguage detectionarticle extractionentity extraction

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aflorea4-php-nlp-client/health.svg)

```
[![Health](https://phpackages.com/badges/aflorea4-php-nlp-client/health.svg)](https://phpackages.com/packages/aflorea4-php-nlp-client)
```

###  Alternatives

[web64/php-nlp-client

Library for accessing NLP apis

7424.5k2](/packages/web64-php-nlp-client)[google-gemini-php/client

Gemini API is a supercharged PHP API client that allows you to interact with the Gemini API

402986.7k21](/packages/google-gemini-php-client)[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47073.9k5](/packages/deepseek-php-deepseek-php-client)[grok-php/laravel

Seamlessly integrate Grok AI into Laravel applications with an elegant, developer-friendly package. Leverage powerful AI models for chat, automation, and NLP while maintaining Laravel's expressive simplicity.

1633.4k](/packages/grok-php-laravel)[nlpcloud/nlpcloud-client

NLP Cloud serves high performance pre-trained or custom models for NER, sentiment-analysis, classification, summarization, paraphrasing, grammar and spelling correction, keywords and keyphrases extraction, chatbot, product description and ad generation, intent classification, text generation, image generation, code generation, question answering, automatic speech recognition, machine translation, language detection, semantic search, semantic similarity, tokenization, POS tagging, speech synthesis, embeddings, and dependency parsing. It is ready for production, served through a REST API. This is the PHP client for the API. More details here: https://nlpcloud.com. Documentation: https://docs.nlpcloud.com. Github: https://github.com/nlpcloud/nlpcloud-php

2523.9k](/packages/nlpcloud-nlpcloud-client)[grok-php/client

Grok PHP Client is a robust and community-driven PHP client library for seamless integration with Grok AI API, offering efficient access to advanced AI and data processing capabilities.

325.9k4](/packages/grok-php-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
