// Path: snorocket-core/src/main/java/au/csiro/snorocket/core/util/Utils.java
// public class Utils {
//     
//     public static void printTaxonomy(Node top, Node bottom, Map<String, String> idNameMap) {
//     	if(top.equals(bottom)) return;
//         System.out.println(nodeToString(top, idNameMap));
//     	for(Node child : top.getChildren()) {
//             printTaxonomyLevel(child, bottom, 1, idNameMap);
//         }
//     }
//     
//     private static void printTaxonomyLevel(Node root, 
//             Node bottom, int level, Map<String, String> idNameMap) {
//         if(root.equals(bottom)) return;
//         System.out.println(spaces(level)+nodeToString(root, idNameMap));
//         for(Node child : root.getChildren()) {
//             printTaxonomyLevel(child, bottom, level+1, idNameMap);
//         }
//     }
//     
//     private static String nodeToString(Node node, Map<String, String> idNameMap) {
//         StringBuilder sb = new StringBuilder();
//         sb.append("{");
//         for(String concept : node.getEquivalentConcepts()) {
//             sb.append(" ");
//             String desc = idNameMap.get(concept);
//             if(desc == null) desc = "NA";
//             sb.append(desc);
//         }
//         sb.append(" }");
//         return sb.toString();
//     }
//     
//     public static void printTaxonomy(Node top, Node bottom) {
//         for(Node child : top.getChildren()) {
//             printTaxonomyLevel(child, bottom, 0);
//         }
//     }
//     
//     private static void printTaxonomyLevel(Node root, Node bottom, int level) {
//         if(root.equals(bottom)) return;
//         System.out.println(spaces(level)+root.toString());
//         for(Node child : root.getChildren()) {
//             printTaxonomyLevel(child, bottom, level+1);
//         }
//     }
//     
//     private static String spaces(int num) {
//         StringBuilder sb = new StringBuilder();
//         for(int i = 0; i < num; i++) {
//             sb.append("  ");
//         }
//         return sb.toString();
//     }
// 
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import junit.framework.Assert;
import org.junit.Test;
import au.csiro.ontology.Factory;
import au.csiro.ontology.Node;
import au.csiro.ontology.Ontology;
import au.csiro.ontology.model.Axiom;
import au.csiro.ontology.model.Concept;
import au.csiro.ontology.model.ConceptInclusion;
import au.csiro.ontology.model.Conjunction;
import au.csiro.ontology.model.Existential;
import au.csiro.ontology.model.NamedConcept;
import au.csiro.ontology.model.NamedRole;
import au.csiro.ontology.model.Role;
import au.csiro.ontology.model.RoleInclusion;
import au.csiro.snorocket.core.util.Utils;

                new Existential(am, burn),
        };
        Concept[] rhs = {
                finding,
                new Existential(rg, new Conjunction(g1)),
                new Existential(rg, new Conjunction(g2)),
        };
        Concept[] rhs2 = {
                finding,
                new Existential(rg, new Existential(am, fracture)),
        };
        Axiom[] inclusions = {
                new ConceptInclusion(multi, new Conjunction(rhs)),
                new ConceptInclusion(arm, limb),
                new ConceptInclusion(fracfind, new Conjunction(rhs2)),
                new ConceptInclusion(new Conjunction(rhs2), fracfind),
        };

        Set<Axiom> axioms = new HashSet<Axiom>();
        for (Axiom a : inclusions) {
            axioms.add(a);
        }

        // Classify
        SnorocketReasoner sr = new SnorocketReasoner();
        sr.loadAxioms(axioms);
        sr.classify();

        Ontology ont = sr.getClassifiedOntology();


// Path: snorocket-core/src/main/java/au/csiro/snorocket/core/util/Utils.java
// public class Utils {
//     
//     public static void printTaxonomy(Node top, Node bottom, Map<String, String> idNameMap) {
//     	if(top.equals(bottom)) return;
//         System.out.println(nodeToString(top, idNameMap));
//     	for(Node child : top.getChildren()) {
//             printTaxonomyLevel(child, bottom, 1, idNameMap);
//         }
//     }
//     
//     private static void printTaxonomyLevel(Node root, 
//             Node bottom, int level, Map<String, String> idNameMap) {
//         if(root.equals(bottom)) return;
//         System.out.println(spaces(level)+nodeToString(root, idNameMap));
//         for(Node child : root.getChildren()) {
//             printTaxonomyLevel(child, bottom, level+1, idNameMap);
//         }
//     }
//     
//     private static String nodeToString(Node node, Map<String, String> idNameMap) {
//         StringBuilder sb = new StringBuilder();
//         sb.append("{");
//         for(String concept : node.getEquivalentConcepts()) {
//             sb.append(" ");
//             String desc = idNameMap.get(concept);
//             if(desc == null) desc = "NA";
//             sb.append(desc);
//         }
//         sb.append(" }");
//         return sb.toString();
//     }
//     
//     public static void printTaxonomy(Node top, Node bottom) {
//         for(Node child : top.getChildren()) {
//             printTaxonomyLevel(child, bottom, 0);
//         }
//     }
//     
//     private static void printTaxonomyLevel(Node root, Node bottom, int level) {
//         if(root.equals(bottom)) return;
//         System.out.println(spaces(level)+root.toString());
//         for(Node child : root.getChildren()) {
//             printTaxonomyLevel(child, bottom, level+1);
//         }
//     }
//     
//     private static String spaces(int num) {
//         StringBuilder sb = new StringBuilder();
//         for(int i = 0; i < num; i++) {
//             sb.append("  ");
//         }
//         return sb.toString();
//     }
// 
// }


// Path: snorocket-core/src/test/java/au/csiro/snorocket/core/TestSnorocketReasoner.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import junit.framework.Assert;
import org.junit.Test;
import au.csiro.ontology.Factory;
import au.csiro.ontology.Node;
import au.csiro.ontology.Ontology;
import au.csiro.ontology.model.Axiom;
import au.csiro.ontology.model.Concept;
import au.csiro.ontology.model.ConceptInclusion;
import au.csiro.ontology.model.Conjunction;
import au.csiro.ontology.model.Existential;
import au.csiro.ontology.model.NamedConcept;
import au.csiro.ontology.model.NamedRole;
import au.csiro.ontology.model.Role;
import au.csiro.ontology.model.RoleInclusion;
import au.csiro.snorocket.core.util.Utils;

                new Existential(am, burn),
        };
        Concept[] rhs = {
                finding,
                new Existential(rg, new Conjunction(g1)),
                new Existential(rg, new Conjunction(g2)),
        };
        Concept[] rhs2 = {
                finding,
                new Existential(rg, new Existential(am, fracture)),
        };
        Axiom[] inclusions = {
                new ConceptInclusion(multi, new Conjunction(rhs)),
                new ConceptInclusion(arm, limb),
                new ConceptInclusion(fracfind, new Conjunction(rhs2)),
                new ConceptInclusion(new Conjunction(rhs2), fracfind),
        };

        Set<Axiom> axioms = new HashSet<Axiom>();
        for (Axiom a : inclusions) {
            axioms.add(a);
        }

        // Classify
        SnorocketReasoner sr = new SnorocketReasoner();
        sr.loadAxioms(axioms);
        sr.classify();

        Ontology ont = sr.getClassifiedOntology();


        Utils.printTaxonomy(ont.getTopNode(), ont.getBottomNode());
