Debug scoring of question answer code, a=chris
Debug scoring of question answer code, a=chris
diff --git a/src/models/PhraseModel.php b/src/models/PhraseModel.php
index 57185efee..bbe43fe66 100755
--- a/src/models/PhraseModel.php
+++ b/src/models/PhraseModel.php
@@ -103,7 +103,7 @@ class PhraseModel extends ParallelModel
*/
public function indexExists($index_time_stamp)
{
- return file_exists(C\CRAWL_DIR.'/cache/IndexData'.$index_time_stamp);
+ return file_exists(C\CRAWL_DIR.'/cache/IndexData'. $index_time_stamp);
}
/**
* Rewrites a mix query so that it maps directly to a query about crawls
@@ -384,6 +384,8 @@ class PhraseModel extends ParallelModel
}
$disjunct_phrases = explode("|", $phrase);
}
+ $this->query_info['QUERY'] .=
+ "$in2<b>Guessed Semantics</b>:<br/>$in2$phrase<br />";
if (!$network) {
foreach ($disjunct_phrases as $disjunct) {
if (C\QUERY_STATISTICS) {
@@ -457,9 +459,8 @@ class PhraseModel extends ParallelModel
$triplets_with_answer[$question];
if (array_key_exists(
$answer, $answer_score_map)) {
- $new_score =
- $answer_score_map[$answer]
- + $out_results['PAGES'][
+ $answer_score_map[$answer] +=
+ $out_results['PAGES'][
$out_count][self::SCORE];
} else {
$answer_score_map[$answer] =
@@ -570,7 +571,7 @@ class PhraseModel extends ParallelModel
* phrases, the weight that should be put on these query results, and
* which archive to use.
*
- * @param strin g&$phrase string to extract struct from, if the phrase
+ * @param string &$phrase string to extract struct from, if the phrase
* semantics is guessed or an if condition is processed the value of
* phrase will be altered. (Helps for feeding to network queries)
* @return array struct representing the conjunctive query
@@ -941,6 +942,7 @@ class PhraseModel extends ParallelModel
}
}
}
+ $is_question = false;
if (!empty($tokenizer) && method_exists($tokenizer, "isQuestion") &&
method_exists($tokenizer, "questionParser") &&
$tokenizer->isQuestion($phrase)) {
@@ -951,13 +953,17 @@ class PhraseModel extends ParallelModel
} else if (!empty($generated_question['RAW'])) {
$phrase = implode("|", $generated_question['RAW']);
}
+ $is_question = true;
}
+ $is_question_delim = "";
if ($len > 0 && !preg_match("/site\:\S{5}|info\:|path\:|ip\:/",
$phrase)) {
if (!preg_match("/safe\:/", $phrase)) {
- $phrase .= " " . ((!isset($_SESSION['SAFE_SEARCH']) ||
+ $safe_term = " " .((!isset($_SESSION['SAFE_SEARCH']) ||
$_SESSION['SAFE_SEARCH'] == "true") ? "safe:true" :
"safe:all") . " ";
+ $phrase .= $safe_term;
+ $is_question_delim .= $safe_term;
}
if (!preg_match("/date\:/", $phrase) &&
!empty($_SESSION['TIME_PERIOD_SELECTED']) &&
@@ -974,7 +980,12 @@ class PhraseModel extends ParallelModel
$phrase = preg_replace("/date\:year/",
"date:" . date('Y', $time), $phrase);
if (!preg_match("/media\:image|lang\:/", $phrase)) {
- $phrase .= " " . "lang:" . $main_tag . " ";
+ $lang_term = " " . "lang:" . $main_tag . " ";
+ $phrase .= $lang_term;
+ $is_question_delim .= $lang_term;
+ }
+ if ($is_question) {
+ $phrase = str_replace("|", " $is_question_delim | ", $phrase);
}
if (preg_match("/media\:video/", $phrase)) {
if (!empty($_SESSION['VIDEO_MIN_DURATION'])) {