summaryrefslogtreecommitdiff
path: root/backend.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2017-02-28 13:30:07 +0300
committerAndrew Dolgov <[email protected]>2017-02-28 13:30:07 +0300
commit6b355bca61e57f6f8a168f0bc7256ef6ac273c6c (patch)
tree6497b95883a4bea270cbe9c097ba7535d755c31d /backend.php
parent27ef6e89501371b58b92a3b805ab31ba8fc79260 (diff)
improve dictd guessing a bit
Diffstat (limited to 'backend.php')
-rw-r--r--backend.php19
1 files changed, 15 insertions, 4 deletions
diff --git a/backend.php b/backend.php
index e7a7e41..fb0c9ec 100644
--- a/backend.php
+++ b/backend.php
@@ -197,23 +197,34 @@
} else if ($rc == 21) {
- $word_match = "";
+ $word_matches = [];
foreach ($output as $line) {
- if (preg_match('/^[^ ]+: *([^ ]+)$/', $line, $match)) {
+ if (preg_match('/^[^ ]+: *(.*)/', $line, $match)) {
+
if ($match[1]) {
- $word_match = escapeshellarg($match[1]);
+ $word_matches = explode(" ", $match[1]);
break;
}
}
}
+ $word_matches = implode(" ", array_map("escapeshellarg", $word_matches));
+
unset($output);
- exec(DICT_CLIENT . " -h ". DICT_SERVER ." $word_match 2>&1", $output, $rc);
+ exec(DICT_CLIENT . " -h ". DICT_SERVER ." $word_matches 2>&1", $output, $rc);
if ($rc == 0) {
print json_encode(["result" => $output]);
}
+ } else if ($rc == 20) {
+
+ exec(DICT_CLIENT . " -s soundex -h ". DICT_SERVER ." $word 2>&1", $output, $rc);
+
+ print json_encode(["result" => $output]);
+
+ } else {
+ print json_encode(["result" => $output]);
}
}