Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
biseau
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
8
Issues
8
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
BOURNEUF Lucas
biseau
Commits
aca5d86c
Commit
aca5d86c
authored
Dec 12, 2018
by
Lucas Bourneuf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
einstein riddle data + new config showing its use
parent
165ceade
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
3 deletions
+73
-3
Makefile
Makefile
+4
-0
biseau/core.py
biseau/core.py
+3
-2
biseau/module_loader.py
biseau/module_loader.py
+24
-1
configs/einstein-riddle.json
configs/einstein-riddle.json
+20
-0
contexts/einstein-rev-riddle.lp
contexts/einstein-rev-riddle.lp
+21
-0
contexts/einstein-riddle.lp
contexts/einstein-riddle.lp
+1
-0
No files found.
Makefile
View file @
aca5d86c
...
...
@@ -5,6 +5,10 @@ VERBOSITY=
run-test
:
python
-m
biseau scripts/example.lp scripts/black_theme.json
-o
out/out.png
$(VERBOSITY)
run-fca-test
:
python
-m
biseau
-c
./configs/concept-lattice.json
-o
out/concept-lattice.png
$(VERBOSITY)
run-einstein-test
:
python
-m
biseau
-c
./configs/einstein-riddle.json
-o
out/einstein-riddle.png
$(VERBOSITY)
run-config-test
:
python
-m
biseau
-c
./configs/simple.json
$(VERBOSITY)
python
-m
biseau
-c
./configs/concept-lattice.json
-o
out/concept-lattice.png
$(VERBOSITY)
...
...
biseau/core.py
View file @
aca5d86c
...
...
@@ -68,9 +68,10 @@ def build_pipeline_from_json(jsondata:dict, verbosity:int=0) -> [Script]:
for
item
in
jsondata
:
yield
from
build_pipeline_from_json
(
item
)
for
name
,
options
in
jsondata
.
items
():
scripts
=
module_loader
.
build_scripts_from_file
(
name
)
scripts
=
module_loader
.
build_scripts_from_file
(
name
,
options
)
for
script
in
scripts
:
script
.
options_values
.
update
(
options
)
if
isinstance
(
options
,
dict
):
script
.
options_values
.
update
(
options
)
yield
script
build_pipeline
.
from_configfile
=
build_pipeline_from_configfile
...
...
biseau/module_loader.py
View file @
aca5d86c
...
...
@@ -58,7 +58,7 @@ def gen_scripts_in_dir(dirname:str, extensions:[str]=('py', 'lp', 'json'),
)
def
build_scripts_from_file
(
fname
:
str
)
->
[
Script
]:
def
build_scripts_from_file
(
fname
:
str
,
options
:
dict
=
{}
)
->
[
Script
]:
name
,
ext
=
os
.
path
.
splitext
(
fname
)
if
ext
==
'.json'
:
yield
from
build_scripts_from_json_file
(
fname
)
...
...
@@ -74,6 +74,13 @@ def build_scripts_from_file(fname:str) -> [Script]:
print
(
'SCRIPT ERROR:'
,
str
(
err
))
elif
ext
==
'.lp'
:
yield
build_asp_script_from_name
(
fname
)
elif
fname
.
upper
().
startswith
(
'ASP'
):
if
isinstance
(
options
,
(
list
,
tuple
,
str
)):
yield
from
build_scripts_from_asp_code
(
options
)
else
:
print
(
f
"Unknow type for ASP code:
{
type
(
options
)
}
"
)
else
:
print
(
f
"WARNING file '
{
fname
}
' was not recognized"
)
def
build_scripts_from_dir
(
base_dir
:
str
=
'scripts'
)
->
iter
:
...
...
@@ -179,6 +186,22 @@ def build_scripts_from_json_file(fname:str) -> [Script]:
""
.
format
(
fname
,
type
(
data
)))
def
build_scripts_from_asp_code
(
data
:
str
or
list
)
->
[
Script
]:
"""Yield one Script instance initialized with given source code"""
if
isinstance
(
data
,
(
tuple
,
list
)):
# multiple scripts
for
source
in
data
:
yield
from
build_scripts_from_asp_code
(
source
)
elif
isinstance
(
data
,
str
):
# only one
yield
build_script_from_json
({
'name'
:
'inline ASP code'
,
'ASP'
:
data
,
'description'
:
'inline ASP code'
,
'inputs'
:
[],
'outputs'
:
[],
# TODO: search for #show's in the file
})
else
:
raise
ScriptError
(
f
"Given ASP source of type
{
type
(
data
)
}
can't be handled."
)
def
build_script_from_json
(
module_def
:
dict
)
->
Script
:
"""From given JSON build a Script instance"""
# let's use a class as placeholder for a module.
...
...
configs/einstein-riddle.json
0 → 100644
View file @
aca5d86c
{
"scripts/context.py"
:
{
"fname"
:
"contexts/einstein-rev-riddle.lp"
},
"ASP1"
:
"ans(A):- rule(A,_).
\n
r(R):- rule(_,R).
\n
rel(R,A):- ans(A) ; r(R) ; not rule(A,R)."
,
"scripts/build_concepts.py"
:
{
"type"
:
"formal"
,
"careful_parsing"
:
true
,
"supremum_and_infimum"
:
true
,
"remove_symmetry"
:
false
},
"ASP2"
:
"label(X,
\"\"
) :- concept(X). shape(X,circle):- concept(X)."
,
"scripts/galois-lattice.json"
:
{},
"scripts/show_galois_lattice.py"
:
{
"dpi"
:
300
,
"use_aoc_as_label"
:
true
,
"concept_uid"
:
false
},
"scripts/black_theme.json"
:
{}
}
contexts/einstein-rev-riddle.lp
0 → 100644
View file @
aca5d86c
rel(ans1,1).
rel(ans1,4).
rel(ans1,5).
rel(ans1,7).
rel(ans1,14).
rel(ans2,1).
rel(ans2,15).
rel(ans3,4).
rel(ans3,5).
rel(ans3,7).
rel(ans3,8).
rel(ans4,4).
rel(ans4,9).
rel(ans5,5).
rel(ans5,9).
rel(ans6,5).
rel(ans6,15).
rel(ans7,8).
rel(ans7,15).
rel(ans8,14).
rel(ans8,15).
contexts/einstein-riddle.lp
0 → 120000
View file @
aca5d86c
/home/lbourneu/programs/biseau/contexts/einstein-riddle.lp
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment