Download the PHP package darrynten/google-natural-language-php without Composer
On this page you can find all versions of the php package darrynten/google-natural-language-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download darrynten/google-natural-language-php
More information about darrynten/google-natural-language-php
Files in darrynten/google-natural-language-php
Package google-natural-language-php
Short Description PHP Google Natural Language Client with Extras
License
Informations about the package google-natural-language-php
google-natural-language-php
An unofficial, fully unit tested Google Natural Language PHP client with extra sugar.
Why not just use the official one?
The official one is great, and we actually use it in this package, it just doesn't quite have the sort of features we needed, so we wrapped it up with some extra bits.
What extra features?
Cost Cutters
The Google Natural Language API costs money. If you're doing anything with it at scale, you're going to have to keep an eye on your calls to make sure things aren't running away with you. I learnt this the hard way. It can get expensive.
That's why we introduced some cost cutting features.
Caching Requests
By default this package caches your requests, something you would have to usually do yourself.
It caches using a framework-agnostic approach, whereby it leverages any host frameworks caching mechanism, and falls back to a temporary cache if there is no cache available.
The supported frameworks are detailed in the AnyCache project.
Examples include Laravel, Symfony, Doctrine, Psr6 and more.
This feature is on by default and can easily be disabled.
Cheapskate Mode
While not immediately clear, the Google Natural Language API charges per 1000 characters.
We've added "cheapskate mode" that, if set, automatically truncates the desired text, saving you another credit.
This feature is on by default and can easily be disabled.
Conveniences
There are a few other conveniences like being able to set the type, language, encoding etc.
One use case would be running a single instance of text through multiple language attempts.
Usage
See The Google Cloud Docs for more on these options and their usage.
Options
setType($type)
- EitherPLAIN_TEXT
(default) orHTML
setEncodingType($type)
- EitherUTF8
(default)UTF16
,UTF32
orNONE
setLanguage($language)
- Either ISO (en
,es
) or BCP-47 (en-ZA
,en-GB
).
If no language is provided then it is autodetected from the text and is returned with the response.
Missing Features
Feel free to open a PR!
Usage of Google\Cloud\Storage\StorageObject is presently not possible.
- Custom
authCache
andauthCacheOptions
- Custom
httpHandler
andauthHttpHandler
Entity Sentiment
You can retrieve the sentiment of some text
Roadmap
- [ ] - Get Entities of Type - Will allow the ability to retrieve, for example, only the People, or only the Locations
- [ ] - Sentiment shortcuts (is positive etc)
- [ ] - Check for types, has location etc
- [ ] - And more!
Acknowledgements
- Dmitry Semenov for being such a legend.
- Bradley Weston for coming out of nowhere.
-
blaisedufrain for the sentiment analysis.
- Open a PR and put yourself here :)
All versions of google-natural-language-php with dependencies
guzzlehttp/guzzle Version ^6.2.1
google/cloud Version ~0.56
darrynten/any-cache Version ^1.0