コード例 #1
0
ファイル: RDFtoGraphs.py プロジェクト: FieldDB/desmeme
import tdag
from tdag import rdfGraph, Namespace, RDF, tdag, conflate, process_template, prettyName
from tdag import simUI_d, get_distances, to_nex, draw_graphs, full_grid, process_templates, draw_components


rdfTemplates = rdfGraph()

instanceNS = Namespace("http://purl.org/linguistics/jcgood/template#")
rdfTemplates.load("./template.rdf")

# Get template IDs from RDF
templatesGenerator = rdfTemplates.subjects(RDF.type, instanceNS['desmeme'])

templates = []
for template in templatesGenerator:
	templates.append(template)
			
gTemplates = process_templates(templates, rdfTemplates)

# NOTE: CAN NO LONGER GO DIRECTLY TO PNG or PDF; MUST MANUALLY PROCESS .dot FOR NOW
#graphfolder = "/Volumes/Obang/MyDocuments/Linearity/template_ontology/Graphs/"
#graphfolder = "/Users/jcgood/Desktop/Graphs/"
#graphfolder = "/Volumes/Obang/MyDocuments/Linearity/TemplatesBook/Graphs/"

graphfolder = "/Users/jcgood/Dropbox/TemplatesBook/Graphs/"

draw_graphs(gTemplates, graphfolder)


graphfolder = "/Users/jcgood/Dropbox/TemplatesBook/ComponentGraphs/"
draw_components(gTemplates, graphfolder)
コード例 #2
0
ファイル: PCGtoDOT-Example.py プロジェクト: FieldDB/desmeme
except: pass

try: g2.add_node("component3", "")
except: pass
try: g2.add_node("elastic1", "")
except: pass

try: g2.add_edge(("component3", "elastic1"), label=" ELASTICITY")
except: pass

try: g2.add_node("component4", "")
except: pass
try: g2.add_node("elastic2", "")
except: pass

try: g2.add_edge(("component4", "elastic2"), label=" ELASTICITY")
except: pass

# To self: I spent a long time working out why .dot files had attributes
# such as width and pos that I didn't have in my representation.
# This "write_dot" function is a special pydot feature that doesn't
# exist as an actual method but is, rather, generated automatically based on the extension (sort of).
# The internal representation is passed through the dot program and the output adds these extra features.
# This seems to be the same as the "default" ones if they aren't added.
# I looked into this to see how I should be customizing node placement.
# I guess I'd have to delve deep into dot to find out at this point.
# See comparison method in tdag for where this write_dot function is called.
#pcgfolder = "/Volumes/Obang/MyDocuments/Linearity/TemplatesBook/PCGs/"
pcgfolder = "/Users/jcgood/Dropbox/TemplatesBook/PCGs/"
draw_graphs([pcgweighted, pcglabels, g1, g2], pcgfolder)
コード例 #3
0
ファイル: PCGtoDot.py プロジェクト: FieldDB/desmeme
try: g2.add_edge(("component4", "stable2"), label=" STABILITY")
except: pass

try: g2.add_node("component3", "")
except: pass
try: g2.add_node("elastic1", "")
except: pass

try: g2.add_edge(("component3", "elastic1"), label=" ELASTICITY")
except: pass

try: g2.add_node("component4", "")
except: pass
try: g2.add_node("elastic2", "")
except: pass

try: g2.add_edge(("component4", "elastic2"), label=" ELASTICITY")
except: pass

# To self: I spent a long time working out why .dot files had attributes
# such as width and pos that I didn't have in my representation.
# This "write_dot" function is a special pydot feature that doesn't
# exist as an actual method but is, rather, generated automatically based on the extension (sort of).
# The internal representation is passed through the dot program and the output adds these extra features.
# This seems to be the same as the "default" ones if they aren't added.
# I looked into this to see how I should be customizing node placement.
# I guess I'd have to delve deep into dot to find out at this point.
# See comparison method in tdag for where this write_dot function is called.
draw_graphs([pcg, pcgnolabels, g1, g2], "./")