1
0
Fork 0

Now the third most likely languages are shown.

In "vier" the tag line is now suppressed. It saves a little bit of space - and is redundant.
This commit is contained in:
Michael Vogel 2013-01-09 20:54:18 +01:00
parent 348f43157a
commit 82820d8e95
4 changed files with 58 additions and 6 deletions

View file

@ -898,8 +898,23 @@ function item_store($arr,$force_parent = false) {
require_once('library/langdet/Text/LanguageDetect.php');
$naked_body = preg_replace('/\[(.+?)\]/','',$arr['body']);
$l = new Text_LanguageDetect;
$lng = $l->detectConfidence($naked_body);
$arr['postopts'] = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : '');
//$lng = $l->detectConfidence($naked_body);
//$arr['postopts'] = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : '');
$lng = $l->detect($naked_body, 3);
if (sizeof($lng) > 0) {
$postopts = "";
foreach ($lng as $language => $score) {
if ($postopts == "")
$postopts = "lang=";
else
$postopts .= ":";
$postopts .= $language.";".$score;
}
$arr['postopts'] = $postopts;
}
}
$arr['wall'] = ((x($arr,'wall')) ? intval($arr['wall']) : 0);

View file

@ -236,9 +236,23 @@ function item_post(&$a) {
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
$l = new Text_LanguageDetect;
$lng = $l->detectConfidence($naked_body);
//$lng = $l->detectConfidence($naked_body);
//$postopts = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : '');
$postopts = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : '');
$lng = $l->detect($naked_body, 3);
if (sizeof($lng) > 0) {
$postopts = "";
foreach ($lng as $language => $score) {
if ($postopts == "")
$postopts = "lang=";
else
$postopts .= ":";
$postopts .= $language.";".$score;
}
}
logger('mod_item: detect language' . print_r($lng,true) . $naked_body, LOGGER_DATA);
}

View file

@ -213,8 +213,28 @@ class Item extends BaseObject {
localize_item($item);
if ($item["postopts"]) {
$langdata = explode(";", $item["postopts"]);
$langstr = substr($langdata[0], 5)." (".round($langdata[1]*100, 1)."%)";
//$langdata = explode(";", $item["postopts"]);
//$langstr = substr($langdata[0], 5)." (".round($langdata[1]*100, 1)."%)";
$langstr = "";
if (substr($item["postopts"], 0, 5) == "lang=") {
$postopts = substr($item["postopts"], 5);
$languages = explode(":", $postopts);
if (sizeof($languages) == 1) {
$languages = array();
$languages[] = $postopts;
}
foreach ($languages as $language) {
$langdata = explode(";", $language);
if ($langstr != "")
$langstr .= ", ";
//$langstr .= $langdata[0]." (".round($langdata[1]*100, 1)."%)";
$langstr .= round($langdata[1]*100, 1)."% ".$langdata[0];
}
}
}
$body = prepare_body($item,true);

View file

@ -1091,6 +1091,7 @@ border-bottom: 1px solid #D2D2D2;
max-width: 660px;
word-wrap: break-word;
line-height: 1.36;
padding-bottom: 6px;
}
.wall-item-container .wall-item-content img {
@ -1304,7 +1305,9 @@ border-bottom: 1px solid #D2D2D2;
.wall-item-tags {
padding-top: 1px;
padding-bottom: 2px;
display: none;
}
.tag {
color: rgb(153,153,153);
padding-left: 3px;