Download the PHP package bredmor/comment-analyzer without Composer

On this page you can find all versions of the php package bredmor/comment-analyzer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package comment-analyzer

CommentAnalyzer

CommentAnalyzer is an API Wrapper for the Google Perspective Comment Analyzer API

This package enables you to programmatically scan any kind of text written in supported languages for various metrics associated with negative tones and apply the resulting score, such as automatically hiding harassing or explicit comments from a blog or social media platform.

Installation / Usage

From Source:

Clone the repository from GitHub or unzip into your vendor directory. CommentAnalyzer is packaged for PSR-4 autoloading.

From Composer:

composer require bredmor/comment-analyzer

Basic Usage:

CommentAnalyzer accepts text in the form of Comment objects that are constructed with a single argument - the text you wish to analyze.

Instantiate the Analyzer object, providing it your Perspective API key and an optional PSR-3 compliant LoggerInterface. Then add the attribute models you wish to score comments on by calling the instance's addAttributeModel() method. Note: You must provide at least one attribute model for scoring before calling the analyze() method or an AnalyzerException will be thrown.

Pass an instance of a Comment object to the Analyzer object's analyze method. This will start the API call process.

Note: If you wish to use this library in an asynchronus manner, the Comment object holds a state variable of STATE_CREATED, STATE_SUBMITTED and STATE_ANALYZED. You can check for the instance's current state via its getState() method, to ensure you aren't trying to process the same comment via multiple threads.

After successfully completing the call, the Comment object, which is passed by reference, will be filled out with SummaryScore and SpanScore objects representing the summary and span scores data returned by the API, respectively. These objects are accessed by calling the Comment object's getSummaryScore() or getSpanScore() methods with one required argument - one of the attribute models you provided to the Analyzer instance.

Example:

This example code should output something like:

Other examples can be found in the /tests directory.

Please see the Perspective API Documentation for full reference on available attribute models and score meanings.

Error Handling

Every part of the library that relies on input or proper function use will throw a CommentException or AnalyzerException as appropriate when an error is encountered.

The Analyzer object accepts an optional PSR-3 compliant LoggerInterface, which logs a critical error when the API is unreachable or responds with a non-200 HTTP error code.

API Support

CommentAnalyzer supports the following features of the Perspective API:

Requirements

CommentAnalyzer version 3.x is tested on PHP 8.0 and later.

Authors

Contributing

Pull requests, bug reports and feature requests are welcome.

If you add a new feature, or change an existing feature that does not yet have a test - please add one in your PR!

Testing

Testing is handled via PHPUnit.

You can run all current tests with composer run test.

License

CommentAnalyzer is licensed under the MIT License - see the LICENSE file for details


All versions of comment-analyzer with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
guzzlehttp/guzzle Version ~7.4.4
psr/log Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package bredmor/comment-analyzer contains the following files

Loading the files please wait ....