-
Notifications
You must be signed in to change notification settings - Fork 0
/
reader.py
88 lines (75 loc) · 2.47 KB
/
reader.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import os
import sys
from utils import *
import commands
import traceback
import cmd
class CLI(cmd.Cmd):
"""Simple command processor example."""
# def __init__(self):
# # self.prompt = "CLI"
# a = 1
def preloop(self, line):
print "preloop() called!!!"
self.cmdTokens = line.rsplit(" ")
self.nArgs = len(cmdTokens)
def do_inf(self, line):
cmdTokens = line.rsplit(" ")
nArgs = len(cmdTokens)
if(nArgs != 0): return False
commands.listInfluencers()
def do_cat(self, line):
cmdTokens = line.rsplit(" ")
nArgs = len(cmdTokens)
if(nArgs != 1): return False
commands.listCategories(int(cmdTokens[0]))
def do_resp(self, line):
cmdTokens = line.rsplit(" ")
nArgs = len(cmdTokens)
if(nArgs != 2): return False
commands.listResponses(int(cmdTokens[0]), int(cmdTokens[1]))
def do_add_cat(self, line):
cmdTokens = line.rsplit(" ")
nArgs = len(cmdTokens)
if(nArgs != 1): return False
catCaption = raw_input(greenText("Type the new category name:"))
commands.addCategory(int(cmdTokens[0]), catCaption)
def do_add_resp(self, line):
cmdTokens = line.rsplit(" ")
nArgs = len(cmdTokens)
if(nArgs != 2): return False
response = raw_input(greenText("Type the new response:"))
commands.addResponse(int(cmdTokens[0]), int(cmdTokens[1]), response)
def do_mes(self, line):
cmdTokens = line.rsplit(" ")
nArgs = len(cmdTokens)
if(nArgs != 1): return False
commands.listMessages(int(cmdTokens[0]))
def do_set_cat(self, line):
cmdTokens = line.rsplit(" ")
nArgs = len(cmdTokens)
if(nArgs != 2): return False
commands.setCat(int(cmdTokens[0]), int(cmdTokens[1]))
def do_set_cat_batch(self, line):
cmdTokens = line.rsplit(" ")
nArgs = len(cmdTokens)
if(nArgs != 2): return False
commands.setCatBatch(int(cmdTokens[0]), int(cmdTokens[1]))
def do_LDA(self, line):
cmdTokens = line.rsplit(" ")
nArgs = len(cmdTokens)
if(nArgs != 2): return False
commands.runLDA(int(cmdTokens[0]), int(cmdTokens[1]), 100000)
def do_topics(self, line):
cmdTokens = line.rsplit(" ")
nArgs = len(cmdTokens)
if(nArgs != 0): return False
commands.ldaTopics()
def do_topic_all(self, line):
cmdTokens = line.rsplit(" ")
nArgs = len(cmdTokens)
if(nArgs != 2): return False
commands.ldaMessagesByTopic(int(cmdTokens[0]), int(cmdTokens[1]))
def do_EOF(self, line):
print "\n"
return True