Example #1
0
 def __init__(self, host, context=None, document=None, args=None, handler=None):
    self.mmt      = MMTApi(host)
    self.context  = context
    self.args     = args
    self.document = document
    self.handler  = handler
    if context:
       C = self.mmt.get_context_s(context)
       S = self.mmt.create_session(C)
       self.session = S['id']
    else:
       self.session = None
    return
Example #2
0
class Session:
   def __init__(self, host, context=None, document=None, args=None, handler=None):
      self.mmt      = MMTApi(host)
      self.context  = context
      self.args     = args
      self.document = document
      self.handler  = handler
      if context:
         C = self.mmt.get_context_s(context)
         S = self.mmt.create_session(C)
         self.session = S['id']
      else:
         self.session = None
      return
   
   def __del__(self):
      if self.session != None:
         self.mmt.close_session(self.session)
      return

   def translate(self,line):
      return self.mmt.translate(line,session=self.session, nbest=None)