コード例 #1
0
    def __init__(self, speaker=None, demo=False):
        Thread.__init__(self)

        self.go_on = True
        self._logger = logging.getLogger('dialogs')

        self._demo_mode = demo

        if speaker:
            self._speaker = speaker
        else:
            self._speaker = SpeakerIdentifier().get_current_speaker_id()

        self._parser = Parser()
        self._resolver = Resolver()
        self._content_analyser = ContentAnalyser()
        self._verbalizer = Verbalizer()

        self._nl_input_queue = Queue()
        self._sentence_output_queue = Queue()

        #true when the Dialog module is within an interaction with a speaker
        self.in_interaction = False

        #the current set of sentences that dialog is dealing with
        self.sentences = deque()

        #the current sentence being worked on. Specifically, if active_sentence
        #is set, the parser will _complete_ this sentence instead of creating a
        #new one.
        self.active_sentence = None

        #true when, during an interaction, more infos is needed.
        self.waiting_for_more_info = False

        #contains the last result of a failed resolution (including the object
        #that could not be resolved. Cf doc of UnsufficientInputError for details.
        self._last_output = None

        #contains the last result of a failed resolution of an anaphoric words (it, one) (including the object
        #that could not be resolved. Cf doc of UnidentifiedAnaphoraError for details.
        self._anaphora_input = None

        #the ID of the speaker we are talking with. used to resolve references
        #like 'me', 'you', etc.
        self.current_speaker = None

        #the set of the statements generated by the analysis of the last sentence.
        # For testing purposes.
        self.last_stmts_set = []

        #last utterance outputed to user. This is a tuple containing both the
        # Sentence object and the verbalized version.
        self.last_sentence = (None, None)
コード例 #2
0
from dialogs.parsing.parser import Parser

parser = Parser()

print """
<html>
    <head>
      <meta charset="UTF-8">
      <title> DIALOGS parser demo</title>
      <link rel ="stylesheet" type="text/css" href="styles.css" title="Style"></link>
      <link rel="stylesheet" href="javascript/jquery.tooltip.css" />

      <script src="javascript/lib/jquery.js" type="text/javascript"></script>
      <script src="javscript/lib/jquery.bgiframe.js" type="text/javascript"></script>
      <script src="javascript/lib/jquery.dimensions.js" type="text/javascript"></script>
      <script src="javascript/jquery.tooltip.js" type="text/javascript"></script>

      <script type="text/javascript">
      $(function() {
          $('.subject').tooltip({ 
              track: true, 
              delay: 0, 
              showURL: false, 
              bodyHandler: function() { return "Subject";}, 
              fade: 250 
          });

          $('.indirect_object').tooltip({ 
              track: true, 
              delay: 0, 
              showURL: false,