treatment of composed substantives
Esse commit está contido em:
@@ -35,6 +35,31 @@ class Syntaxer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fixes the composed substantives(defined by the use of
|
||||
* the "of" tokens)
|
||||
*/
|
||||
public function fetchComposedSubstantives()
|
||||
{
|
||||
// for each word
|
||||
for($i=0, $j=sizeof(Token::$spine); $i<$j; $i++)
|
||||
{
|
||||
// if it is a substantive and there is another substantive
|
||||
// two positions after, with an OF token between them
|
||||
if( Token::$spine[$i] == Token::MT_SUBST
|
||||
&& isset(Token::$spine[$i+1])
|
||||
&& isset(Token::$spine[$i+2])
|
||||
&& Token::$spine[$i+1] == Token::MT_QOF
|
||||
&& Token::$spine[$i+2] == Token::MT_SUBST)
|
||||
{
|
||||
// rewrite the substantive
|
||||
Token::$words[$i+2]= Token::$words[$i+2].
|
||||
PROPERTY_SEPARATOR.
|
||||
Token::$words[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sweeps the content to apply the rules and identify patterns
|
||||
* @name sweep
|
||||
@@ -53,6 +78,8 @@ class Syntaxer {
|
||||
// reminding that the pattern was dynamicaly created before
|
||||
$pattern= str_replace('S', VALID_SUBST_SYNTAX, $pattern);
|
||||
|
||||
$this->fetchComposedSubstantives();
|
||||
|
||||
// finding the valid syntaxes
|
||||
preg_match_all('/'.$pattern.'/',
|
||||
Token::$string,
|
||||
|
||||
@@ -59,7 +59,6 @@ class Token
|
||||
{
|
||||
self::$spine[]= Token::MT_ANY;
|
||||
self::$string.= Token::MS_ANY;
|
||||
echo $word."<<<<<< ";
|
||||
return;
|
||||
}
|
||||
if($word==',')
|
||||
|
||||
@@ -205,14 +205,25 @@ class Tokenizer extends Token{
|
||||
}
|
||||
|
||||
// adding each word as its token
|
||||
foreach($cont as $word)
|
||||
for($i=0, $j=sizeof($cont); $i<$j; $i++)
|
||||
{
|
||||
$word= $cont[$i];
|
||||
/*if(isset($cont[$i+1])
|
||||
&&
|
||||
Tokenizer::isQualifier('of', $cont[$i+1])
|
||||
&&
|
||||
isset($cont[$i+2]))
|
||||
{
|
||||
$word= $word.'_'.$cont[$i+2];
|
||||
}else{
|
||||
$word= strtolower($word);
|
||||
$this->add($word);
|
||||
}*/
|
||||
$word= strtolower($word);
|
||||
$this->add($word);
|
||||
}
|
||||
|
||||
Mind::$syntaxer= new Syntaxer();
|
||||
//print_r(Token::$spine);
|
||||
return Token::$spine;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,6 +101,9 @@ EOT
|
||||
echo "Time: ".
|
||||
number_format(((float)$endingTime) - ((float)$startingTime), 4).
|
||||
"s\n";
|
||||
$memory= ((memory_get_usage() / 1024)/1024);
|
||||
$memory= number_format($memory, 2);
|
||||
echo $memory."MBs\n";
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,4 +30,5 @@
|
||||
|
||||
// other constants
|
||||
define('QUANTIFIER_MAX_MAX', 'n');
|
||||
define('QUANTIFIER_MAX_MIN', 1);
|
||||
define('QUANTIFIER_MAX_MIN', 1);
|
||||
define('PROPERTY_SEPARATOR', "_");
|
||||
@@ -1,4 +1,5 @@
|
||||
cada professor deve ter um ou vários alunos.
|
||||
|
||||
sogra e sogro tem um genro e nora.
|
||||
sogra, sogro, genro e nora tem nome:varchar(200, obrigatório), idade:int e
|
||||
sexo:char(1, {F=Feminino|M=Masculino}).
|
||||
@@ -12,3 +13,8 @@ aluno tem um pai e mãe.
|
||||
aluno tem nome:caractere(128, obrigatório, não nulo, "josé's da \"conceição\" machado")
|
||||
pai usa \pilha.
|
||||
tanto mãe quanto pai tem nome:varchar, idade:int e sexo:char(1, {F=Feminino|M=Masculino}).
|
||||
|
||||
professor também tem pai e mãe.
|
||||
aluno pode ter divérsos irmãos.
|
||||
Cada irmão pode ter filhos, e cada filho pode ter filho.
|
||||
A grade de cadeiras terá várias disciplinas.
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário