コード例 #1
0
def main():
    print os.getcwd()
    basepath = os.path.dirname(__file__)
    filepath = os.path.abspath(os.path.join(basepath, "..", "..", "..", "..", "bluesGrammar.txt"))
    parser = GrammarPyParser(filepath)
    grammarDict = parser.parseIntoDictionary()
    generator = ProbabilisticSentenceGenerator(grammarDict)
    print 'generated:', generator.generate('Q4')
コード例 #2
0
def main():
    print os.getcwd()
    basepath = os.path.dirname(__file__)
    filepath = os.path.abspath(os.path.join(basepath, "..", "..", "..", "..", "bluesGrammar.txt"))
    parser = GrammarPyParser(filepath)
    grammarDict = parser.parseIntoDictionary()
    
    grammarWeightingNormaliser = GrammarWeightingNormaliser(grammarDict)
    newGrammarDict = grammarWeightingNormaliser.normaliseProbabilities()
    print 'normalised grammar:', newGrammarDict
コード例 #3
0
 def __init__(self, grammarFileName):
     grammarFileParser = GrammarPyParser(grammarFileName)
     grammarDictionary = grammarFileParser.parseIntoDictionary()
     self.sentenceGenerator = ProbabilisticSentenceGenerator(grammarDictionary)