]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #3743 from MrPetovan/task/update-languagedetect
authorTobias Diekershoff <tobias.diekershoff@gmx.net>
Thu, 5 Oct 2017 08:49:17 +0000 (08:49 +0000)
committerGitHub <noreply@github.com>
Thu, 5 Oct 2017 08:49:17 +0000 (08:49 +0000)
Update languagedetect library

1  2 
include/items.php

diff --combined include/items.php
index 6945f8894d2819f0e98d461089e049e6d04441d8,946b285f8178c1b0026dd7a91f39cc6abdf7b983..35e01cbc747ea8efeec031379b85a77bef6d0d14
@@@ -364,13 -364,9 +364,9 @@@ function item_add_language_opt(&$arr) 
                $postopts = "";
        }
  
-       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->detect($naked_body, 3);
+       $LanguageDetect = new Text_LanguageDetect();
+       $lng = $LanguageDetect->detect($naked_body, 3);
  
        if (sizeof($lng) > 0) {
                if ($postopts != "") $postopts .= '&'; // arbitrary separator, to be reviewed
@@@ -397,24 -393,15 +393,24 @@@ function uri_to_guid($uri, $host = "") 
        // We have to avoid that different routines could accidentally create the same value
        $parsed = parse_url($uri);
  
 +      // When the hostname isn't given, we take it from the uri
        if ($host == "") {
 -              $host = $parsed["host"];
 +              // Is it in the format data@host.tld?
 +              if ((count($parsed) == 1) && strstr($uri, '@')) {
 +                      $mailparts = explode('@', $uri);
 +                      $host = array_pop($mailparts);
 +              } else {
 +                      $host = $parsed["host"];
 +              }
        }
  
 +      // We use a hash of the hostname as prefix for the guid
        $guid_prefix = hash("crc32", $host);
  
        // Remove the scheme to make sure that "https" and "http" doesn't make a difference
        unset($parsed["scheme"]);
  
 +      // Glue it together to be able to make a hash from it
        $host_id = implode("/", $parsed);
  
        // We could use any hash algorithm since it isn't a security issue