-- Mar 9 In-Class Exercise
Code:
<?php
namespace gargi\test_composer;
use seekquarry\yioop\configs as SYC;
use seekquarry\yioop\library as SYL;
use seekquarry\yioop\library\Library;
use seekquarry\yioop\library\PhraseParser;
require_once "vendor/autoload.php";
/*
Since a normal Yioop instance needs a Profile.php file to be generated,
the following is used to set up Yioop in library mode so you don't need this.
To enable debugging use Library::init(true);
*/
Library::init();
$inputstr = "The prime minister is the head of government for Canada, chairs and selects the membership of the Cabinet, and advises the Crown on the exercise of executive power and much of the royal prerogative. ";
PhraseParser::hyphenateEntities($inputstr, "en-US");
echo $inputstr;
Output:
Hyphenated: The prime-minister is the head of government for Canada, chairs and selects the membership of the Cabinet, and advises the Crown on the exercise of executive-power and much of the royal prerogative.
Stemmed: array(32) {
[0]=>
string(3) "The"
[1]=>
string(12) "prime-minist"
[2]=>
string(2) "is"
[3]=>
string(3) "the"
[4]=>
string(4) "head"
[5]=>
string(2) "of"
[6]=>
string(6) "govern"
[7]=>
string(3) "for"
[8]=>
string(7) "Canada,"
[9]=>
string(5) "chair"
[10]=>
string(3) "and"
[11]=>
string(6) "select"
[12]=>
string(3) "the"
[13]=>
string(10) "membership"
[14]=>
string(2) "of"
[15]=>
string(3) "the"
[16]=>
string(8) "Cabinet,"
[17]=>
string(3) "and"
[18]=>
string(5) "advis"
[19]=>
string(3) "the"
[20]=>
string(5) "Crown"
[21]=>
string(2) "on"
[22]=>
string(3) "the"
[23]=>
string(7) "exercis"
[24]=>
string(2) "of"
[25]=>
string(15) "executive-power"
[26]=>
string(3) "and"
[27]=>
string(4) "much"
[28]=>
string(2) "of"
[29]=>
string(3) "the"
[30]=>
string(5) "royal"
[31]=>
string(12) "prerogative."
}
<pre>
Code:
<?php
namespace gargi\test_composer;
use seekquarry\yioop\configs as SYC;
use seekquarry\yioop\library as SYL;
use seekquarry\yioop\library\Library;
use seekquarry\yioop\library\PhraseParser;
require_once "vendor/autoload.php";
/*
Since a normal Yioop instance needs a Profile.php file to be generated,
the following is used to set up Yioop in library mode so you don't need this.
To enable debugging use Library::init(true);
*/
Library::init();
$inputstr = "The prime minister is the head of government for Canada, chairs and selects the membership of the Cabinet, and advises the Crown on the exercise of executive power and much of the royal prerogative. ";
PhraseParser::hyphenateEntities($inputstr, "en-US");
echo $inputstr;
Output:
Hyphenated: The prime-minister is the head of government for Canada, chairs and selects the membership of the Cabinet, and advises the Crown on the exercise of executive-power and much of the royal prerogative.
Stemmed: array(32) {
[0]=>
string(3) "The"
[1]=>
string(12) "prime-minist"
[2]=>
string(2) "is"
[3]=>
string(3) "the"
[4]=>
string(4) "head"
[5]=>
string(2) "of"
[6]=>
string(6) "govern"
[7]=>
string(3) "for"
[8]=>
string(7) "Canada,"
[9]=>
string(5) "chair"
[10]=>
string(3) "and"
[11]=>
string(6) "select"
[12]=>
string(3) "the"
[13]=>
string(10) "membership"
[14]=>
string(2) "of"
[15]=>
string(3) "the"
[16]=>
string(8) "Cabinet,"
[17]=>
string(3) "and"
[18]=>
string(5) "advis"
[19]=>
string(3) "the"
[20]=>
string(5) "Crown"
[21]=>
string(2) "on"
[22]=>
string(3) "the"
[23]=>
string(7) "exercis"
[24]=>
string(2) "of"
[25]=>
string(15) "executive-power"
[26]=>
string(3) "and"
[27]=>
string(4) "much"
[28]=>
string(2) "of"
[29]=>
string(3) "the"
[30]=>
string(5) "royal"
[31]=>
string(12) "prerogative."
}
</pre>