I am using the tool for language analysis called Freeling. For language identification I use the analyzer
command in the Linux console:
analyzer -f /usr/share/freeling/config/ident.cfg --outlv ident --fidn /usr/share/freeling/common/lang_ident/ident.dat
When I execute this command, its wait for the text entries (sentences) and determine what language they are in. When I write a line of text in Spanish: "la casa es azul" and I press the enter key returns ES which means that it is written in Spanish. If I write "the house is blue" it returns EN, for the English language. To interrupt its execution press <kbd>Ctrl</kbd> + <kbd>C</kbd>.
When I execute this command in the Linux console the first sentence takes some time to respond and the other times responds quickly.
I use this code to execute this php command but it takes many seconds to return the result:
<?php
$cmd = "analyzer -f /usr/share/freeling/config/ident.cfg --outlv ident --fidn /usr/share/freeling/common/lang_ident/ident.dat";
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("pipe", "w"),
);
$process = proc_open($cmd, $descriptorspec, $pipes);
$oracion[0]="we are the word";
$oracion[1]="somos el mundo";
if (is_resource($process)) {
fwrite($pipes[0], $oracion[0]);
fwrite($pipes[0], $oracion[1]);
fclose($pipes[0]);
while($pdf_content = fgets($pipes[1]))
{
echo $pdf_content . "<br>";
}
fclose($pipes[1]);
$return_value = proc_close($process);
}
?>
How can I improve the response time?