2017 © Pedro Peláez
 

library laravel-alchemy

Package for Laravel integration with Alchemy API

image

lexismith/laravel-alchemy

Package for Laravel integration with Alchemy API

  • Monday, February 13, 2017
  • by lexismith
  • Repository
  • 2 Watchers
  • 0 Stars
  • 3,357 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 8 % Grown

The README.md

Alchemy API Service Provider for Laravel 5

This is a Laravel service provider for making it easy to include the Alchemy API for PHP in a Laravel application., (*1)

Installation

The Alchemy Service Provider can be installed via Composer by requiring the lexismith/laravel-alchemy package in your project's composer.json., (*2)

    {
        "require": {
            "lexismith/laravel-alchemy": "dev-master"
        }
    }

Then run a composer update, (*3)

php composer.phar update

To use the Alchemy Service Provider, you must register the provider when bootstrapping your Laravel application., (*4)

Find the providers key in your config/app.php and register the service provider., (*5)

    'providers' => array(
        // ...
            'LexiSmith\LaravelAlchemy\AlchemyServiceProvider',
    )

Find the aliases key in your config/app.php and add the Alchemy facade alias., (*6)

    'aliases' => array(
        // ...
        'Alchemy'   => 'LexiSmith\LaravelAlchemy\AlchemyFacade',
    )

Configuration

By default, the package uses the following environment variables to auto-configure the plugin without modification:, (*7)

API_KEY
BASE_URL

To customize the configuration file, publish the package configuration using Artisan., (*8)

php artisan vendor:publish

Update your settings in the generated app/config/alchemy.php configuration file or by editing your environment variables accordingly in .env, (*9)

return [
        'url' => env('ALCHEMY_URL', 'http://access.alchemyapi.com/calls'),
        'key' => env('ALCHEMY_API_KEY')
];

Usage

All functions accept three parameters: 1. $flavor that describes the type of content being passed. For each function, the options for $flavor are given. 2. $data that is given in the form of the $flavor. 3. $options that specify options for each specific function, as described below., (*10)

Emotion

Tags the concepts for test, a URL, or HTML. For more information, please refer to the overview or the docs., (*11)

    $emotions = Alchemy::emotion($flavor, $data, $options);

Available flavors: + 'text' + 'html' + 'url', (*12)

Available options: + maxRetrieve -> the maximum number of concepts to retrieve (default: 8) + linkedData -> include linked data, 0: disabled, 1: enabled (default) + showSourceText -> 0:disabled (default), 1: enabled, (*13)

Entities

Extracts the entities for text, a URL or HTML. For more information, please refer to the overview or the docs., (*14)

    $emotions = Alchemy::entities($flavor, $data, $options);

Available flavors: + 'text' + 'html' + 'url', (*15)

Available options: + disambiguate -> disambiguate entities (i.e. Apple the company vs. apple the fruit). 0: disabled, 1: enabled (default) + linkedData -> include linked data on disambiguated entities. 0: disabled, 1: enabled (default) + coreference -> resolve coreferences (i.e. the pronouns that correspond to named entities). 0: disabled, 1: enabled (default) + quotations -> extract quotations by entities. 0: disabled (default), 1: enabled. + sentiment -> analyze sentiment for each entity. 0: disabled (default), 1: enabled. Requires 1 additional API transction if enabled. + showSourceText -> 0: disabled (default), 1: enabled + maxRetrieve -> the maximum number of entities to retrieve (default: 50), (*16)

Keywords

Extracts the keywords for text, a URL or HTML. For more information, please refer to the overview or the docs., (*17)

    $emotions = Alchemy::keywords($flavor, $data, $options);

Available flavors: + 'text' + 'html' + 'url', (*18)

Available options: + keywordExtractMode -> normal (default), strict + sentiment -> analyze sentiment for each keyword. 0: disabled (default), 1: enabled. Requires 1 additional API transaction if enabled. + showSourceText -> 0: disabled (default), 1: enabled. + maxRetrieve -> the max number of keywords returned (default: 50), (*19)

Concepts

Tags the concepts for text, a URL or HTML. For more information, please refer to the overview or the docs., (*20)

    $emotions = Alchemy::keywords($flavor, $data, $options);

Available flavors: + 'text' + 'html' + 'url', (*21)

Available options: + maxRetrieve -> the maximum number of concepts to retrieve (default: 8) + linkedData -> include linked data, 0: disabled, 1: enabled (default) + showSourceText -> 0:disabled (default), 1: enabled, (*22)

Sentiment

Calculates the sentiment for text, a URL or HTML. For more information, please refer to the overview or the docs., (*23)

    $emotions = Alchemy::sentiment($flavor, $data, $options);

Available flavors: + 'text' + 'html' + 'url', (*24)

Available options: + showSourceText -> 0: disabled (default), 1: enabled, (*25)

Targeted Sentiment

Analyzes sentiment for targeted phrases via text, a URL or HTML. For more information, please refer to the overview or the docs., (*26)

    $emotions = Alchemy::sentiment_targeted($flavor, $data, $target, $options);

Additional input: + target -> the word or phrase to run sentiment analysis on., (*27)

Available flavors: + 'text' + 'html' + 'url', (*28)

Available options: + showSourceText -> 0: disabled (default), 1: enabled, (*29)

Cleaned Text

Extracts the cleaned text (removes ads, navigation, etc.) for text, a URL or HTML. For more information, please refer to the overview or the docs., (*30)

    $emotions = Alchemy::text($flavor, $data, $options);

Available flavors: + 'text' + 'html' + 'url', (*31)

Available options: + useMetadata -> utilize meta description data, 0: disabled, 1: enabled (default) + extractLinks -> include links, 0: disabled (default), 1: enabled., (*32)

Raw Text

Extracts the raw text (includes ads, navigation, etc.) for text, a URL or HTML. For more information, please refer to the overview or the docs., (*33)

    $emotions = Alchemy::text_raw($flavor, $data, $options);

Available flavors: + 'text' + 'html' + 'url', (*34)

Available options: + none, (*35)

Author

Extracts the author from URL or HTML. For more information, please refer to the overview or the docs., (*36)

    $emotions = Alchemy::author($flavor, $data, $options);

Available flavors: + 'html' + 'url', (*37)

Available options: + none, (*38)

Language Detection

Detects the language for text, a URL or HTML. For more information, please refer to the overview or the docs., (*39)

    $emotions = Alchemy::language($flavor, $data, $options);

Available flavors: + 'text' + 'html' + 'url', (*40)

Available options: + none, (*41)

Title

Extracts the title for a URL or HTML. For more information, please refer to the overview or the docs., (*42)

    $emotions = Alchemy::title($flavor, $data, $options);

Available flavors: + 'html' + 'url', (*43)

Available options: + useMetadata -> utilize title info embedded in meta data, 0: disabled, 1: enabled (default), (*44)

Relations

Extracts the relations for text, a URL or HTML. For more information, please refer to the overview or the docs., (*45)

    $emotions = Alchemy::relations($flavor, $data, $options);

Available flavors: + 'text' + 'html' + 'url', (*46)

Available options: + sentiment -> 0: disabled (default), 1: enabled. Requires one additional API transaction if enabled. + keywords -> extract keywords from the subject and object. 0: disabled (default), 1: enabled. Requires one additional API transaction if enabled. + entities -> extract entities from the subject and object. 0: disabled (default), 1: enabled. Requires one additional API transaction if enabled. + requireEntities -> only extract relations that have entities. 0: disabled (default), 1: enabled. + sentimentExcludeEntities -> exclude full entity name in sentiment analysis. 0: disabled, 1: enabled (default) + disambiguate -> disambiguate entities (i.e. Apple the company vs. apple the fruit). 0: disabled, 1: enabled (default) + linkedData -> include linked data with disambiguated entities. 0: disabled, 1: enabled (default). + coreference -> resolve entity coreferences. 0: disabled, 1: enabled (default)
+ showSourceText -> 0: disabled (default), 1: enabled. + maxRetrieve -> the maximum number of relations to extract (default: 50, max: 100), (*47)

Feeds

Detects the RSS/ATOM feeds for a URL or HTML. For more information, please refer to the overview or the docs., (*48)

    $emotions = Alchemy::feeds($flavor, $data, $options);

Available flavors: + 'html' + 'url', (*49)

Available options: + none, (*50)

Microformats

Extracts the microformats for a URL or HTML. For more information, please refer to the overview or the docs., (*51)

    $emotions = Alchemy::microformats($flavor, $data, $options);

Available flavors: + 'html' + 'url', (*52)

Available options: + none, (*53)

Taxonomy

Taxonomy classification operations for text, a URL or HTML. For more information, please refer to the overview or the docs., (*54)

    $emotions = Alchemy::taxonomy($flavor, $data, $options);

Available flavors: + 'text' + 'html' + 'url', (*55)

Available options: + showSourceText -> include the original 'source text' the taxonomy categories were extracted from within the API response. 1: enabled, 0: disabled (default) + sourceText -> where to obtain the text that will be processed by this API call. --* cleaned_or_raw : cleaning enabled, fallback to raw when cleaning produces no text (default) --* cleaned : operate on 'cleaned' web page text (web page cleaning enabled) --* raw : operate on raw web page text (web page cleaning disabled) --* cquery : operate on the results of a visual constraints query. Note: The 'cquery' http argument must also be set to a valid visual constraints query. --* xpath : operate on the results of an XPath query. Note: The 'xpath' http argument must also be set to a valid XPath query. + cquery -> a visual constraints query to apply to the web page. + xpath -> an XPath query to apply to the web page. + baseUrl -> rel-tag output base http url (must be uri-argument encoded), (*56)

Combined Calls

Combined call for entity, keyword, title, author, taxonomy. For more information, please refer to the overview or the docs., (*57)

    $emotions = Alchemy::combined($flavor, $data, $options);

Available flavors: + 'text' + 'html' + 'url', (*58)

Available options: + extract -> Possible values: entity, keyword, title, author, taxonomy (default: entity, keyword, taxonomy, concept) + disambiguate -> disambiguate detected entities. 1: enabled (default), 0: disabled + linkedData -> include Linked Data content links with disambiguated entities. 1: enabled (default), 0: disabled + coreference -> resolve he/she/etc coreferences into detected entities. 1: enabled (default), 0: disabled + quotations -> enable quotations extraction. 1: enabled, 0: disabled (default) + sentiment ->enable entity-level sentiment analysis. 1: enabled, 0: disabled (default) + showSourceText -> include the original 'source text' the entities were extracted from within the API response. 1: enabled, 0: disabled (default) + maxRetrieve -> maximum number of named entities to extract. default : 50 + baseUrl -> rel-tag output base http url, (*59)

The Versions

13/02 2017

dev-master

9999999-dev

Package for Laravel integration with Alchemy API

  Sources   Download

MIT

by Avatar lexismith