-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from stevenay/master
PHP: Add user guide and demo.
- Loading branch information
Showing
3 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
// include autoload | ||
$autoload = join(DIRECTORY_SEPARATOR, [__DIR__, "vendor", "autoload.php"]); | ||
if (!file_exists($autoload)) | ||
exit("Need Composer!"); | ||
require $autoload; | ||
|
||
use Googlei18n\MyanmarTools\ZawgyiDetector; | ||
|
||
$detector = new ZawgyiDetector(); | ||
|
||
// Unicode string | ||
$unicodeInput = 'အပြည်ပြည်ဆိုင်ရာ လူ့အခွင့်အရေး ကြေညာစာတမ်း'; | ||
|
||
// Zawgyi string | ||
$zawgyiInput = 'အျပည္ျပည္ဆိုင္ရာ လူ႔အခြင့္အေရး ေၾကညာစာတမ္း'; | ||
|
||
$unicodeScore = $detector->getZawgyiProbability($unicodeInput); | ||
$zawgyiScore = $detector->getZawgyiProbability($zawgyiInput); | ||
|
||
assert($unicodeScore < 0.001); | ||
assert($zawgyiScore > 0.999); | ||
|
||
printf("Unicode Score: %.6f", $unicodeScore); | ||
echo "<br />"; | ||
printf("Zawgyi Score: %.6f", $zawgyiScore); | ||
|
||
echo "<br />"; | ||
|
||
// Convert the second string to Unicode: | ||
$zawgyi2UniConverted = Rabbit::zg2uni($zawgyiInput); | ||
assert($unicodeInput === $zawgyi2UniConverted, "Converted string is equal to unicode"); | ||
printf("Converted Text: %s\n", $zawgyi2UniConverted); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "googlei18n/myanmar-tools-sample", | ||
"description": "Sample for how to use myanmar-tools detector", | ||
"license": "MIT", | ||
"keywords": [ | ||
"sample" | ||
], | ||
"homepage": "https://developers.google.com/international", | ||
"authors": [ | ||
{ | ||
"name": "googlei18n", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"type": "project", | ||
"require": { | ||
"googlei18n/myanmar-tools": ">=0.1.0" | ||
} | ||
} |