Skip to content

Commit

Permalink
small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Luca Liechti committed Jan 28, 2017
1 parent 1a6af23 commit d687c20
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 23 deletions.
Binary file modified bin/driver/Driver.class
Binary file not shown.
2 changes: 1 addition & 1 deletion src/driver/ContextCleanser.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,6 @@ public void removeSingletonObjects() {
i++;
}
}
System.out.println("Removed " + i + "/" + k + " objects from context.");
// System.out.println("Removed " + i + "/" + k + " objects from context.");
}
}
43 changes: 26 additions & 17 deletions src/driver/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ public static void main(String[] args){
// docs.add(repoFolder + "XML\\mondial.xml");
// docs.add(repoFolder + "XML\\SigmodRecord.xml");
// docs.add(repoFolder + "XML\\ebay.xml");
// docs.add(repoFolder + "XML\\DBLP\\1000Lattice.xml"); //
docs.add(repoFolder + "XML\\DBLP\\1000Lattice.xml"); //
// docs.add(repoFolder + "XML\\DBLP\\316NoSql.xml");
// docs.add(repoFolder + "XML\\DBLP\\1000FCA.xml"); //
// docs.add(repoFolder + "XML\\DBLP\\1000Schema.xml"); //

//add BibTex repos
// docs.add(repoFolder + "BibTex\\BordatTest.bib");
// docs.add(repoFolder + "BibTex\\Test2.bib");
docs.add(repoFolder + "BibTex\\scg.bib"); //
// docs.add(repoFolder + "BibTex\\scg.bib"); //
// docs.add(repoFolder + "BibTex\\listb.bib"); //
// docs.add(repoFolder + "BibTex\\zbMATH\\100Lattice.bib"); //
// docs.add(repoFolder + "BibTex\\zbMATH\\100Schema.bib");
Expand All @@ -54,33 +54,42 @@ private static void parseDocument(String doc, String outputFolder, String graphv

LatticeBuilder lb = new LatticeBuilder(fc);
Lattice lattice = lb.buildLattice();
lattice.exportLatticeToFile(graphvizFolder + "0a_" + parser.getTargetLatticeFilename(doc));
lattice.exportLatticeToFile(graphvizFolder + "0a_original_" + parser.getTargetLatticeFilename(doc));

System.out.println("Nr\tScore\tNodes\tWithOwn\tedges\tindex\tclean\tnull\tleg");
System.out.println("\nNr\tScore\tNodes\tWithOwn\tedges\tindex\tclean\tnull\tleg");
System.out.println("-------------------------------------------------------------------");
System.out.println("orig\t---" + "\t" + lattice.latticeStats());
ContextCleanser cc = new ContextCleanser(fc, lattice);

///SINGLETONS PT. 1///
cc.removeSingletonObjects();
// cc.removeRareAttributes(0);
lattice.clear();
lattice = lb.buildLattice();
System.out.println("noSing\t---" + "\t" + lattice.latticeStats()); //if we have deleted singleton objects
lattice.exportLatticeToFile(graphvizFolder + "0b_withoutSingletons_" + parser.getTargetLatticeFilename(doc));

///RARE ATTRIBUTES///
// cc.removeRareAttributes(0);
// lattice.clear();
// lattice = lb.buildLattice();
// System.out.println("del\t---" + "\t" + lattice.latticeStats()); //if we have deleted rare attributes
System.out.println("2+\t---" + "\t" + lattice.latticeStats()); //if we have deleted singleton objects
lattice.exportLatticeToFile(graphvizFolder + "0b_" + parser.getTargetLatticeFilename(doc));
double score = 100000d;
// lattice.exportLatticeToFile(graphvizFolder + "0c_withoutRareAttributes_" + parser.getTargetLatticeFilename(doc));

///TINKER///
double score = cc.tinker();
int i = 1;
while(score > 0d) {
// the if(score > 0d) line should logically go here, and we would print the result anyways,
//except in the first round (because that's already printed above)
//TODO: completely do this method the other way round and calculate the new score only at the end
score = cc.tinker();
while(score > 1d) {
lattice.clear();
lattice = lb.buildLattice();
if(score > 0d) System.out.println(i + "\t" + String.format("%.2f", score) + "\t" + lattice.latticeStats());
System.out.println(i + "\t" + String.format("%.2f", score) + "\t" + lattice.latticeStats());
lattice.exportLatticeToFile(graphvizFolder + (i++) + "_" + parser.getTargetLatticeFilename(doc));
score = cc.tinker();
}

///SINGLETONS PT. 2///
lattice.retrofitSingletons();
System.out.println("final\t\t" + lattice.latticeStats());
lattice.exportLatticeToFile(graphvizFolder + "final_" + parser.getTargetLatticeFilename(doc));
// System.out.println("performed " + (i-2) + " merges in total.");
System.out.println("retfit\t\t" + lattice.latticeStats());
lattice.exportLatticeToFile(graphvizFolder + i + "_retroFit_" + parser.getTargetLatticeFilename(doc));
System.out.println("-------------------------------------------------------------------\n\n");
}
}
6 changes: 1 addition & 5 deletions src/driver/LatticeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ private void add(FormalObject g) {
LatticeNode newNode = new LatticeNode(gSet, g.getIntent(), lattice.getDic());
if(!maximalConcept.getIntent().equals(newNode.getIntent())) //only add an object if it hasn't already been added as the maximal concept!
lattice.addNode(newNode);
// System.out.println("added new node with intent = " + newNode.getIntent());
// System.out.println("nodes in total = " + lattice.getNodes().size());
}
alreadyAddedObjects.add(g);
}
Expand All @@ -86,11 +84,9 @@ private boolean hFunction(FormalObject g, HashSet<FormalObject> extent) {
private void addNodeWithAllAttributes() {
BitSet allAttributes = new BitSet(lattice.getDic().getSize());
allAttributes.set(0, lattice.getDic().getSize()); //second parameter is EXCLUSIVE, so not dictionarySize-1
if(!lattice.containsNodeWithIntent(allAttributes)){ //TODO: Check if this does what we want it to.
//TODO this does not work
if(!lattice.containsNodeWithIntent(allAttributes)){
HashSet<FormalObject> extentWithAllAttributes = context.getDerivationOfAttributes(allAttributes);
LatticeNode nodeWithAllAttributes = new LatticeNode(extentWithAllAttributes, allAttributes, lattice.getDic());
// System.out.println("adding node with all attributes, namely: " + nodeWithAllAttributes.getIntent());
lattice.addNode(nodeWithAllAttributes);
}
}
Expand Down

0 comments on commit d687c20

Please sign in to comment.