-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathextract.php
49 lines (48 loc) · 1.19 KB
/
extract.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
39
40
41
42
43
44
45
46
47
48
49
<?php
/*
<parameters>
<requestType>extract</requestType>
<numWords>number</numWords>
<resourceList>
<resource>
<table>table name</table>
<id>id</id>
</resource>
...
</resourceList>
</parameters>
```
###Response
```
<parameters>
<requestID>number</requestID>
<requestType>extract</requestType>
<resourceList>
<resource>
<id>id</id>
<keywords>comma,seperated,keywords</keywords>
</resource>
...
</resourceList>
</parameters>
*/
class Extract extends Controller{
function run($xml){
global $FILE_ROOT, $STORAGE, $REQ_ID, $CMD_EXTRA, $BIN;
// /if(!pe($xml, "table")) die(err("No table found"));
if(!pe($xml, "resourceList")) die(err("No resources found"));
//write to temporary file
$fname = $STORAGE . $REQ_ID . "_extract.xml";
$TMP = fopen($fname, "w");
fwrite($TMP, $xml->asXML());
fclose($TMP);
//extract those words
$cmd = $BIN . "text_processing extract " . $fname;
$output = array();
exec($cmd, $output);
unlink($fname);
$extractedResList = implode($output);
$response = "<parameters><requestType>extract</requestType><requestID>". $REQ_ID . "</requestID><resourceList>" . $extractedResList . "</resourceList></parameters>";
return $response;
}
}