Download the PHP package survos/classifier-bundle without Composer

On this page you can find all versions of the php package survos/classifier-bundle. 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 classifier-bundle

survos/classifier-bundle

Assign controlled labels to text. One set of vocabularies, several interchangeable ways of assigning from them, and a benchmark that scores those ways against labeled data.

Every assignment records the strategy that made it. Assignments made by an editor are never replaced or removed. A strategy that can't tell abstains instead of guessing.

Install

No configuration is needed for the rules strategies. For Jev, see Jev. For IPTC Media Topics, composer require survos/media-topics (or survos/media-topics-bundle, whose vocabulary instance is then shared).

Vocabularies

name shape source
media_topics tree, 1,085 topics under 17 roots IPTC Media Topics, from survos/media-topics; registered only when that package is installed
country tree, 249 countries under 6 regions names from symfony/intl, grouped by UN M49 region
us_metro flat, 393 areas Census Bureau metropolitan statistical areas, July 2023

Add your own by registering a service that implements VocabularyInterface; it is tagged automatically. ArrayVocabulary::fromRows() builds one from plain rows, which is the easy way to expose an app's tag table:

Row keys: code, label, definition, parent, triggerTerms, properNouns, exceptions, regularExpressions.

Strategies

name how it decides
rules trigger terms, proper nouns and regular expressions in the headline and summary
rules_headline the same rules, headline only
tag_vote maps labels the document already carries in another vocabulary; the single most-voted concept wins, a tie abstains. Not registered by default: define a TagVoteStrategy service with your code map
jev TypeSafe's Jev model; registered only when symfony/ai-type-safe-platform is installed

Rules

Terms match whole words. A term containing an uppercase letter is case-sensitive (NE matches "Omaha, NE", not "the northeast"); proper nouns always are.

Exceptions are phrases that contain a trigger without meaning it. They are blanked out of the text before matching, so with the trigger tobacco and the exception Alcohol, Tobacco and Firearms, a story about an ATF gun raid is not labeled tobacco, but an ATF story that also mentions smuggled tobacco is. In triggerTerms, a leading ! marks an exception.

Scores, and rules that settle it

A concept can carry structured rules beside its term lists (rules in ArrayVocabulary::fromRows(), or RuleSet::fromRules()). Matches add to a score; the concept is assigned when the total reaches its threshold (default 1).

Options per rule: score (default 1, may be negative), scope (headline, summary or body; default is what the strategy reads), case (default: case-sensitive iff the term has a capital), word (whole words, default true). meta rules test Document::$metadata, which is whatever the caller already knows about the item (host, source, marking, tag ids ...); a list value matches if it contains the value. An accept rule, in text or metadata, assigns the concept with Assignment::$decisive = true and stops evaluating it; reject withholds it. Decisive rules are checked before any score is added, wherever they appear in the list.

The older term syntax still works: term! is worth 100, term!! accepts outright, !term is an exception.

Jev (optional)

Set TYPESAFE_API_KEY, or point the bundle at a platform you already configured:

Two modes, chosen per vocabulary:

The default threshold of 0.5 assigns far too many labels. Tune it on your own labeled data with the benchmark below; cached responses make rerunning at another threshold free.

Commands

All three take --format=json. The first two are also agent tools when survos/command-bundle is installed.

Benchmark

classifier:benchmark <file> <vocabulary> runs every strategy over labeled documents, one JSON object per line:

--concepts=tags.jsonl loads the vocabulary from a file of rows (the keys above, plus vocabulary) instead of the registry. Other options: --strategy, --limit, --per-concept, --price (US dollars per million input tokens, default 0.042).

Per strategy it reports true and false positives, false negatives, precision, recall and F1 over the documents the strategy answered; abstentions separately, with the gold labels they left unassigned; milliseconds per document; and for Jev, requests, input tokens and cost. For trees it also counts documents where the prediction is on the same branch as a gold label.

In code

Development

DESIGN.md has the design notes and the first measurements against a news archive.


All versions of classifier-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
survos/jsonl-bundle Version ^2.5
survos/kit-bundle Version ^2.5
symfony/config Version ^8.1
symfony/console Version ^8.1
symfony/dependency-injection Version ^8.1
symfony/framework-bundle Version ^8.1
symfony/http-kernel Version ^8.1
symfony/intl Version ^8.1
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 survos/classifier-bundle contains the following files

Loading the files please wait ...