001package conexp.fx.core.algorithm.nextclosures; 002 003/*- 004 * #%L 005 * Concept Explorer FX 006 * %% 007 * Copyright (C) 2010 - 2019 Francesco Kriegel 008 * %% 009 * This program is free software: you can redistribute it and/or modify 010 * it under the terms of the GNU General Public License as 011 * published by the Free Software Foundation, either version 3 of the 012 * License, or (at your option) any later version. 013 * 014 * This program is distributed in the hope that it will be useful, 015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 017 * GNU General Public License for more details. 018 * 019 * You should have received a copy of the GNU General Public 020 * License along with this program. If not, see 021 * <http://www.gnu.org/licenses/gpl-3.0.html>. 022 * #L% 023 */ 024 025import java.io.File; 026import java.io.IOException; 027import java.util.Collections; 028import java.util.HashSet; 029import java.util.Set; 030import java.util.concurrent.Executors; 031 032import conexp.fx.core.context.Context; 033import conexp.fx.core.context.Implication; 034import conexp.fx.core.context.MatrixContext; 035import conexp.fx.core.importer.CXTImporter; 036import conexp.fx.core.math.SetClosureOperator; 037 038public class ICFCA2019 { 039 040 public static void main(String[] args) throws IOException { 041 final MatrixContext<String, String> cxt = 042 CXTImporter.read(new File("/Users/francesco/workspace/LaTeX/icfca2019-join-implications/example1.cxt")); 043 cxt.colHeads().forEach(System.out::println); 044 cxt.rowHeads().forEach(System.out::println); 045 final Set<String> pset = new HashSet<>(); 046 pset.add("$\\textsf{Abrupt Onset}$"); 047 pset.add("$\\textsf{Fever}$"); 048 pset.add("$\\textsf{Aches}$"); 049 pset.add("$\\textsf{Chills}$"); 050 pset.add("$\\textsf{Fatigue}$"); 051 pset.add("$\\textsf{Sneezing}$"); 052 pset.add("$\\textsf{Cough}$"); 053 pset.add("$\\textsf{Stuffy Nose}$"); 054 pset.add("$\\textsf{Sore Throat}$"); 055 pset.add("$\\textsf{Headache}$"); 056 final Set<String> cset = new HashSet<>(); 057 cset.add("$\\textsf{Cold}$"); 058 cset.add("$\\textsf{Flu}$"); 059 final Set<String> baseSet = new HashSet<>(); 060 baseSet.addAll(pset); 061 baseSet.addAll(cset); 062 final SetClosureOperator<String> clop = SetClosureOperator.joiningImplications(cxt, pset, cset); 063 final Set<Implication<String, String>> implications = NextClosures2 064 .compute( 065 baseSet, 066 clop, 067 cxt::colAnd, 068 __ -> false, 069 Executors.newWorkStealingPool(), 070 __ -> {}, 071 __ -> {}, 072 System.out::println, 073 __ -> {}, 074 () -> false, 075 Collections.emptySet()) 076 .second(); 077 System.out.println("implications of clop:"); 078 implications.forEach(System.out::println); 079 System.out.println(); 080 final Set<Implication<String, String>> pcimplications = 081 NextClosures2.transformToJoiningImplications(cxt, pset, cset, implications); 082 System.out.println("pc-implications of cxt:"); 083 pcimplications.forEach(System.out::println); 084 } 085 086}