Revision: 6183 http://sourceforge.net/p/smartbody/code/6183 Author: arishapiro Date: 2015-08-18 19:08:11 +0000 (Tue, 18 Aug 2015) Log Message: ----------- Added SBParserListener, an interface for adding BML for an utterance based on the text. Usage:
class MyListener(SBParserListener): def onWord(self, timing, word ): # called every time a word is parsed self.addBML("<gesture lexeme=\"DEICTIC\" type=\"YOU\" start=\"" + timing + "\"/>") def onPartOfSpeech(self, timing, word ): # called every time a new part of speech is reached self.addBML("<head type=\"SHAKE\" start=\"" + timing + "\"/>") my = MyListener() # associate the listener with a Character scene.getCharacter("mycharacter").addParserListener(my) # parse an utterance bml = scene.getParser().parseUtterance("hello, my name is Brad.") # bml contains the full BML Requires the loading of parser data like this: parser = scene.getParser() parser.initialize("e:/smartbody/trunk/data/parser/EN/", "-T40") if the parser is not initialized, listener will only call onWord() function, and not onPartOfSpeech() function. Modified Paths: -------------- trunk/core/smartbody/SmartBody/src/sb/SBCharacter.cpp trunk/core/smartbody/SmartBody/src/sb/SBCharacter.h trunk/core/smartbody/SmartBody/src/sb/SBParser.cpp trunk/core/smartbody/SmartBody/src/sb/SBParser.h trunk/core/smartbody/SmartBody/src/sb/SBPython.cpp trunk/core/smartbody/SmartBody/src/sb/SBPythonCharacter.cpp trunk/core/smartbody/SmartBody/src/sb/SBPythonInternal.h trunk/core/smartbody/SmartBody/src/sb/SBVersion.hpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ _______________________________________________ Smartbody-svn mailing list Smartbody-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/smartbody-svn