guid = $guid; $this->type = $type; } function add_term($guid, $subject, $relevance = 0.0) { $this->terms[$guid] = new CalaisTerm($guid, $subject, $relevance); } function add_relevance($guid, $relevance) { if ($this->has_guid($guid)) { $this->terms[$guid]->relevance = $relevance; } } function has_guid($guid) { return array_key_exists($guid, $this->terms); } function has_term_value($value) { foreach ($this->terms as $term) { if ($term->value == $value) { return TRUE; } } return FALSE; } function remove_term_by_name($name) { $filter = new TermFilter($name); $this->terms = array_filter($this->terms, array($filter, 'filter')); } function readable_type() { return calais_api_make_readable($this->type); } } class TermFilter { public $filter; function __construct($filter) { $this->filter = $filter; } function filter($term) { return $term->value != $this->filter; } } /** * This class represents a specific term result from the Calais Web Service. */ class CalaisTerm { public $guid; public $value; public $relevance; /** * */ function __construct($guid, $value, $relevance = 0.0) { $this->guid = $guid; $this->value = $value; $this->relevance = $relevance; } }