本文整理汇总了PHP中CSearch::RegisterStem方法的典型用法代码示例。如果您正苦于以下问题:PHP CSearch::RegisterStem方法的具体用法?PHP CSearch::RegisterStem怎么用?PHP CSearch::RegisterStem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSearch
的用法示例。
在下文中一共展示了CSearch::RegisterStem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: StemIndex
function StemIndex($arLID, $ID, $sContent)
{
$DB = CDatabase::GetModuleConnection('search');
static $CACHE_SITE_LANGS = array();
$ID = intval($ID);
$arLang = array();
if (!is_array($arLID)) {
$arLID = array();
}
foreach ($arLID as $site => $url) {
if (!array_key_exists($site, $CACHE_SITE_LANGS)) {
$db_site_tmp = CSite::GetByID($site);
if ($ar_site_tmp = $db_site_tmp->Fetch()) {
$CACHE_SITE_LANGS[$site] = array("LANGUAGE_ID" => $ar_site_tmp["LANGUAGE_ID"], "CHARSET" => $ar_site_tmp["CHARSET"], "SERVER_NAME" => $ar_site_tmp["SERVER_NAME"]);
} else {
$CACHE_SITE_LANGS[$site] = false;
}
}
if (is_array($CACHE_SITE_LANGS[$site])) {
$arLang[$CACHE_SITE_LANGS[$site]["LANGUAGE_ID"]] = true;
}
}
foreach ($arLang as $lang => $value) {
$sql_lang = $DB->ForSql($lang);
$arDoc = stemming($sContent, $lang);
$docLength = array_sum($arDoc);
if (BX_SEARCH_VERSION > 1) {
$arPos = stemming($sContent, $lang, false, true);
CSearch::RegisterStem($arDoc);
}
if ($docLength > 0) {
$doc = "";
$logDocLength = log($docLength < 20 ? 20 : $docLength);
$strSqlPrefix = "\n\t\t\t\t\t\tinsert ignore into b_search_content_stem\n\t\t\t\t\t\t(SEARCH_CONTENT_ID, LANGUAGE_ID, STEM, TF" . (BX_SEARCH_VERSION > 1 ? ",PS" : "") . ")\n\t\t\t\t\t\tvalues\n\t\t\t\t";
$maxValuesLen = 2048;
$strSqlValues = "";
if (BX_SEARCH_VERSION > 1) {
foreach ($arDoc as $word => $count) {
$stem_id = CSearch::RegisterStem($word);
//This is almost impossible, but happens
if ($stem_id > 0) {
$strSqlValues .= ",\n(" . $ID . ", '" . $sql_lang . "'" . ", " . CSearch::RegisterStem($word) . ", " . number_format(log($count + 1) / $logDocLength, 4, ".", "") . ", " . number_format($arPos[$word] / $count, 4, ".", "") . ")";
}
if (strlen($strSqlValues) > $maxValuesLen) {
$DB->Query($strSqlPrefix . substr($strSqlValues, 2), false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$strSqlValues = "";
}
}
} else {
foreach ($arDoc as $word => $count) {
$strSqlValues .= ",\n(" . $ID . ", '" . $sql_lang . "'" . ", '" . $DB->ForSQL($word) . "'" . ", " . number_format(log($count + 1) / $logDocLength, 4, ".", "") . ")";
if (strlen($strSqlValues) > $maxValuesLen) {
$DB->Query($strSqlPrefix . substr($strSqlValues, 2), false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$strSqlValues = "";
}
}
}
if (strlen($strSqlValues) > 0) {
$DB->Query($strSqlPrefix . substr($strSqlValues, 2), false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$strSqlValues = "";
}
}
}
}