1 /** Create structure with stemma data, read from dot string **/
2 procedure readStemma(stemmastring) {
3 local stemma = newstructure(V,"stemma")
4 local pipe = assert(io.popen("echo '"..stemmastring.."' | dot -Tplain"))
5 local s = pipe:read("*all")
7 -- Add nodes to the stemma.
9 for node in string.gmatch(s,"node%s(%S+)%s") do
12 stemma[V::Manuscript.type] = t
13 -- Add edges to the stemma.
14 for n1,n2 in string.gmatch(s,"edge%s(%S+)%s(%S+)%s") do
15 maketrue(stemma[V::CopiedBy],{n1,n2})
17 -- There are no more edges than the ones given.
18 stemma[V::CopiedBy].cf = stemma[V::CopiedBy].pf
22 /** Create table of structures with sample data **/
23 procedure readSamples(stemma,sampletable) {
25 for i,groupings in ipairs(sampletable) do
26 local sample = newstructure(V,"sample"..tostring(i))
27 sample[V::Manuscript.type] = stemma[V::Manuscript.type]
28 sample[V::CopiedBy] = stemma[V::CopiedBy]
29 sample[V::Variant.type] = range(1,#groupings)
30 -- Add known equivalence relations to the sample.
31 for variant,grouping in ipairs(groupings) do
32 for _,element in ipairs(grouping) do
33 maketrue(sample[V::VariantOf].graph,{element,variant})
36 table.insert(samples,sample)
41 /** Show stemma using dot **/
42 procedure showStemma(stemmastring) {
43 local f = assert(io.open("data/test.dot","w"))
46 os.execute("dotty data/test.dot &")