ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilLuceneHighlighterResultParser Class Reference

Parses result XML from lucene search highlight. More...

+ Collaboration diagram for ilLuceneHighlighterResultParser:

Public Member Functions

 __construct ()
 Contructor. More...
 
 getMaxScore ()
 
 setMaxScore ($a_score)
 
 getRelevance ($a_obj_id, $sub_id)
 get relevance More...
 
 setResultString ($a_res)
 set result xml string More...
 
 getResultString ()
 get result xml string More...
 
 parse ()
 parse More...
 
 getTitle ($a_obj_id, $a_sub_id)
 get title More...
 
 getDescription ($a_obj_id, $a_sub_id)
 get description More...
 
 getContent ($a_obj_id, $a_sub_id)
 get content More...
 
 getSubItemIds ($a_obj_id)
 get subitem ids More...
 

Private Attributes

 $result_string = ''
 
 $result = array()
 
 $max_score = 0
 

Detailed Description

Parses result XML from lucene search highlight.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 34 of file class.ilLuceneHighlighterResultParser.php.

Constructor & Destructor Documentation

◆ __construct()

ilLuceneHighlighterResultParser::__construct ( )

Contructor.

Returns

Definition at line 48 of file class.ilLuceneHighlighterResultParser.php.

49  {
50  }

Member Function Documentation

◆ getContent()

ilLuceneHighlighterResultParser::getContent (   $a_obj_id,
  $a_sub_id 
)

get content

Parameters
intobj_id
intsub_item
Returns

Definition at line 165 of file class.ilLuceneHighlighterResultParser.php.

166  {
167  return isset($this->result[$a_obj_id][$a_sub_id]['content']) ? $this->result[$a_obj_id][$a_sub_id]['content'] : null;
168  }

◆ getDescription()

ilLuceneHighlighterResultParser::getDescription (   $a_obj_id,
  $a_sub_id 
)

get description

Parameters
intobj_id
intsub_item
Returns

Definition at line 154 of file class.ilLuceneHighlighterResultParser.php.

155  {
156  return isset($this->result[$a_obj_id][$a_sub_id]['description']) ? $this->result[$a_obj_id][$a_sub_id]['description'] : null;
157  }

◆ getMaxScore()

ilLuceneHighlighterResultParser::getMaxScore ( )

Definition at line 53 of file class.ilLuceneHighlighterResultParser.php.

References $max_score.

Referenced by getRelevance().

+ Here is the caller graph for this function:

◆ getRelevance()

ilLuceneHighlighterResultParser::getRelevance (   $a_obj_id,
  $sub_id 
)

get relevance

Parameters
intobj_id
Returns
int relevance in percent

Definition at line 68 of file class.ilLuceneHighlighterResultParser.php.

References getMaxScore().

69  {
70  if (!$this->getMaxScore()) {
71  return 0;
72  }
73 
74  $score = $this->result[$a_obj_id][$sub_id]['score'];
75  return $score / $this->getMaxScore() * 100;
76  }
+ Here is the call graph for this function:

◆ getResultString()

ilLuceneHighlighterResultParser::getResultString ( )

get result xml string

Parameters

Definition at line 95 of file class.ilLuceneHighlighterResultParser.php.

References $result_string.

Referenced by parse().

+ Here is the caller graph for this function:

◆ getSubItemIds()

ilLuceneHighlighterResultParser::getSubItemIds (   $a_obj_id)

get subitem ids

Parameters

Definition at line 175 of file class.ilLuceneHighlighterResultParser.php.

References $data, and array.

176  {
177  $sub_item_ids = array();
178  if (!isset($this->result[$a_obj_id])) {
179  return array();
180  }
181  foreach ($this->result[$a_obj_id] as $sub_item_id => $data) {
182  if ($sub_item_id) {
183  $sub_item_ids[] = $sub_item_id;
184  }
185  }
186  return $sub_item_ids ? $sub_item_ids : array();
187  }
Create styles array
The data for the language used.

◆ getTitle()

ilLuceneHighlighterResultParser::getTitle (   $a_obj_id,
  $a_sub_id 
)

get title

Parameters
intobj_id
intsub_item
Returns

Definition at line 143 of file class.ilLuceneHighlighterResultParser.php.

144  {
145  return isset($this->result[$a_obj_id][$a_sub_id]['title']) ? $this->result[$a_obj_id][$a_sub_id]['title'] : null;
146  }

◆ parse()

ilLuceneHighlighterResultParser::parse ( )

parse

Returns

Definition at line 104 of file class.ilLuceneHighlighterResultParser.php.

References $name, ilLoggerFactory\getLogger(), getResultString(), setMaxScore(), and string.

105  {
106  if (!strlen($this->getResultString())) {
107  return false;
108  }
109  ilLoggerFactory::getLogger('src')->debug($this->getResultString());
110  $root = new SimpleXMLElement($this->getResultString());
111 
112  // begin-patch mime_filter
113  $this->setMaxScore((string) $root['maxScore']);
114  // end-patch mime_filter
115 
116 
117  foreach ($root->children() as $object) {
118  $obj_id = (string) $object['id'];
119  foreach ($object->children() as $item) {
120  $sub_id = (string) $item['id'];
121 
122  // begin-patch mime_filter
123  $score = (string) $item['absoluteScore'];
124  $this->result[$obj_id][$sub_id]['score'] = $score;
125  // end-patch mime_filter
126 
127  foreach ($item->children() as $field) {
128  $name = (string) $field['name'];
129  $this->result[$obj_id][$sub_id][$name] = (string) $field;
130  }
131  }
132  }
133 
134  return true;
135  }
Add rich text string
if($format !==null) $name
Definition: metadata.php:146
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

◆ setMaxScore()

ilLuceneHighlighterResultParser::setMaxScore (   $a_score)

Definition at line 58 of file class.ilLuceneHighlighterResultParser.php.

Referenced by parse().

59  {
60  $this->max_score = $a_score;
61  }
+ Here is the caller graph for this function:

◆ setResultString()

ilLuceneHighlighterResultParser::setResultString (   $a_res)

set result xml string

Parameters

Definition at line 85 of file class.ilLuceneHighlighterResultParser.php.

86  {
87  $this->result_string = $a_res;
88  }

Field Documentation

◆ $max_score

ilLuceneHighlighterResultParser::$max_score = 0
private

Definition at line 40 of file class.ilLuceneHighlighterResultParser.php.

Referenced by getMaxScore().

◆ $result

ilLuceneHighlighterResultParser::$result = array()
private

Definition at line 37 of file class.ilLuceneHighlighterResultParser.php.

◆ $result_string

ilLuceneHighlighterResultParser::$result_string = ''
private

Definition at line 36 of file class.ilLuceneHighlighterResultParser.php.

Referenced by getResultString().


The documentation for this class was generated from the following file: