11
22"""
33The User-Agent (also called UI-Agent, Agent-UI) receives text/speech
4- as input, and produces an n-tuple, which it sends to a ProblemSolver.
4+ as input, and produces an n-tuple, which it sends to a ProblemSolver.
55It feeds the text through the ECG Analyzer (running on a local server)
66to produce a SemSpec, which it then runs through the CoreSpecializer to produce
7- the n-tuple.
7+ the n-tuple.
88
99Interaction with the user is modulated through the output_stream method, which
1010allows designers to subclass the User-Agent and define a new mode of interaction.
@@ -78,7 +78,7 @@ def initialize_UI(self):
7878
7979 def initialize_analyzer (self ):
8080 self .analyzer = Analyzer (self .analyzer_port )
81-
81+
8282 def initialize_specializer (self ):
8383 try :
8484 self .specializer = CoreSpecializer (self .analyzer )
@@ -130,7 +130,7 @@ def speech_callback(self, ntuple):
130130 #ntuple = json.loads(ntuple)
131131 text = ntuple ['text' ].lower ()
132132 print ("Got {}" .format (text ))
133- new_ntuple = self .process_input (text )
133+ new_ntuple = self .process_input (text )
134134 if new_ntuple and new_ntuple != "null" and "predicate_type" in new_ntuple :
135135 self .transport .send (self .solve_destination , new_ntuple )
136136
@@ -141,7 +141,9 @@ def text_callback(self, ntuple):
141141 specialize = True
142142 #ntuple = json.loads(ntuple)
143143 msg = ntuple ['text' ]
144- if ntuple ['type' ] == "standard" :
144+ if self .is_quit (ntuple ):
145+ self .close ()
146+ elif ntuple ['type' ] == "standard" :
145147 if msg == None or msg == "" :
146148 specialize = False
147149 elif msg .lower () == "d" :
@@ -159,7 +161,6 @@ def text_callback(self, ntuple):
159161 self .clarification = False
160162
161163
162-
163164 def callback (self , ntuple ):
164165 print (ntuple )
165166 #ntuple = self.decoder.convert_JSON_to_ntuple(ntuple)
@@ -182,7 +183,6 @@ def write_file(self, json_ntuple, msg):
182183
183184
184185
185-
186186 def process_clarification (self , tag , msg , ntuple ):
187187 self .clarification = True
188188 #self.output_stream(tag, msg)
@@ -203,15 +203,6 @@ def clarify_ntuple(self, ntuple, descriptor):
203203 new [key ] = value
204204 return new
205205
206-
207- def prompt (self ):
208- while True :
209- s = input ("> " )
210- if s == "q" :
211- self .transport .quit_federation ()
212- quit ()
213-
214-
215206 def check_spelling (self , msg ):
216207 table = self .spell_checker .spell_check (msg )
217208 if table :
@@ -229,6 +220,3 @@ def check_spelling(self, msg):
229220
230221if __name__ == "__main__" :
231222 ui = UserAgent (sys .argv [1 :])
232- ui .prompt ()
233-
234-
0 commit comments