-
Notifications
You must be signed in to change notification settings - Fork 13
/
vmsp.py
40 lines (31 loc) · 970 Bytes
/
vmsp.py
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
# NO INTERNAL REFERENCE
import subprocess
class Vmsp:
def __init__(self):
self._executable = "spmf.jar"
self._input = "input.txt"
self._output = "output.txt"
def run(self, min_supp=0.5):
# java -jar spmf.jar run VMSP contextPrefixSpan.txt output.txt 50%
subprocess.call(["java", "-jar", self._executable, "run", "VMSP", self._input, self._output, str(min_supp)])
def encode_input(self, data):
pass
def decode_output(self):
# read
lines = []
try:
with open(self._output, "rU") as f:
lines = f.readlines()
except:
print "read_output error"
# decode
patterns = []
for line in lines:
line = line.strip()
patterns.append(line.split(" -1 "))
return patterns
if __name__ == "__main__":
vmsp = Vmsp()
vmsp.encode_input([])
vmsp.run()
print vmsp.decode_output()