Commit | Line | Data |
51650966 |
1 | #include <mx> |
2 | #include <table_utils> |
3 | |
4 | procedure main() { |
5 | exec(findGroupings) -- findGroupings | findSources | findClasses |
6 | } |
7 | |
8 | procedure exec(task) { |
9 | input = io.read("*all") |
10 | output = process(input,task) |
11 | print(output) |
12 | } |
13 | |
14 | /* ---------- Base vocabulary --------------------------------------------- */ |
15 | vocabulary V { |
16 | type Manuscript |
17 | type Variant |
18 | CopiedBy(Manuscript,Manuscript) |
19 | VariantOf(Manuscript): Variant |
20 | } |
21 | |
22 | /* ---------- Three tasks ------------------------------------------------- */ |
23 | |
24 | #include "findGroupings.idp" |
25 | #include "findSources.idp" |
26 | #include "findClasses.idp" |
27 | |
28 | /* ---------- Procedures for processing ----------------------------------- */ |
29 | #include "readData.idp" |
30 | |
31 | /** Process input in json format **/ |
32 | procedure process(input,task) { |
9cb32653 |
33 | require("json") |
51650966 |
34 | local input = json.decode(input) |
35 | local stemma = readStemma(input.graph) |
36 | local samples = readSamples(stemma,input.groupings) |
37 | local result = task(samples) |
38 | return json.encode(result) |
39 | } |
40 | |
41 | /** Process input from two files **/ |
42 | procedure processFiles(stemmafile,samplefile,task) { |
9cb32653 |
43 | require("json") |
51650966 |
44 | local f = assert(io.open(stemmafile,"r")) |
45 | local stemma = readStemma(f:read("*all")) |
46 | f:close() |
47 | local f = assert(io.open(samplefile,"r")) |
48 | local samples = readSamples(stemma,json.decode(f:read("*all"))) |
49 | f:close() |
50 | local result = task(samples) |
51 | return json.encode(result) |
52 | } |
53 | |