PHPackages                             aflorea4/laravel-nlp - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. aflorea4/laravel-nlp

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

aflorea4/laravel-nlp
====================

Laravel package for accessing NLP tools (FIXED Header interpretation)

v0.40.1(3y ago)0124MITPHP

Since Apr 11Pushed 3y agoCompare

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

READMEChangelog (1)Dependencies (3)Versions (8)Used By (0)

Laravel NLP
===========

[](#laravel-nlp)

 [![](https://camo.githubusercontent.com/ee4339829c06ca7370b1ab59b5dea0629dcc144f75197ded74b4a1b75df81c47/687474703a2f2f63646e2e77656236342e636f6d2f6e6c702d6e6f727761792f6c61726176656c2d6e6c702d362e706e67)](https://camo.githubusercontent.com/ee4339829c06ca7370b1ab59b5dea0629dcc144f75197ded74b4a1b75df81c47/687474703a2f2f63646e2e77656236342e636f6d2f6e6c702d6e6f727761792f6c61726176656c2d6e6c702d362e706e67)

A simple wrapper for the [PHP-NLP-Client](https://github.com/web64/php-nlp-client) library for accessing Python and Java NLP libraries and external NLP APIs.

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

[](#installation)

```
$ composer require web64/laravel-nlp
```

Plese follow the instructions here to install the NLP Server and CoreNLP server:

-
-

If you want to use Opencalais, get a token by registering [here](http://www.opencalais.com/) and read their [terms of service](http://www.opencalais.com/open-calais-terms-of-service/)

Configuration
-------------

[](#configuration)

Add `NLPSERVER_URL` to your `.env` file to specify the location of where the NLP Server is running. If you want to use [CoreNLP](https://stanfordnlp.github.io/CoreNLP/download.html) or [Opencalais](http://www.opencalais.com/) also fill inn those details in .env.

```
NLPSERVER_URL="http://localhost:6400/"
CORENLP_HOST="http://localhost:9000/"
OPENCALAIS_KEY=

```

Alternatively, update the nlp.php configuration file.

```
# Publish nlp.php config file
$ php artisan vendor:publish --provider="Web64\LaravelNlp\NlpServiceProvider"
```

Quick Start
-----------

[](#quick-start)

```
use Web64\LaravelNlp\Facades\NLP;

// Get Article content and metadata
$article = NLP::article($url);

// Detect language
$lang = NLP::language("What language is this?");

// Entity Extraction
$entities = NLP::entities( $text, 'en' );

// Sentiment analysis
$sentiment = NLP::sentiment( $text, 'en' );

// Translage text to Portuguese
$translated_text = NLP::translate($text, null, 'pt');
```

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

[](#nlp-server)

This package requires a running instance of the NLP Server () for most of the functionality to work. See the documentation for installation instructions of the NLP Server.

Included NLP Tools
------------------

[](#included-nlp-tools)

- [Language Detection](#language-detection)
- [Article Extraction](#article-extraction)
- [Entity Extraction (Named Entity Recognition)](#entity-extraction-with-polyglot)
- [Sentiment Analysis](#sentiment-analysis)
- [Summarization](#summarization)
- [Translation](#translation)
- [Neighbouring Words](#neighbouring-words)
- [Concepts](#concepts)

Usage
-----

[](#usage)

Include the class to use the NLP facade.

```
use Web64\LaravelNlp\Facades\NLP;
```

### Language Detection

[](#language-detection)

```
$lang = NLP::language("What language is this?");
// 'en'
```

### Article Extraction

[](#article-extraction)

```
$article = NLP::article("https://medium.com/@taylorotwell/wildcard-letsencrypt-certificates-on-forge-d3bdec43692a");
dump($article);
/*
[
    "article_html" => "Wildcard LetsEncrypt Certificates on&#160;Forge...",
    "authors" => ["Taylor Otwell"],
    "canonical_url" => https://medium.com/@taylorotwell/wildcard-letsencrypt-certificates-on-forge-d3bdec43692a",
    "meta_data" => [ ... ],
    "meta_description" => "Today we’re happy to announce support for wildcard LetsEncrypt certificates on Laravel Forge…",
    "publish_date" => "2018-03-16 13:43:54",
    "text" => "Wildcard LetsEncrypt Certificates on Forge...",
    "title" => "Wildcard LetsEncrypt Certificates on Forge – Taylor Otwell – Medium",
    "top_image" => "https://cdn-images-1.medium.com/max/1200/1*y1yKkIQqGHcpOmsObR7WIQ.png",
]
*/
```

### Entity Extraction with Polyglot

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

This function uses the [Polyglot](https://polyglot.readthedocs.io/en/latest/Installation.html) library which supports entity extraction for 40 languages. Make sure you have downloaded the language models for the languages you are using.

For English and other major European languages use [Spacy](https://spacy.io/usage/) or [CoreNLP](https://stanfordnlp.github.io/CoreNLP/download.html) for best results.

```
$text = "Barack Hussein Obama is an American politician who served as the 44th President of the United States from January 20, 2009 to January 20, 2017. Before that, he served in the Illinois State Senate from 1997 until 2004.";

$entities = NLP::entities( $text, 'en' );
/*
Array
(
    [0] => Barack Hussein Obama
    [1] => American
    [2] => United States
    [3] => Illinois
)
*/
```

Entity Extraction with Spacy
----------------------------

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

A running NLP Server provides access to Spacy's entity extraction.

Spacy has language models for English, German, Spanish, Portuguese, French, Italian and Dutch.

```
$entities = NLP::spacy_entities($text, 'en' );
/*
array:4 [
  "DATE" => array:1 [
    0 => "1857"
  ]
  "GPE" => array:3 [
    0 => "Kentucky"
    1 => "the United States"
    2 => "the Confederate States of America"
  ]
  "NORP" => array:1 [
    0 => "Breckinridge  "
  ]
  "PERSON" => array:2 [
    0 => "John C. Breckinridge"
    1 => "James Buchanan's"
  ]
]
*/
```

### Entitiy extraction with CoreNLP

[](#entitiy-extraction-with-corenlp)

[CoreNLP](https://github.com/web64/php-nlp-client#corenlp---entity-extraction-ner) provides very good entoty extraction for English texts.

To use this function you need a running instance of the CoreNLP server. [See installation inststructions](https://github.com/web64/php-nlp-client#corenlp---entity-extraction-ner)

Specify the URL of the CoreNLP server in `CORENLP_HOST` in .env or `config/nlp/php`.

```
$entities = NLP::corenlp_entities($text);
/*
array:6 [
  "PERSON" => array:3 [
    0 => "John C. Breckinridge"
    1 => "James Buchanan"
  ]
  "STATE_OR_PROVINCE" => array:1 [
    0 => "Kentucky"
  ]
  "COUNTRY" => array:1 [
    0 => "United States"
  ]
  "ORGANIZATION" => array:1 [
    0 => "Confederate States of America"
  ]
  "DATE" => array:1 [
    0 => "1857"
  ]
  "TITLE" => array:1 [
    0 => "vice president"
  ]
]
*/
```

### Sentiment Analysis

[](#sentiment-analysis)

This will return a value ranging from -1 to +1, where &gt; 0 is considered to have a positive sentiment and everython &lt; 0 has a negative sentiment.

Provide the language code as the second parameter to specify the language of the text. (default='en').

```
$sentiment = NLP::sentiment( "This is great!" );
// 1

$sentiment = NLP::sentiment( "I hate this product", 'en' );
// -1
```

### Summarization

[](#summarization)

This will take a long text and return a summary of what is considered to be the most important sentences. An optional max. number of words can be speficied.

```
$summary = NLP::summarize($long_text);
$summary = NLP::summarize($long_text, $max_word_count) ;
```

### Translation

[](#translation)

Second parameter is the source language. Language will be automatically detected if left as NULL

```
$translated_text = NLP::translate($text, $from_lang, $to_lang);

$translated_text = NLP::translate("Mange er opprørt etter avsløringene om at persondata for 87 millioner Facebook-brukere skal være på avveie", null, 'pt');
// 'Muitas pessoas estão chateadas após a divulgação de que os dados pessoais de 87 milhões de usuários do Facebook devem estar fora de ordem'
```

### Neighbouring Words

[](#neighbouring-words)

This uses word embeddings to find related words from the one given.

```
$words = NLP::neighbours( 'president');
dump( $words );
/*
array:10 [
  0 => "chairman"
  1 => "vice-president"
  2 => "President"
  3 => "Chairman"
  4 => "Vice-President"
]
*/

// ensure polyglot language model is installed: polyglot download LANG:no
$norwegian_words = NLP::neighbours( 'president', 'no');
/*
array:10 [
  0 => "visepresident"
  1 => "presidenten"
  2 => "statsminister"
  3 => "utenriksminister"
  4 => "finansminister"
]
*/
```

### Concepts

[](#concepts)

This uses Microsoft Concept Graph For Short Text Understanding:

An array of related concepts will be returned.

```
$concepts = NLP::concepts( 'php' );

/*
array:10 [
  "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
]
*/
```

More
----

[](#more)

For other Laravel NLP packages, check out:

-
-
-

Contribute
----------

[](#contribute)

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

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.5% 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 ~260 days

Recently: every ~361 days

Total

7

Last Release

1391d 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 (23 commits)")[![aflorea4](https://avatars.githubusercontent.com/u/5405865?v=4)](https://github.com/aflorea4 "aflorea4 (3 commits)")

### Embed Badge

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

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

###  Alternatives

[web64/laravel-nlp

Laravel package for accessing NLP tools

5711.2k](/packages/web64-laravel-nlp)

PHPackages © 2026

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