示例#1
0
    def run(self, args, state):
        from jazzparser.data.tonalspace import TonalSpaceAnalysisSet
        if len(args) != 1:
            raise ShellError, "Please give the name of a tonal space analysis "\
                "set. Available sets are: %s" % \
                    ", ".join(TonalSpaceAnalysisSet.list())

        try:
            # Try loading the named set
            songset = TonalSpaceAnalysisSet.load(args[0])
        except Exception, err:
            raise ShellError, "Error loading tonal space analysis set: %s" % \
                err
示例#2
0
def main():
    usage = "%prog"
    description = "List tonal space analysis sets"
    parser = OptionParser(usage=usage, description=description)
    options, arguments = parser.parse_args()
    
    print ", ".join(TonalSpaceAnalysisSet.list())
示例#3
0
def main():
    usage = "%prog"
    description = "List tonal space analysis sets"
    parser = OptionParser(usage=usage, description=description)
    options, arguments = parser.parse_args()

    print ", ".join(TonalSpaceAnalysisSet.list())
示例#4
0
def main():
    usage = "%prog <name>"
    description = "Delete a tonal space analysis set"
    parser = OptionParser(usage=usage, description=description)
    options, arguments = parser.parse_args()
    
    name = arguments[0]
    tsset = TonalSpaceAnalysisSet.load(name)
    tsset.delete()
示例#5
0
                for result in results:
                    print
                    print result.derivation_trace

            if options.tonal_space:
                # Output the tonal space coordinates
                path = grammar.formalism.sign_to_coordinates(results[0])
                for i, point in enumerate(path):
                    print "%d, %d: %s" % (seq.id, i, point)

            # Only include a result in the output analyses if it was a full parse
            if len(results) == 1:
                full_analyses.append((seq.string_name, results[0].semantics))
            else:
                logger.warn("%s was not included in the output analyses, "\
                    "since it was not fully parsed" % seq.string_name)

    logger.info("Fully parsed: %d" % stats['full'])
    logger.info("Partially parsed: %d" % stats['partial'])
    logger.info("Failed: %d" % stats['fail'])

    if options.output_set:
        # Output the full analyses to a file
        anal_set = TonalSpaceAnalysisSet(full_analyses, options.output_set)
        anal_set.save()
        print "Wrote analyses to analysis set '%s'" % options.output_set


if __name__ == "__main__":
    main()
示例#6
0
        moptstr = ":".join(moptstr)
    else:
        moptstr = ""
    mopts = ModuleOption.process_option_string(moptstr)
    # Instantiate the metric with these options
    metric = metric_cls(options=mopts)
    
        
    if len(arguments) < 2:
        print >>sys.stderr, "Specify a song corpus name and one or more files to read results from"
        sys.exit(1)
    
    # First argument is an TonalSpaceAnalysisSet
    corpus_name = arguments[0]
    # Load the corpus file
    corpus = TonalSpaceAnalysisSet.load(corpus_name)
    
    # The rest of the args are result files to analyze
    res_files = arguments[1:]

    # Work out how many results to print out
    if options.print_results == -1:
        print_up_to = None
    else:
        print_up_to = options.print_results
    
    ranks = []
    num_ranked = 0
    for filename in res_files:
        # Load the parse results
        pres = ParseResults.from_file(filename)
示例#7
0
            sys.exit(0)
        moptstr = ":".join(moptstr)
    else:
        moptstr = ""
    mopts = ModuleOption.process_option_string(moptstr)
    # Instantiate the metric with these options
    metric = metric_cls(options=mopts)

    if len(arguments) < 2:
        print >> sys.stderr, "Specify a song corpus name and one or more files to read results from"
        sys.exit(1)

    # First argument is an TonalSpaceAnalysisSet
    corpus_name = arguments[0]
    # Load the corpus file
    corpus = TonalSpaceAnalysisSet.load(corpus_name)

    # The rest of the args are result files to analyze
    res_files = arguments[1:]

    # Work out how many results to print out
    if options.print_results == -1:
        print_up_to = None
    else:
        print_up_to = options.print_results

    ranks = []
    num_ranked = 0
    for filename in res_files:
        # Load the parse results
        pres = ParseResults.from_file(filename)