Skip to content

Commit

Permalink
sparsegraph makefile bug
Browse files Browse the repository at this point in the history
  • Loading branch information
krivard committed Dec 19, 2014
1 parent fd55f0d commit 079378e
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/20newsgroups/20news.sparse/Makefile
Expand Up @@ -32,7 +32,7 @@ inverse: $(addsuffix .index,$(basename $(INVERSE)))
for f in $(INVERSE); do \
FWD=$${f%.*}; \
REV=$${f##*.}; \
awk 'BEGIN{FS=OFS="\t"}{print $$2,$$1,$$3}' $${FWD}.index > $${REV}.index; \
awk 'BEGIN{FS=OFS="\t"}{print $$2,$$1,$$3}' $${FWD}.index | sort -n > $${REV}.index; \
done

$(NAME): all
Expand Down
2 changes: 1 addition & 1 deletion examples/configure.sh
Expand Up @@ -78,7 +78,7 @@ endif
ifeq (\$(suffix \$(PROPPR)),'jar')
CP:=.:\${PROPPR}
else
CP:=.:\${PROPPR}/bin:\${PROPPR}/conf/:\${PROPPR}/lib/*
CP:=.:\${PROPPR}/conf/:\${PROPPR}/bin:\${PROPPR}/lib/*
endif
#### Hyperparameters
ifeq (\$(strip \$(EPSILON)),)
Expand Down
2 changes: 1 addition & 1 deletion sparseGraphTools/Makefile
Expand Up @@ -33,7 +33,7 @@ inverse: $(addsuffix .index,$(basename $(INVERSE)))
for f in $(INVERSE); do \
FWD=$${f%.*}; \
REV=$${f##*.}; \
awk 'BEGIN{FS=OFS="\t"}{print $$2,$$1,$$3}' $${FWD}.index > $${REV}.index; \
awk 'BEGIN{FS=OFS="\t"}{print $$2,$$1,$$3}' $${FWD}.index | sort -n > $${REV}.index; \
done

$(NAME): all
Expand Down
2 changes: 1 addition & 1 deletion src/java/main/edu/cmu/ml/proppr/prove/DprProver.java
Expand Up @@ -139,7 +139,7 @@ protected int dfsPushes(ProofGraph pg, Map<State,Double> p, Map<State, Double> r
// long now = System.currentTimeMillis();
// log.info("push "+pushCounter+"->"+(pushCounter+1)+" ru "+ru+" "+r.size()+" r-states u "+u);
// last = now;
// if (log.isDebugEnabled()) log.debug("PUSHPATH include "+(pushCounter+1)+" "+u);
if (log.isDebugEnabled()) log.debug("PUSHPATH include "+(pushCounter+1)+" "+u);
// }
pushCounter += 1;
Outlink restart=null;
Expand Down
8 changes: 8 additions & 0 deletions src/java/main/edu/cmu/ml/proppr/prove/wam/Outlink.java
Expand Up @@ -2,6 +2,8 @@

import java.util.Map;

import edu.cmu.ml.proppr.util.Dictionary;

public class Outlink {
public State child;
public Map<Goal,Double> fd;
Expand All @@ -10,4 +12,10 @@ public Outlink(Map<Goal,Double> features, State state) {
child = state;
fd = features;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder(child.toString());
Dictionary.buildString(fd, sb, "\n ");
return sb.toString();
}
}
79 changes: 79 additions & 0 deletions src/java/test/edu/cmu/ml/proppr/MiscDatasetTest.java
@@ -0,0 +1,79 @@
package edu.cmu.ml.proppr;

import static org.junit.Assert.*;

import java.io.File;
import java.io.IOException;
import java.util.Map;

import org.junit.Test;

import edu.cmu.ml.proppr.prove.PathDprProver;
import edu.cmu.ml.proppr.prove.wam.Goal;
import edu.cmu.ml.proppr.prove.wam.LogicProgramException;
import edu.cmu.ml.proppr.prove.wam.Outlink;
import edu.cmu.ml.proppr.prove.wam.ProofGraph;
import edu.cmu.ml.proppr.prove.wam.Query;
import edu.cmu.ml.proppr.prove.wam.State;
import edu.cmu.ml.proppr.prove.wam.WamBaseProgram;
import edu.cmu.ml.proppr.prove.wam.WamProgram;
import edu.cmu.ml.proppr.prove.wam.plugins.FactsPlugin;
import edu.cmu.ml.proppr.prove.wam.plugins.SparseGraphPlugin;
import edu.cmu.ml.proppr.prove.wam.plugins.SparseGraphPluginTest;
import edu.cmu.ml.proppr.prove.wam.plugins.WamPlugin;
import edu.cmu.ml.proppr.util.APROptions;

public class MiscDatasetTest {
static final File DIR = new File("examples/20newsgroups");
static final File RULES = new File(DIR,"20news.wam");
static final File SPARSE = new File(DIR,"20news.sparse");
static final File LABELS = new File(DIR,"labels.cfacts");
static final File SEEDS = new File(DIR,"seed_doc_label.10per.cfacts");

@Test
public void test20Newsgroups() throws IOException, LogicProgramException {
APROptions apr = new APROptions();
WamProgram program = WamBaseProgram.load(RULES);
WamPlugin plugins[] = new WamPlugin[] {
SparseGraphPlugin.load(apr, SPARSE),
FactsPlugin.load(apr,LABELS,false),
FactsPlugin.load(apr,SEEDS,false)
};
PathDprProver p = new PathDprProver(apr);

Query query = Query.parse("predict(comp.sys.mac.hardware:51779.txt,Y)");
ProofGraph pg = new ProofGraph(query,apr,program,plugins);


for (Outlink o : pg.pgOutlinks(pg.getStartState(), false, false)) {
System.out.println(o.toString()); // seed; nonseed
if (o.child.getJumpTo().equals("hasWord/2")) {
for (Outlink oo : pg.pgOutlinks(o.child, false, false)) {
// hasWord
for (Outlink ooo : pg.pgOutlinks(oo.child, false, false)) {
//wordIn
for (Outlink m : pg.pgOutlinks(ooo.child, false, false)) {
// predict again: seed; nonseed
if (m.child.getJumpTo().equals("seed/2")) {
for (Outlink mm : pg.pgOutlinks(m.child, false, false)) {
System.out.println(" "+oo.toString().replaceAll("\n","\n "));
System.out.println(" "+ooo.toString().replaceAll("\n","\n "));
System.out.println(" "+m.toString().replaceAll("\n","\n "));
System.out.println(" "+mm.toString().replaceAll("\n","\n "));
}
}
}
}
}
}
}


// Map<State,Double> ans = p.prove(pg);
// assertTrue(ans.size()>0);
// for(Map.Entry<State,Double> e : ans.entrySet()) {
// System.out.println(e.getKey());
// }
}

}

0 comments on commit 079378e

Please sign in to comment.