nothing@1: import rdflib, os, fnmatch nothing@1: from rdflib import Graph, RDF, RDFS, plugin, URIRef, Literal nothing@1: nothing@1: execfile('/Users/alo/Downloads/python-Levenshtein-0.10.2/StringMatcher.py') nothing@1: nothing@1: mdir = '/Users/alo/Development/MIR/marsyas-0.4.7/src/marsyas/' nothing@1: #magraph = Graph() nothing@1: madict = {} nothing@1: #current = Graph() nothing@1: #current.parse('docfeatures.rdf') nothing@1: nothing@1: abbr = { nothing@1: "Zero Crossing Rate": "ZCR", nothing@1: "Mel-Frequency Cepstral Coefficients": "MFCC", nothing@1: "Linear Predictive Coding": "LPC", nothing@1: "Zero crossing peak amplitudes": "ZCPA", nothing@1: "Line spectral frequencies": "LSF", nothing@1: "Short-time energy": "STE", nothing@1: "Amplitude descriptor": "AD", nothing@1: "Adaptive time frequency transform": "ATFT", nothing@1: "Daubechies Wavelet coefficient histogram": "DWCH", nothing@1: "Spectral Flux": "SF", nothing@1: "Group delay function": "GDF", nothing@1: "Modified group delay function": "MGDF", nothing@1: "Spectral centroid": "SC", nothing@1: "Subband spectral flux": "SSF", nothing@1: "Perceptual linear prediction": "PLP" nothing@1: } nothing@1: nothing@1: for name in os.listdir(mdir): nothing@1: if fnmatch.fnmatch(name, '*.h'): nothing@1: code = [line.strip() for line in open(mdir + name)] nothing@1: found = False nothing@1: for line in code: nothing@1: if line.find('\ingroup Analysis') >= 0: nothing@1: found = True nothing@1: break nothing@1: nothing@1: if found: nothing@1: i = 0 nothing@1: cl = '' nothing@1: for line in code: nothing@1: if line.find('\class') >= 0: nothing@1: cl = line.split(' ')[-1] nothing@1: madict[cl] = {'brief': code[i+2][7:]} nothing@1: if code[i+3] != '': nothing@1: madict[cl]['brief'] += code[i+3] nothing@1: nothing@1: break nothing@1: nothing@1: i += 1 nothing@1: nothing@1: score = 100 nothing@1: madict[cl]['score'] = 100 nothing@1: madict[cl]['name'] = "" nothing@1: for s, p, o in current.triples((None, None, RDFS.Resource)): nothing@1: for cs, cp, name in current.triples((s, URIRef('http://sovarr.c4dm.eecs.qmul.ac.uk/features/feature'), None)): nothing@1: m = StringMatcher() nothing@1: m.set_seqs(Literal(cl), name) nothing@1: sc = float(m.distance()) / ((len(cl) + len(name)) / 2.0) nothing@1: if sc < score: nothing@1: madict[cl]['score'] = 1.0 - sc nothing@1: madict[cl]['name'] = name nothing@1: score = sc nothing@1: nothing@1: if madict[cl]['score'] < 0.75: nothing@1: for k in abbr.keys(): nothing@1: if abbr[k] == cl: nothing@1: madict[cl]['score'] = 1.0 nothing@1: madict[cl]['name'] = k nothing@1: