ko444evnik (ko444evnik) wrote in dot15926,
ko444evnik
ko444evnik
dot15926

Некоторые бесчеловечные эксперименты над .15926 Editor v1.2.


Мелкая программка на Python, которая при исполнении в консоли редактора...

# ko4evnik 2013-03-01

import re
import iso15926.kb as kb

part2 = kb.part2_itself

outfile = file('15926_to_graphvize.dot', 'w')
outfile.write('digraph graph15926entities{\nrankdir=LR\nnode[shape=box]\n')

entities=sorted(kb.part2_itself)

regex = re.compile('part2:')

for entity in entities:
  name = regex.sub('',entity)
  outfile.write(name+' [label="'+name+'"]\n')

outfile.write('\nedge[style=filled,arrowhead=dot]\n')

for entity in entities:
  superclasses = kb.part2_itself[entity]['supertypes']
  name_entity = regex.sub('',entity)
  for superclass in superclasses:
    name_superclass = regex.sub('',superclass )
    outfile.write(name_superclass +' -> '+name_entity+'\n')

outfile.write('\nedge[style=dotted,arrowhead=normal,arrowtail=none]\n')

for entity in entities:

 name_entity = regex.sub('',entity)  
 if 'classifier' in kb.part2_itself[entity]: 
   classifiers = kb.part2_itself[entity]['classifier']
   for classifier in classifiers:
     name_classifier  = regex.sub('',classifier )
     outfile.write(name_classifier +' -> '+name_entity+'\n')

outfile.write('\n}')
outfile.close()


...пишет такой вот .dot-файл
по которому Graphviz рисует такую вот картинку 4000х5000:
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 31 comments