-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.php
38 lines (33 loc) · 791 Bytes
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php
$phrase = 'çıkmasına';
$output = '';
$output = shell_exec('echo "' . $phrase . '" |flookup /home/abylay/projects/morph/TRmorph/stem.fst');
$lines = preg_split('/\n/', $output);
$alternatives = array();
$stems = array();
foreach($lines as $line) {
$parts = $parts = preg_split('/\t+/', $line);
$stem = $parts[1];
$stem = preg_replace('/<.*>/', '', $stem);
if($stem != "?+" && $stem != ""){
array_push($stems, $stem);
}
}
if(count($stems) > 0){
$alternatives = $stems;
rsort($alternatives);
array_push($alternatives, $phrase);
$phrase = $alternatives[0];
}
echo htmlspecialchars('-' . $phrase) . '<br/>';
foreach($alternatives as $st) {
echo htmlspecialchars('-' . $st) . '<br/>';
}
?>
</body>
</html>