Oihana PHP Arango

tfidf.php

Table of Contents

Functions

tfidf()  : string
Score documents with the term frequency–inverse document frequency algorithm (TF-IDF).

Functions

tfidf()

Score documents with the term frequency–inverse document frequency algorithm (TF-IDF).

tfidf(string $doc[, bool|null $normalize = null ]) : string

Wraps the ArangoDB AQL scoring function TFIDF(doc, normalize). The first argument must be the document variable emitted by a FOR … IN viewName operation, and the function can only be used together with a SEARCH. Sort descending by the score to get the most relevant documents first.

Example AQL usage:

FOR doc IN viewName
  SEARCH ...
  SORT TFIDF(doc) DESC
  RETURN doc
Parameters
$doc : string

The document variable emitted by FOR … IN viewName (kept raw).

$normalize : bool|null = null

Optional — whether to normalize the score (server default false).

Tags
example
use function oihana\arango\db\functions\search\tfidf;

echo tfidf( 'doc' ) ;        // 'TFIDF(doc)'
echo tfidf( 'doc' , true ) ; // 'TFIDF(doc,true)'
see
https://docs.arangodb.com/stable/aql/functions/arangosearch/#tfidf
bm25()
since
1.2.0
author

Marc Alcaraz

Return values
string

The formatted AQL expression.

On this page

Search results