def __init__(self, corpus, n=15, expressionModel=None): self.allowed = treeconstraints.train(corpus) self.expressionModel = expressionModel if expressionModel == None: self.expressionModel = expression.train(corpus) rhythmModel = pcfg.train(corpus) super(StochasticParser, self).__init__(model=rhythmModel, n=n) self.setBeam(corpus)
def corpusAndParser(n=15): from jazzr.models import pcfg, treeconstraints from jazzr.corpus import annotations corpus = annotations.corpus() allowed = treeconstraints.train(corpus) allowed.append(['tie', 'tie', 'on']) model = pcfg.train(corpus) #model = None return annotations.loadAnnotations(), SimpleParser(n=n, model=model, corpus=True, allowed=allowed, tolerance=0.001, maxdepth=5)
def __init__(self, collection='explicitswing', n=15, beam=0.8, std=0.1, expected_logratio=0.0, model=None, allowed=None): if model == None: corpus = annotations.corpus(collection=collection) model = pcfg.train(corpus) self.allowed = treeconstraints.train(corpus) else: self.model = model self.allowed = allowed # Standard deviation expressed in proportion of beatlength self.std = std self.expected_logratio = expected_logratio super(StochasticParser, self).__init__(beam=beam, model=model, n=n)