TermFrequency
This object is optionally provided as property of a result set.
It allows to refine the related result set using as constraints one or more term frequency items
related to a term frequency target.
The available term frequency targets are:
- keyword: frequency at which the keyword field items appear in a node report
- format: frequency at which the format field items appear in a node report
- protocol: frequency at which the protocol field items appear in a node report
- source: frequency at which the nodes of the result set own to a source
// creates a new DAB instance with the given endpoint
var dab = GIAPI.DAB('https://api.geodab.eu/dab');
// set to true after the first refinement
var refined = false;
// defines discover response callback function
var onResponse = function(response){
var resultSet = response[0];
// retrieves the TermFrequency object
var tf = resultSet.termFrequency;
// retrieves the term frequency items of
// all the available term frequency targets
var kwdTerms = tf.items('keyword');
var frmTerms = tf.items('format');
var proTerms = tf.items('protocol');
var srcTerms = tf.items('source');
if(refined){// exit
return;
}
// checks the first term of the keyword target
tf.checkItems('keyword',[ kwdTerms[0] ]);
// refines the discover; the new result set contains only
// nodes matching the first term of the keyword target
tf.refine();
refined = true;
};
// setting the termFrequency option
var options = {
"termFrequency": "keyword,format,protocol,source"
};
// starts discover
dab.discover(onResponse, options);
This API provides a widget which allows to refine the discover
using check boxes to select the term frequency items.
See also TermFrequencyWidget
Item Index
Methods
checkedItems
-
target
Return an array of all the checked term frequency items related to the
given term frequency target
.
See also checkItems method
Parameters:
-
target
Stringa term frequency target. Available targets are:
- keyword
- format
- source
- protocol
Returns:
array of checked term frequency items
checkItems
-
target
-
targetItems
Checks the term frequency items of the given term frequency target
.
Once the items are checked,
the refine method is ready to be called.
See also refine method
Parameters:
-
target
String -
targetItems
TermFrequencyItem[]
clearCheckedItems
-
target
Clear all the checked term frequency items related to the
given term frequency target
.
See also checkItems method
Parameters:
-
target
Stringa term frequency target. Available targets are:
- keyword
- format
- source
- protocol
isCheckedItem
-
target
-
item
Return true
if the given term frequency items related to the
given term frequency target
is checked.
See also checkItems method
Parameters:
-
target
Stringa term frequency target. Available targets are:
- keyword
- format
- source
- protocol
-
item
TermFrequencyItemthe term frequency item to check
items
-
target
Returns an array of all the available term frequency items related to the
given target
Parameters:
-
target
Stringa term frequency target. Available targets are:
- keyword
- format
- source
- protocol
Returns:
array of all the available term frequency items related to the
given target
itemsCount
-
target
Returns the number of all the available term frequency items
related to the given target
Parameters:
-
target
Stringa term frequency target. Available targets are:
- keyword
- format
- source
- protocol
Returns:
the number of all the available term frequency items
related to the given target
refine
()
Refines the related result set by adding constraints basing on the
currently checked term frequency items.
See also checkItems method.
See also items method
targets
()
String[]
Return an array of all the available term frequency targets. Available targets are:
- keyword
- format
- source
- protocol
See also termFrequency option
Returns:
array of all the available term frequency targets
targetsCount
()
Integer
Returns the number of all the available term frequency targets.
See also targets method
Returns:
the number of all the available term frequency targets