Answer the question
In order to leave comments, you need to log in
Text processing with mystem in php?
The mystem program performs a morphological analysis of the text in Russian.
I'm trying to process a string with it:
<?php<br/>
function mystem($q) {<br/>
$out = array();<br/>
exec('echo ' . $q . ' | ' . dirname(__FILE__) . '\mystem\mystem.exe -i', $out);<br/>
$q = implode('', $out);<br/>
return $q;<br/>
}<br/>
<br/>
echo mystem('в мурелки шлепают пельсиски');<br/>
?>
�{�??}�{�??}��{��??}���{���??}�{�??}����{����??}���{���??}��{��??}���{���??}
exec('echo ' . $q . ' | ' . dirname(__FILE__) . '\mystem\mystem.exe -e utf-8 -i', $out);
<?php<br/>
function mystem($q) {<br/>
$out = array();<br/>
$q = iconv("utf-8", "windows-1251", $q);<br/>
exec('echo ' . $q . ' | ' . dirname(__FILE__) . '\mystem\mystem.exe -i', $out);<br/>
$q = implode('', $out);<br/>
return $q;<br/>
}<br/>
<br/>
echo mystem('в мурелки шлепают пельсиски');<br/>
?>
ў{ў??}гаҐ{гаҐ??}ЄЁ{ЄЁ??}и{и=INTJ=|и=PART=|и=S,сокр=им,ед|=S,сокр=им,мн|=S,сокр=род,ед|=S,сокр=род,мн|=S,сокр=дат,ед|=S,сокр=дат,мн|=S,сокр=вин,ед|=S,сокр=вин,мн|=S,сокр=твор,ед|=S,сокр=твор,мн|=S,сокр=пр,ед|=S,сокр=пр,мн|и=CONJ=}ҐЇ{ҐЇ??}ов{ов??}ЇҐ{ЇҐ??}мбЁбЄЁ{мбЁбЄЁ??}
<?php<br/>
function mystem($q) {<br/>
$q = iconv("utf-8", "windows-1251", $q);<br/>
$result = exec('echo "'.$q.'" | mystem.exe -i -e cp866');<br/>
$result = iconv("cp866", "utf-8", $result);<br/>
return $result;<br/>
}<br/>
<br/>
header("Content-type: text/html; charset=utf-8");<br/>
echo mystem('в мурелки шлепают пельсиски');<br/>
?><br/>
Answer the question
In order to leave comments, you need to log in
This option works for me:
<?php
function mystem($q) {
$result = exec('echo "'.$q.'" | mystem.exe -i -e cp866');
$result = iconv("cp866", "windows-1251", $result);
return $result;
}
echo mystem('в мурелки шлепают пельсиски');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question