ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
51  }

Member Function Documentation

◆ getContent()

ilLuceneHighlighterResultParser::getContent (   $a_obj_id,
  $a_sub_id 
)

get content

Parameters
intobj_id
intsub_item
Returns

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

172  {
173  return isset($this->result[$a_obj_id][$a_sub_id]['content']) ? $this->result[$a_obj_id][$a_sub_id]['content'] : null;
174  }

◆ getDescription()

ilLuceneHighlighterResultParser::getDescription (   $a_obj_id,
  $a_sub_id 
)

get description

Parameters
intobj_id
intsub_item
Returns

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

161  {
162  return isset($this->result[$a_obj_id][$a_sub_id]['description']) ? $this->result[$a_obj_id][$a_sub_id]['description'] : null;
163  }

◆ getMaxScore()

ilLuceneHighlighterResultParser::getMaxScore ( )

Definition at line 54 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 69 of file class.ilLuceneHighlighterResultParser.php.

References getMaxScore().

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

◆ getResultString()

ilLuceneHighlighterResultParser::getResultString ( )

get result xml string

Parameters

Definition at line 97 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 181 of file class.ilLuceneHighlighterResultParser.php.

References $data, and array.

182  {
183  $sub_item_ids = array();
184  if(!isset($this->result[$a_obj_id]))
185  {
186  return array();
187  }
188  foreach($this->result[$a_obj_id] as $sub_item_id => $data)
189  {
190  if($sub_item_id)
191  {
192  $sub_item_ids[] = $sub_item_id;
193  }
194  }
195  return $sub_item_ids ? $sub_item_ids : array();
196  }
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 149 of file class.ilLuceneHighlighterResultParser.php.

150  {
151  return isset($this->result[$a_obj_id][$a_sub_id]['title']) ? $this->result[$a_obj_id][$a_sub_id]['title'] : null;
152  }

◆ parse()

ilLuceneHighlighterResultParser::parse ( )

parse

Returns

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

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

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

◆ setMaxScore()

ilLuceneHighlighterResultParser::setMaxScore (   $a_score)

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

Referenced by parse().

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

◆ setResultString()

ilLuceneHighlighterResultParser::setResultString (   $a_res)

set result xml string

Parameters

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

88  {
89  $this->result_string = $a_res;
90  }

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: