Permalink
Browse files

Merge branch 'master' of github.com:lstrojny/php-cld

  • Loading branch information...
lstrojny committed May 29, 2012
2 parents 83d3a96 + e5b4253 commit 5763c1ffb5977a84c292906310f83b1eb9b2fe24
Showing with 7 additions and 5 deletions.
  1. +6 −4 cld.cc
  2. +1 −1 package.xml
View
10 cld.cc
@@ -147,7 +147,7 @@ PHPAPI int cld_detect_language(zval **result, char *text, int text_len, int is_p
char *language_name;
- double normalized_score;
+ double normalized_scores[3];
zval *detail;
@@ -179,7 +179,7 @@ PHPAPI int cld_detect_language(zval **result, char *text, int text_len, int is_p
CompactLangDet::DetectLanguage(0, text, text_len, is_plain_text,
include_extended_languages, 1, 0, top_level_domain_hint, encoding_hint,
- language_hint, languages, percentages, &normalized_score, &bytes, &reliable);
+ language_hint, languages, percentages, normalized_scores, &bytes, &reliable);
array_init(*result);
@@ -200,6 +200,8 @@ PHPAPI int cld_detect_language(zval **result, char *text, int text_len, int is_p
add_assoc_string(detail, "code", (char *)ExtLanguageCode(language), 1);
add_assoc_bool(detail, "reliable", reliable);
add_assoc_long(detail, "bytes", bytes);
+ add_assoc_double(detail, "score", normalized_scores[i]);
+ add_assoc_long(detail, "percent", percentages[i]);
add_next_index_zval(*result, detail);
}
@@ -314,8 +316,8 @@ PHP_FUNCTION(cld_detect)
{
int is_plain_text = 1,
include_extended_languages = 1,
- top_level_domain_hint_len,
- language_hint_name_len,
+ top_level_domain_hint_len = 0,
+ language_hint_name_len = 0,
text_len;
long encoding_hint = -1;
View
@@ -20,7 +20,7 @@
</stability>
<license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
<notes>
-- ???
+- CLD\detect() and CLD\Detector::detectLanguage() now return scores and percentages (Arnaud Le Blanc)
</notes>
<contents>
<dir name="/">

0 comments on commit 5763c1f

Please sign in to comment.