-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgen_lattice.wls
More file actions
executable file
·58 lines (42 loc) · 1.67 KB
/
gen_lattice.wls
File metadata and controls
executable file
·58 lines (42 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env -S wolframscript -script
SCRIPTDIR = AbsoluteFileName[DirectoryName[$ScriptCommandLine[[1]]]];
Get[SCRIPTDIR <> "/fca.wl"];
(*CLASSPATH = "//Applications/conexp-1.3/*";*)
CLASSPATH = SCRIPTDIR <> "/../bin/conexp-1.3/";
DBFILE = $ScriptCommandLine[[2]];
CONTEXT = $ScriptCommandLine[[3]];
LANG = $ScriptCommandLine[[4]];
DEBUG = Length[$ScriptCommandLine] > 4;
DEBUGOUTPUT = "stderr";
FcaInit["ClassPath" -> CLASSPATH,
"DebugOutput" -> DEBUGOUTPUT];
result = FcaImportDBContextAsContext[DBFILE, CONTEXT, LANG];
context = result[["context"]];
model = result[["model"]];
attributes = result[["attributes"]];
objects = result[["objects"]];
objectsByName = result[["objectsByName"]];
DEBUG && FcaDebugContext[context, objects, attributes];
result = FcaComputeLattice[model];
concepts = result[["lattice"]];
implications = result[["implications"]];
associations = result[["associations"]];
DEBUG && FcaDebugConcepts[concepts, attributes, objects];
DEBUG && FcaDebugImplications[implications, attributes];
DEBUG && FcaDebugAssociations[associations, attributes];
acontext = FcaContextToAssociation[context, objects, attributes];
lconcepts = FcaConceptsToList[concepts, objects, attributes];
lnodes = FcaConceptsToAssociationList[concepts, lconcepts, objectsByName];
anodes = Association[
Map[Function[anode, anode[["hash"]] -> anode], lnodes]
];
DEBUG && FcaDebug["\nanodes:\n\n", anodes, "\n\n"]
links = FcaGetNodeLinks[lnodes, anodes];
DEBUG && FcaDebug["links:\n\n", links, "\n\n"]
Export[Streams["stdout"],
Association[
"context" -> acontext,
"concepts" -> lconcepts,
"nodes" -> lnodes,
"links" -> links
], "JSON"];