annotate rdfpy/writeBaseOnto.py @ 0:62d2c72e4223

initial commit
author nothing@tehis.net
date Mon, 25 Feb 2013 14:40:54 +0000
parents
children 53069717108c
rev   line source
nothing@0 1 import rdflib, os, fnmatch, urllib2
nothing@0 2 from rdflib import Graph, RDF, RDFS, plugin, URIRef, Literal, OWL, XSD, Namespace
nothing@0 3 from xml.dom.minidom import parseString
nothing@0 4
nothing@0 5 names = [line.strip() for line in open('pdfextract/names.txt')]
nothing@0 6 cat = [line.strip() for line in open('pdfextract/categories.txt')]
nothing@0 7 sig = [line.strip() for line in open('pdfextract/sig.txt')]
nothing@0 8
nothing@0 9 basedir = '/Users/alo/MusicOntology/features/'
nothing@0 10
nothing@0 11 local = 'http://sovarr.c4dm.eecs.qmul.ac.uk/features/'
nothing@0 12
nothing@0 13 DC = Namespace(u"http://purl.org/dc/elements/1.1/")
nothing@0 14 VS = Namespace(u"http://www.w3.org/2003/06/sw-vocab-status/ns#")
nothing@0 15
nothing@0 16 graph = Graph()
nothing@0 17 graph.bind('af', URIRef(local))
nothing@0 18 graph.bind('dc', URIRef('http://purl.org/dc/elements/1.1/'))
nothing@0 19 graph.bind('owl', URIRef('http://www.w3.org/2002/07/owl#'))
nothing@0 20 graph.bind('xsd', URIRef('http://www.w3.org/2001/XMLSchema#'))
nothing@0 21 graph.bind('vs', URIRef('http://www.w3.org/2003/06/sw-vocab-status/ns#'))
nothing@0 22
nothing@0 23 graph.add((
nothing@0 24 URIRef(''),
nothing@0 25 RDF.type,
nothing@0 26 OWL.Ontology
nothing@0 27 ))
nothing@0 28
nothing@0 29 graph.add((
nothing@0 30 URIRef(''),
nothing@0 31 DC['title'],
nothing@0 32 Literal("Audio Features Base Ontology")
nothing@0 33 ))
nothing@0 34
nothing@0 35 graph.add((
nothing@0 36 URIRef(''),
nothing@0 37 OWL.versionInfo,
nothing@0 38 Literal("Version 0.1")
nothing@0 39 ))
nothing@0 40
nothing@0 41 graph.add((
nothing@0 42 URIRef(''),
nothing@0 43 DC['description'],
nothing@0 44 Literal("This is a base ontology for the Audio Features engineering process collected from literature")
nothing@0 45 ))
nothing@0 46
nothing@0 47 graph.add((
nothing@0 48 VS['term_status'],
nothing@0 49 RDF.type,
nothing@0 50 OWL.AnnotationProperty
nothing@0 51 ))
nothing@0 52
nothing@0 53 i = 0
nothing@0 54
nothing@0 55 order = [
nothing@0 56 "Zero Crossing Rate",
nothing@0 57 "Linear Predictive Coding",
nothing@0 58 "Mel-scale Frequency Cepstral Coefficients",
nothing@0 59 "Auditory Filter Bank Temporal Envelopes",
nothing@0 60 "Rate-scale-frequency Features",
nothing@0 61 "Phase Space Features"
nothing@0 62 ]
nothing@0 63
nothing@0 64 domains = {
nothing@0 65 "Zero Crossing Rate": 'temporal',
nothing@0 66 "Linear Predictive Coding": 'frequency',
nothing@0 67 "Mel-scale Frequency Cepstral Coefficients": 'cepstral',
nothing@0 68 "Auditory Filter Bank Temporal Envelopes": 'modulation frequency',
nothing@0 69 "Rate-scale-frequency Features": 'eigendomain',
nothing@0 70 "Phase Space Features": 'phase space'
nothing@0 71 }
nothing@0 72
nothing@0 73 abbr = {
nothing@0 74 "Zero Crossing Rate": "ZCR",
nothing@0 75 "Mel-scale Frequency Cepstral Coefficients": "MFCC",
nothing@0 76 "Linear Predictive Coding": "LPC",
nothing@0 77 "Linear Prediction Cepstral Coefficients": "LPCC",
nothing@0 78 "Zero crossing peak amplitudes": "ZCPA",
nothing@0 79 "Line spectral frequencies": "LSF",
nothing@0 80 "Short-time energy": "STE",
nothing@0 81 "Amplitude descriptor": "AD",
nothing@0 82 "Adaptive time frequency transform": "ATFT",
nothing@0 83 "Daubechies Wavelet coefficient histogram": "DWCH",
nothing@0 84 "Spectral Flux": "SF",
nothing@0 85 "Group delay function": "GDF",
nothing@0 86 "Modified group delay function": "MGDF",
nothing@0 87 "Spectral centroid": "SC",
nothing@0 88 "Subband spectral flux": "SSF",
nothing@0 89 "Perceptual linear prediction": "PLP"
nothing@0 90 }
nothing@0 91
nothing@0 92 appdom = {
nothing@0 93 'ASR': "Speech Recognition",
nothing@0 94 'ESR': "Environmental Sound Recognition",
nothing@0 95 'MIR': "Music Information Retrieval",
nothing@0 96 'AS': "Audio Segmentation",
nothing@0 97 'FP': "Fingerprinting",
nothing@0 98 'VAR': "Several",
nothing@0 99 'EXC': ""
nothing@0 100 }
nothing@0 101
nothing@0 102 domain = ""
nothing@0 103 domainIndex = 0
nothing@0 104 compdict = {}
nothing@0 105
nothing@0 106 graph.add((
nothing@0 107 URIRef(local + 'MathematicalOperation'),
nothing@0 108 RDF.type,
nothing@0 109 OWL.Class
nothing@0 110 ))
nothing@0 111
nothing@0 112 graph.add((
nothing@0 113 URIRef(local + 'Filter'),
nothing@0 114 RDF.type,
nothing@0 115 OWL.Class
nothing@0 116 ))
nothing@0 117 graph.add((
nothing@0 118 URIRef(local + 'Filter'),
nothing@0 119 RDFS.subClassOf,
nothing@0 120 URIRef(local + 'MathematicalOperation')
nothing@0 121 ))
nothing@0 122
nothing@0 123 graph.add((
nothing@0 124 URIRef(local + 'Transformation'),
nothing@0 125 RDF.type,
nothing@0 126 OWL.Class
nothing@0 127 ))
nothing@0 128 graph.add((
nothing@0 129 URIRef(local + 'Transformation'),
nothing@0 130 RDFS.subClassOf,
nothing@0 131 URIRef(local + 'MathematicalOperation')
nothing@0 132 ))
nothing@0 133 graph.add((
nothing@0 134 URIRef(local + 'Aggregation'),
nothing@0 135 RDF.type,
nothing@0 136 OWL.Class
nothing@0 137 ))
nothing@0 138 graph.add((
nothing@0 139 URIRef(local + 'Aggregation'),
nothing@0 140 RDFS.subClassOf,
nothing@0 141 URIRef(local + 'MathematicalOperation')
nothing@0 142 ))
nothing@0 143
nothing@0 144 for filename in ['filters', 'trans', 'aggr']:
nothing@0 145 compsuper = filename.replace('filters', 'Filter').replace('trans', 'Transformation').replace('aggr', 'Aggregation')
nothing@0 146 for line in [line.strip() for line in open(basedir + 'pdfextract/' + filename + '.txt')]:
nothing@0 147 compname = line[2:]
nothing@0 148 compidref = URIRef(local + compname.replace(' ', '').replace('(', '').replace(')', '').replace('-', '').replace(',', ''))
nothing@0 149 graph.add((
nothing@0 150 compidref,
nothing@0 151 RDF.type,
nothing@0 152 OWL.Class
nothing@0 153 ))
nothing@0 154 graph.add((
nothing@0 155 compidref,
nothing@0 156 RDFS.subClassOf,
nothing@0 157 URIRef(local + compsuper)
nothing@0 158 ))
nothing@0 159 graph.add((
nothing@0 160 compidref,
nothing@0 161 RDFS.label,
nothing@0 162 Literal(compname)
nothing@0 163 ))
nothing@0 164 compdict[line[0]] = compidref
nothing@0 165
nothing@0 166 graph.add((
nothing@0 167 URIRef(local + 'Signal'),
nothing@0 168 RDF.type,
nothing@0 169 OWL.Class
nothing@0 170 ))
nothing@0 171
nothing@0 172 graph.add((
nothing@0 173 URIRef(local + 'Feature'),
nothing@0 174 RDF.type,
nothing@0 175 OWL.Class
nothing@0 176 ))
nothing@0 177
nothing@0 178 graph.add((
nothing@0 179 URIRef(local + 'Feature'),
nothing@0 180 OWL.subClassOf,
nothing@0 181 URIRef(local + 'Signal'),
nothing@0 182 ))
nothing@0 183
nothing@0 184 for dom in domains.values():
nothing@0 185 idref = URIRef(local + dom.capitalize().replace(' ', '') + 'Feature')
nothing@0 186 graph.add((
nothing@0 187 idref,
nothing@0 188 RDF.type,
nothing@0 189 OWL.Class
nothing@0 190 ))
nothing@0 191 graph.add((
nothing@0 192 idref,
nothing@0 193 RDFS.subClassOf,
nothing@0 194 URIRef(local + 'Feature')
nothing@0 195 ))
nothing@0 196
nothing@0 197 graph.add((
nothing@0 198 URIRef(local + 'PerceptualFeature'),
nothing@0 199 RDF.type,
nothing@0 200 OWL.Class
nothing@0 201 ))
nothing@0 202 graph.add((
nothing@0 203 URIRef(local + 'PerceptualFeature'),
nothing@0 204 RDFS.subClassOf,
nothing@0 205 URIRef(local + 'Feature')
nothing@0 206 ))
nothing@0 207
nothing@0 208 graph.add((
nothing@0 209 URIRef(local + 'FrequencyDomainPerceptualFeature'),
nothing@0 210 RDF.type,
nothing@0 211 OWL.Class
nothing@0 212 ))
nothing@0 213 graph.add((
nothing@0 214 URIRef(local + 'FrequencyDomainPerceptualFeature'),
nothing@0 215 RDFS.subClassOf,
nothing@0 216 URIRef(local + 'FrequencyFeature')
nothing@0 217 ))
nothing@0 218 graph.add((
nothing@0 219 URIRef(local + 'FrequencyDomainPerceptualFeature'),
nothing@0 220 OWL.equivalentClass,
nothing@0 221 URIRef(local + 'PerceptualFeature')
nothing@0 222 ))
nothing@0 223
nothing@0 224 graph.add((
nothing@0 225 URIRef(local + 'FrequencyDomainPhysicalFeature'),
nothing@0 226 RDF.type,
nothing@0 227 OWL.Class
nothing@0 228 ))
nothing@0 229 graph.add((
nothing@0 230 URIRef(local + 'FrequencyDomainPhysicalFeature'),
nothing@0 231 RDFS.subClassOf,
nothing@0 232 URIRef(local + 'FrequencyFeature')
nothing@0 233 ))
nothing@0 234 graph.add((
nothing@0 235 URIRef(local + 'FrequencyDomainPhysicalFeature'),
nothing@0 236 OWL.equivalentClass,
nothing@0 237 URIRef(local + 'PhysicalFeature')
nothing@0 238 ))
nothing@0 239
nothing@0 240
nothing@0 241
nothing@0 242 graph.add((
nothing@0 243 URIRef(local + 'PhysicalFeature'),
nothing@0 244 RDF.type,
nothing@0 245 OWL.Class
nothing@0 246 ))
nothing@0 247 graph.add((
nothing@0 248 URIRef(local + 'PhysicalFeature'),
nothing@0 249 RDFS.subClassOf,
nothing@0 250 URIRef(local + 'Feature')
nothing@0 251 ))
nothing@0 252
nothing@0 253 graph.add((
nothing@0 254 URIRef(local + 'ParametrizedDimensions'),
nothing@0 255 RDF.type,
nothing@0 256 OWL.Class
nothing@0 257 ))
nothing@0 258
nothing@0 259 graph.add((
nothing@0 260 URIRef(local + 'ComputationalComplexity'),
nothing@0 261 RDF.type,
nothing@0 262 OWL.Class
nothing@0 263 ))
nothing@0 264 graph.add((
nothing@0 265 URIRef(local + 'LowComplexity'),
nothing@0 266 RDF.type,
nothing@0 267 OWL.Class
nothing@0 268 ))
nothing@0 269 graph.add((
nothing@0 270 URIRef(local + 'LowComplexity'),
nothing@0 271 RDFS.subClassOf,
nothing@0 272 URIRef(local + 'ComputationalComplexity')
nothing@0 273 ))
nothing@0 274 graph.add((
nothing@0 275 URIRef(local + 'MediumComplexity'),
nothing@0 276 RDF.type,
nothing@0 277 OWL.Class
nothing@0 278 ))
nothing@0 279 graph.add((
nothing@0 280 URIRef(local + 'MediumComplexity'),
nothing@0 281 RDFS.subClassOf,
nothing@0 282 URIRef(local + 'ComputationalComplexity')
nothing@0 283 ))
nothing@0 284 graph.add((
nothing@0 285 URIRef(local + 'HighComplexity'),
nothing@0 286 RDF.type,
nothing@0 287 OWL.Class
nothing@0 288 ))
nothing@0 289 graph.add((
nothing@0 290 URIRef(local + 'HighComplexity'),
nothing@0 291 RDFS.subClassOf,
nothing@0 292 URIRef(local + 'ComputationalComplexity')
nothing@0 293 ))
nothing@0 294
nothing@0 295 graph.add((
nothing@0 296 URIRef(local + 'TemporalScale'),
nothing@0 297 RDF.type,
nothing@0 298 OWL.Class
nothing@0 299 ))
nothing@0 300 graph.add((
nothing@0 301 URIRef(local + 'IntraFrame'),
nothing@0 302 RDF.type,
nothing@0 303 OWL.Class
nothing@0 304 ))
nothing@0 305 graph.add((
nothing@0 306 URIRef(local + 'IntraFrame'),
nothing@0 307 RDFS.subClassOf,
nothing@0 308 URIRef(local + 'TemporalScale')
nothing@0 309 ))
nothing@0 310 graph.add((
nothing@0 311 URIRef(local + 'InterFrame'),
nothing@0 312 RDF.type,
nothing@0 313 OWL.Class
nothing@0 314 ))
nothing@0 315 graph.add((
nothing@0 316 URIRef(local + 'InterFrame'),
nothing@0 317 RDFS.subClassOf,
nothing@0 318 URIRef(local + 'TemporalScale')
nothing@0 319 ))
nothing@0 320 graph.add((
nothing@0 321 URIRef(local + 'Global'),
nothing@0 322 RDF.type,
nothing@0 323 OWL.Class
nothing@0 324 ))
nothing@0 325 graph.add((
nothing@0 326 URIRef(local + 'Global'),
nothing@0 327 RDFS.subClassOf,
nothing@0 328 URIRef(local + 'TemporalScale')
nothing@0 329 ))
nothing@0 330
nothing@0 331
nothing@0 332 graph.add((
nothing@0 333 URIRef(local + 'ApplicationDomain'),
nothing@0 334 RDF.type,
nothing@0 335 OWL.Class
nothing@0 336 ))
nothing@0 337
nothing@0 338 for key in appdom.keys():
nothing@0 339 if appdom[key] != "":
nothing@0 340 idref = URIRef(local + appdom[key].replace(" ", ""))
nothing@0 341 graph.add((
nothing@0 342 idref,
nothing@0 343 URIRef(RDF.type),
nothing@0 344 OWL.Class
nothing@0 345 ))
nothing@0 346 graph.add((
nothing@0 347 idref,
nothing@0 348 RDFS.subClassOf,
nothing@0 349 URIRef(local + 'ApplicationDomain')
nothing@0 350 ))
nothing@0 351
nothing@0 352 #properties
nothing@0 353 graph.add((
nothing@0 354 URIRef(local + "application_domain"),
nothing@0 355 RDF.type,
nothing@0 356 RDF.Property
nothing@0 357 ))
nothing@0 358 graph.add((
nothing@0 359 URIRef(local + "application_domain"),
nothing@0 360 RDFS.range,
nothing@0 361 URIRef(local + 'ApplicationDomain')
nothing@0 362 ))
nothing@0 363 graph.add((
nothing@0 364 URIRef(local + "application_domain"),
nothing@0 365 VS['term_status'],
nothing@0 366 Literal("testing")
nothing@0 367 ))
nothing@0 368 graph.add((
nothing@0 369 URIRef(local + "application_domain"),
nothing@0 370 RDFS.comment,
nothing@0 371 Literal("application domain property")
nothing@0 372 ))
nothing@0 373
nothing@0 374
nothing@0 375
nothing@0 376 graph.add((
nothing@0 377 URIRef(local + "semantic_interpretation"),
nothing@0 378 RDF.type,
nothing@0 379 RDF.Property
nothing@0 380 ))
nothing@0 381 graph.add((
nothing@0 382 URIRef(local + "semantic_interpretation"),
nothing@0 383 VS['term_status'],
nothing@0 384 Literal("testing")
nothing@0 385 ))
nothing@0 386
nothing@0 387 graph.add((
nothing@0 388 URIRef(local + "computational_complexity"),
nothing@0 389 RDF.type,
nothing@0 390 RDF.Property
nothing@0 391 ))
nothing@0 392 graph.add((
nothing@0 393 URIRef(local + "computational_complexity"),
nothing@0 394 VS['term_status'],
nothing@0 395 Literal("testing")
nothing@0 396 ))
nothing@0 397
nothing@0 398 graph.add((
nothing@0 399 URIRef(local + "computational_complexity"),
nothing@0 400 RDFS.range,
nothing@0 401 URIRef(local + 'ComputationalComplexity')
nothing@0 402 ))
nothing@0 403
nothing@0 404 graph.add((
nothing@0 405 URIRef(local + "psychoacoustic_model"),
nothing@0 406 RDF.type,
nothing@0 407 RDF.Property
nothing@0 408 ))
nothing@0 409 graph.add((
nothing@0 410 URIRef(local + "psychoacoustic_model"),
nothing@0 411 RDFS.range,
nothing@0 412 XSD.Boolean
nothing@0 413 ))
nothing@0 414 graph.add((
nothing@0 415 URIRef(local + "psychoacoustic_model"),
nothing@0 416 VS['term_status'],
nothing@0 417 Literal("testing")
nothing@0 418 ))
nothing@0 419
nothing@0 420
nothing@0 421 graph.add((
nothing@0 422 URIRef(local + "dimensions"),
nothing@0 423 RDF.type,
nothing@0 424 RDF.Property
nothing@0 425 ))
nothing@0 426 graph.add((
nothing@0 427 URIRef(local + "dimensions"),
nothing@0 428 RDFS.range,
nothing@0 429 XSD.Integer
nothing@0 430 ))
nothing@0 431 graph.add((
nothing@0 432 URIRef(local + "dimensions"),
nothing@0 433 RDFS.range,
nothing@0 434 URIRef(local + 'ParametrizedDimensions')
nothing@0 435 ))
nothing@0 436
nothing@0 437 graph.add((
nothing@0 438 URIRef(local + "temporal_scale"),
nothing@0 439 RDF.type,
nothing@0 440 RDF.Property
nothing@0 441 ))
nothing@0 442 graph.add((
nothing@0 443 URIRef(local + "temporal_scale"),
nothing@0 444 RDFS.range,
nothing@0 445 URIRef(local + 'TemporalScale')
nothing@0 446 ))
nothing@0 447
nothing@0 448 for name in names:
nothing@0 449 id = local + (name.replace(' ','').replace('-',''))
nothing@0 450
nothing@0 451 if name == order[domainIndex]:
nothing@0 452 domain = domains[order[domainIndex]]
nothing@0 453 domainIndex += 1
nothing@0 454
nothing@0 455 graph.add(( URIRef(id),
nothing@0 456 URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
nothing@0 457 OWL.Class
nothing@0 458 ))
nothing@0 459
nothing@0 460 graph.add((
nothing@0 461 URIRef(id),
nothing@0 462 VS['term_status'],
nothing@0 463 Literal("testing")
nothing@0 464 ))
nothing@0 465
nothing@0 466 if domain == "frequency":
nothing@0 467 if word[1] == 'Y':
nothing@0 468 temp = URIRef(local + 'FrequencyDomainPerceptualFeature')
nothing@0 469 else:
nothing@0 470 temp = URIRef(local + 'FrequencyDomainPhysicalFeature')
nothing@0 471
nothing@0 472 graph.add((
nothing@0 473 URIRef(id),
nothing@0 474 RDFS.subClassOf,
nothing@0 475 URIRef(temp)
nothing@0 476 ))
nothing@0 477
nothing@0 478 else:
nothing@0 479 graph.add((
nothing@0 480 URIRef(id),
nothing@0 481 RDFS.subClassOf,
nothing@0 482 URIRef(local + domain.capitalize().replace(' ', '') + 'Feature')
nothing@0 483 ))
nothing@0 484
nothing@0 485 graph.add((
nothing@0 486 URIRef(id),
nothing@0 487 #URIRef(local + 'feature'),
nothing@0 488 RDFS.label,
nothing@0 489 Literal(name.replace(' ','').replace('-',''))
nothing@0 490 ))
nothing@0 491
nothing@0 492 graph.add((
nothing@0 493 URIRef(id),
nothing@0 494 RDFS.comment,
nothing@0 495 Literal(name + " feature")
nothing@0 496 ))
nothing@0 497
nothing@0 498 graph.add((
nothing@0 499 URIRef(id),
nothing@0 500 RDFS.label,
nothing@0 501 Literal(name)
nothing@0 502 ))
nothing@0 503
nothing@0 504 word = cat[i].split(' ')
nothing@0 505
nothing@0 506 temp = {
nothing@0 507 'I': URIRef(local+'IntraFrame'),
nothing@0 508 'X': URIRef(local+'InterFrame'),
nothing@0 509 'G': URIRef(local+'Global')
nothing@0 510 }[word[0]]
nothing@0 511
nothing@0 512 graph.add((
nothing@0 513 URIRef(id),
nothing@0 514 URIRef(local + 'temporal_scale'),
nothing@0 515 temp
nothing@0 516 ))
nothing@0 517
nothing@0 518
nothing@0 519 if word[1] == 'Y':
nothing@0 520 temp = URIRef(local + 'PerceptualFeature')
nothing@0 521 else:
nothing@0 522 temp = URIRef(local + 'PhysicalFeature')
nothing@0 523
nothing@0 524 graph.add((
nothing@0 525 URIRef(id),
nothing@0 526 URIRef(local + "semantic_interpretation"),
nothing@0 527 temp
nothing@0 528 ))
nothing@0 529
nothing@0 530 if word[2] == 'Y':
nothing@0 531 graph.add((
nothing@0 532 URIRef(id),
nothing@0 533 URIRef(local + "psychoacoustic_model"),
nothing@0 534 Literal(True)
nothing@0 535 ))
nothing@0 536 else:
nothing@0 537 graph.add((
nothing@0 538 URIRef(id),
nothing@0 539 URIRef(local + "psychoacoustic_model"),
nothing@0 540 Literal(False)
nothing@0 541 ))
nothing@0 542
nothing@0 543 temp = {
nothing@0 544 'L': URIRef(local + 'LowComplexity'),
nothing@0 545 'M': URIRef(local + 'MediumComplexity'),
nothing@0 546 'H': URIRef(local + 'HighComplexity')
nothing@0 547 }[word[3]]
nothing@0 548
nothing@0 549 graph.add((
nothing@0 550 URIRef(id),
nothing@0 551 URIRef(local + "computational_complexity"),
nothing@0 552 temp
nothing@0 553 ))
nothing@0 554
nothing@0 555 if word[4] == 'V':
nothing@0 556 temp = URIRef(local + 'ParametrizedDimensions')
nothing@0 557 else:
nothing@0 558 temp = Literal(int(word[4]))
nothing@0 559
nothing@0 560 graph.add((
nothing@0 561 URIRef(id),
nothing@0 562 URIRef(local + 'dimensions'),
nothing@0 563 temp
nothing@0 564 ))
nothing@0 565
nothing@0 566 temp = appdom[word[5]]
nothing@0 567
nothing@0 568 if temp != '':
nothing@0 569 graph.add((
nothing@0 570 URIRef(id),
nothing@0 571 URIRef(local + "application_domain"),
nothing@0 572 URIRef(local + temp.replace(" ", ""))
nothing@0 573 ))
nothing@0 574
nothing@0 575 steps = sig[i].split(' ')
nothing@0 576
nothing@0 577 for key in steps:
nothing@0 578 graph.add((
nothing@0 579 URIRef(id),
nothing@0 580 URIRef(local + 'computation'),
nothing@0 581 compdict[key]
nothing@0 582 ))
nothing@0 583
nothing@0 584 if name.find('MPEG-7') >= 0:
nothing@0 585 graph.add((
nothing@0 586 URIRef(id),
nothing@0 587 URIRef(local + 'computedIn'),
nothing@0 588 Literal('MPEG-7')
nothing@0 589 ))
nothing@0 590 #graph.add((
nothing@0 591 # URIRef(local+name.replace('MPEG-7', '').lower().lstrip().replace(' ', '_')+'_feature'),
nothing@0 592 # RDF.type,
nothing@0 593 # URIRef(id)
nothing@0 594 #))
nothing@0 595
nothing@0 596 if name in abbr.keys():
nothing@0 597 graph.add((
nothing@0 598 URIRef(id),
nothing@0 599 URIRef(local + 'abbreviation'),
nothing@0 600 Literal(abbr[name])
nothing@0 601 ))
nothing@0 602
nothing@0 603
nothing@0 604 i += 1
nothing@0 605
nothing@0 606
nothing@0 607
nothing@0 608 graph.serialize('/Users/alo/MusicOntology/features/baseOnto.n3', format='n3')
nothing@0 609 graph.serialize('/Users/alo/MusicOntology/features/baseOnto.rdf')