{"id":41555627,"url":"https://github.com/web64/laravel-nlp","last_synced_at":"2026-01-24T05:08:20.778Z","repository":{"id":46656482,"uuid":"129117849","full_name":"web64/laravel-nlp","owner":"web64","description":"Laravel wrapper for common NLP tasks","archived":false,"fork":false,"pushed_at":"2020-09-19T11:37:48.000Z","size":35,"stargazers_count":57,"open_issues_count":2,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-11-27T16:46:14.171Z","etag":null,"topics":["article-extractor","entity-extraction","language-detection","laravel-package","nlp","sentiment-analysis"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/web64.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-11T15:48:40.000Z","updated_at":"2025-10-12T17:11:53.000Z","dependencies_parsed_at":"2022-09-05T15:01:42.291Z","dependency_job_id":null,"html_url":"https://github.com/web64/laravel-nlp","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/web64/laravel-nlp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web64%2Flaravel-nlp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web64%2Flaravel-nlp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web64%2Flaravel-nlp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web64%2Flaravel-nlp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/web64","download_url":"https://codeload.github.com/web64/laravel-nlp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web64%2Flaravel-nlp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28712841,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T05:01:10.984Z","status":"ssl_error","status_checked_at":"2026-01-24T04:59:18.328Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["article-extractor","entity-extraction","language-detection","laravel-package","nlp","sentiment-analysis"],"created_at":"2026-01-24T05:08:16.945Z","updated_at":"2026-01-24T05:08:20.773Z","avatar_url":"https://github.com/web64.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel NLP\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"http://cdn.web64.com/nlp-norway/laravel-nlp-6.png\" width=\"400\"\u003e\n\u003c/p\u003e\n\nA 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.\n\n## Installation\n\n```bash\n$ composer require web64/laravel-nlp\n```\n\nPlese follow the instructions here to install the NLP Server and CoreNLP server:\n\n- https://github.com/web64/nlpserver\n- https://github.com/web64/php-nlp-client\n\nIf 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/)\n\n## Configuration\n\nAdd `NLPSERVER_URL` to your `.env` file to specify the location of where the NLP Server is running.\nIf 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.\n\n```\nNLPSERVER_URL=\"http://localhost:6400/\"\nCORENLP_HOST=\"http://localhost:9000/\"\nOPENCALAIS_KEY=\n```\n\nAlternatively, update the nlp.php configuration file.\n\n```bash\n# Publish nlp.php config file\n$ php artisan vendor:publish --provider=\"Web64\\LaravelNlp\\NlpServiceProvider\"\n```\n\n## Quick Start\n\n```php\nuse Web64\\LaravelNlp\\Facades\\NLP;\n\n// Get Article content and metadata\n$article = NLP::article($url);\n\n// Detect language\n$lang = NLP::language(\"What language is this?\");\n\n// Entity Extraction\n$entities = NLP::entities( $text, 'en' );\n\n// Sentiment analysis\n$sentiment = NLP::sentiment( $text, 'en' );\n\n// Translage text to Portuguese\n$translated_text = NLP::translate($text, null, 'pt');\n```\n\n## NLP Server\n\nThis package requires a running instance of the NLP Server (https://github.com/web64/nlpserver) for most of the functionality to work.\nSee the documentation for installation instructions of the NLP Server.\n\n## Included NLP Tools\n\n- [Language Detection](#language-detection)\n- [Article Extraction](#article-extraction)\n- [Entity Extraction (Named Entity Recognition)](#entity-extraction-with-polyglot)\n- [Sentiment Analysis](#sentiment-analysis)\n- [Summarization](#summarization)\n- [Translation](#translation)\n- [Neighbouring Words](#neighbouring-words)\n- [Concepts](#concepts)\n\n## Usage\n\nInclude the class to use the NLP facade.\n\n```php\nuse Web64\\LaravelNlp\\Facades\\NLP;\n```\n\n### Language Detection\n\n```php\n$lang = NLP::language(\"What language is this?\");\n// 'en'\n```\n\n### Article Extraction\n\n```php\n$article = NLP::article(\"https://medium.com/@taylorotwell/wildcard-letsencrypt-certificates-on-forge-d3bdec43692a\");\ndump($article);\n/*\n[\n    \"article_html\" =\u003e \"\u003cdiv\u003e\u003ch1 name=\"9022\" id=\"9022\" class=\"graf graf--h3 graf--leading raf--title\"\u003eWildcard LetsEncrypt Certificates on\u0026#160;Forge\u003c/h1\u003e...\",\n    \"authors\" =\u003e [\"Taylor Otwell\"],\n    \"canonical_url\" =\u003e https://medium.com/@taylorotwell/wildcard-letsencrypt-certificates-on-forge-d3bdec43692a\",\n    \"meta_data\" =\u003e [ ... ],\n    \"meta_description\" =\u003e \"Today we’re happy to announce support for wildcard LetsEncrypt certificates on Laravel Forge…\",\n    \"publish_date\" =\u003e \"2018-03-16 13:43:54\",\n    \"text\" =\u003e \"Wildcard LetsEncrypt Certificates on Forge...\",\n    \"title\" =\u003e \"Wildcard LetsEncrypt Certificates on Forge – Taylor Otwell – Medium\",\n    \"top_image\" =\u003e \"https://cdn-images-1.medium.com/max/1200/1*y1yKkIQqGHcpOmsObR7WIQ.png\",\n]\n*/\n```\n\n### Entity Extraction with Polyglot\n\nThis function uses the [Polyglot](https://polyglot.readthedocs.io/en/latest/Installation.html) library which supports entity extraction for 40 languages.\nMake sure you have downloaded the language models for the languages you are using.\n\nFor English and other major European languages use [Spacy](https://spacy.io/usage/) or [CoreNLP](https://stanfordnlp.github.io/CoreNLP/download.html) for best results.\n\n```php\n$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.\";\n\n$entities = NLP::entities( $text, 'en' );\n/*\nArray\n(\n    [0] =\u003e Barack Hussein Obama\n    [1] =\u003e American\n    [2] =\u003e United States\n    [3] =\u003e Illinois\n)\n*/\n```\n\n## Entity Extraction with Spacy\n\nA running NLP Server provides access to Spacy's entity extraction.\n\nSpacy has language models for English, German, Spanish, Portuguese, French, Italian and Dutch.\n\n```php\n$entities = NLP::spacy_entities($text, 'en' );\n/*\narray:4 [\n  \"DATE\" =\u003e array:1 [\n    0 =\u003e \"1857\"\n  ]\n  \"GPE\" =\u003e array:3 [\n    0 =\u003e \"Kentucky\"\n    1 =\u003e \"the United States\"\n    2 =\u003e \"the Confederate States of America\"\n  ]\n  \"NORP\" =\u003e array:1 [\n    0 =\u003e \"Breckinridge  \"\n  ]\n  \"PERSON\" =\u003e array:2 [\n    0 =\u003e \"John C. Breckinridge\"\n    1 =\u003e \"James Buchanan's\"\n  ]\n]\n*/\n```\n\n### Entitiy extraction with CoreNLP\n\n[CoreNLP](https://github.com/web64/php-nlp-client#corenlp---entity-extraction-ner) provides very good entoty extraction for English texts.\n\nTo 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)\n\nSpecify the URL of the CoreNLP server in `CORENLP_HOST` in .env or `config/nlp/php`.\n\n```php\n$entities = NLP::corenlp_entities($text);\n/*\narray:6 [\n  \"PERSON\" =\u003e array:3 [\n    0 =\u003e \"John C. Breckinridge\"\n    1 =\u003e \"James Buchanan\"\n  ]\n  \"STATE_OR_PROVINCE\" =\u003e array:1 [\n    0 =\u003e \"Kentucky\"\n  ]\n  \"COUNTRY\" =\u003e array:1 [\n    0 =\u003e \"United States\"\n  ]\n  \"ORGANIZATION\" =\u003e array:1 [\n    0 =\u003e \"Confederate States of America\"\n  ]\n  \"DATE\" =\u003e array:1 [\n    0 =\u003e \"1857\"\n  ]\n  \"TITLE\" =\u003e array:1 [\n    0 =\u003e \"vice president\"\n  ]\n]\n*/\n```\n\n### Sentiment Analysis\n\nThis will return a value ranging from -1 to +1, where \u003e 0 is considered to have a positive sentiment and everython \u003c 0 has a negative sentiment.\n\nProvide the language code as the second parameter to specify the language of the text. (default='en').\n\n```php\n$sentiment = NLP::sentiment( \"This is great!\" );\n// 1\n\n$sentiment = NLP::sentiment( \"I hate this product\", 'en' );\n// -1\n```\n\n### Summarization\n\nThis will take a long text and return a summary of what is considered to be the most important sentences.\nAn optional max. number of words can be speficied.\n\n```php\n$summary = NLP::summarize($long_text);\n$summary = NLP::summarize($long_text, $max_word_count) ;\n\n```\n\n### Translation\n\nSecond parameter is the source language. Language will be automatically detected if left as NULL\n\n```php\n$translated_text = NLP::translate($text, $from_lang, $to_lang);\n\n$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');\n// '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'\n```\n\n### Neighbouring Words\n\nThis uses word embeddings to find related words from the one given.\n\n```php\n$words = NLP::neighbours( 'president');\ndump( $words );\n/*\narray:10 [\n  0 =\u003e \"chairman\"\n  1 =\u003e \"vice-president\"\n  2 =\u003e \"President\"\n  3 =\u003e \"Chairman\"\n  4 =\u003e \"Vice-President\"\n]\n*/\n\n// ensure polyglot language model is installed: polyglot download LANG:no\n$norwegian_words = NLP::neighbours( 'president', 'no');\n/*\narray:10 [\n  0 =\u003e \"visepresident\"\n  1 =\u003e \"presidenten\"\n  2 =\u003e \"statsminister\"\n  3 =\u003e \"utenriksminister\"\n  4 =\u003e \"finansminister\"\n]\n*/\n```\n\n### Concepts\n\nThis uses Microsoft Concept Graph For Short Text Understanding: https://concept.research.microsoft.com/\n\nAn array of related concepts will be returned.\n\n```php\n$concepts = NLP::concepts( 'php' );\n\n/*\narray:10 [\n  \"language\" =\u003e 0.40301612064483\n  \"technology\" =\u003e 0.19656786271451\n  \"programming language\" =\u003e 0.14456578263131\n  \"open source technology\" =\u003e 0.057202288091524\n  \"scripting language\" =\u003e 0.049921996879875\n  \"server side language\" =\u003e 0.044201768070723\n  \"web technology\" =\u003e 0.031201248049922\n  \"server-side language\" =\u003e 0.027561102444098\n]\n*/\n```\n\n## More\n\nFor other Laravel NLP packages, check out:\n\n- https://github.com/AntoineAugusti/laravel-sentiment-analysis\n- https://github.com/michaeljhopkins/Laravel-Aylien-Wrapper\n- https://github.com/findbrok/laravel-personality-insights\n\n## Contribute\n\nGet in touch if you have any feedback or ideas on how to improve this package or the documentation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweb64%2Flaravel-nlp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweb64%2Flaravel-nlp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweb64%2Flaravel-nlp/lists"}