public function __construct(){
$this->input = $_GET['text'];
//$this->input = $request->query->get('text');
$array = explode("\n",$this->input);
for($a = 0; $a != count($array); $a++ ){
$words = explode(', ',$array[$a]);
$b = 0; # Номер фразы
foreach($words as $word){
$word = preg_replace('/(?<=\S)-(?=\S)/u', ' ', $word);
$keys = explode(' ',$word);
foreach($keys as $k){
if(mb_strlen($k) <= 2){
$k = '+'.$k;
}
$this->keywords[$a][$b][] = $k; # Массив слов в фарзе, в строоке
}
$b++;
}
foreach($this->keywords[$a] as $wor){
$out = $wor;
$length = count($wor);
foreach($this->keywords[$a] as $other) {
if(count($other) > count($out) && array_intersect($wor, $other) === $length) {
$out = $other;
}
}
echo json_encode($out); echo "\n\n";
}
}
}
ublic function start(Request $request){
$this->input = $request->query->get('text');
$array = explode("\n",$this->input);
for($a = 0; $a != count($array); $a++ ){
$words = explode(', ',$array[$a]);
$b = 0; # Номер фразы
foreach($words as $word){
$word = preg_replace('/(?<=\S)-(?=\S)/u', ' ', $word);
$keys = explode(' ',$word);
foreach($keys as $k){
if(mb_strlen($k) <= 2){
$k = '+'.$k;
}
$this->keywords[$a][$b][] = $k;
}
$b++;
}
}
echo json_encode($this->keywords);
}