Build a Relational Context Family (.rcft) from a set of csv files (IMPORT)


We show here how to build a Relational Context Family (with the .rcft format) from a set of csv files. Each of these csv files describes either one formal context, or one relational context. They are supposed to be coherent in the final file. This means that each relational context should connect one formal context to another one (or to itself).


INPUT

The example considers 5 csv files containing 3 formal contexts (FC) and 2 relational contexts (RC):

- FC with 10 pizzas with no specific description (file pizza.csv)

- FC with 14 ingredients, described by attributes indicating 1) the season it is better to eat them and 2) diets that allow to eat them (file ingredient.csv)

- FC with 5 pizzerias with no specific description (file pizzeria.csv)

- RC connecting pizzas to the ingredients they contain (file pizza2ingredient.csv)

- RC connecting pizzerias to the pizzas they offer (file pizzeria2pizza.csv)


FORMAT examples of the csv files

They simply contain  an unnamed table with attributes in the first row and objects in the first column. Various separators can be used, here we use the semicolon. Commas can be used too (see the command description).


Format1: Cell (0,0) is empty (its content will not be used). Cells contain 0 or 1 depending if an object owns or not an attribute. 

;summer;winter;vegan;vege;medit

tomato;1;0;1;1;1

eggplant;1;0;1;1;1

zucchini;1;0;1;1;1

redpepper;1;0;1;1;1


Format2: Cells contain nothing or a ‘x’ depending if an object owns or not an attribute.

Below there is an excerpt of ingredient.csv. tomato, eggplant, zucchini and redpepper are the objects. summer, winter, vegan, vege and medit are the attributes.


;summer;winter;vegan;vege;medit

tomato;x;;x;x;x

eggplant;x;;x;x;x

zucchini;x;;x;x;x

redpepper;x;;x;x;x


OUPUT


The output is a file pizzasRCFT.rcft which has the right format to apply later the RCA command (https://www.lirmm.fr/fca4j/RCA.html) and create a family of conceptual structures (concept lattice, AOC-poset, Iceberg).

 It can also be used to run RCAexplore tool (http://dataqual.engees.unistra.fr/logiciels/rcaExplore).

The quantifier ‘exist’ is used in this example. Other quantifiers are available (see the command description).


COMMANDS

NOTA: The commands are presented for a jar file called fca4j.jar. It has been transposed depending the fca4j jar version which is used.  

STEP 1. Integrate ingredient.csv into pizzasRCFT.rcft. pizzasRCFT.rcft is created as it does not exist initially). The given name for this FC will be ’ingredient’ (after -n option). The input format is CSV (after -x). The CSV separator is a semicolon (after -s). 

java -jar  fca4j.jar family pizzasRCFT.rcft -a IMPORT ingredient.csv -n ingredient -x CSV -s SEMICOLON

STEP 2. Integrate pizzeria.csv into pizzasRCFT.rcft. 

java -jar  fca4j.jar family pizzasRCFT.rcft -a IMPORT pizzeria.csv -n pizzeria -x CSV -s SEMICOLON

STEP 3. Integrate pizza.csv into pizzasRCFT.rcft. 

java -jar  fca4j.jar family pizzasRCFT.rcft -a IMPORT pizza.csv -n pizza -x CSV -s SEMICOLON

STEP 4. Integrate pizza2ingredient.csv into pizzasRCFT.rcft, with the quantifier ‘exist’.

java -jar  fca4j.jar family pizzasRCFT.rcft -a IMPORT pizza2ingredient.csv -n pizza2ingredient -x CSV -v -s SEMICOLON -op exist -source pizza -target ingredient

STEP 5.  Integrate pizza2ingredient.csv into pizzasRCFT.rcft, with the quantifier ‘exist’.

java -jar  fca4j.jar family pizzasRCFT.rcft -a IMPORT pizzeria2pizza.csv -n pizzeria2pizza -x CSV -v -s SEMICOLON -op exist -source pizzeria -target pizza

EXTRA STEP (TEST)


After the construction of pizzasRCFT.rcft, you can test if it is in right form with the following command that build, in the directory ./results (created before this command is applied), the associated concept lattices. For more information, look at the RCA command (https://www.lirmm.fr/fca4j/RCA.html).


EXTRA STEP1 (create the result):         java -jar fca4j.jar RCA ./pizzasRCFT.rcft ./results -v -a ADD_EXTENT


EXTRA STEP2 (obtain a pdf image of the result):         dot -Tpdf results/step3.dot -o results/resultat.pdf