use of main.database.ReasonPair in project Info-Evaluation by TechnionYP5777.
the class AnalyzeParagragh method InteractiveReasonFinding.
// This function makes the analyze process interactive with the user - he gets reasons to choose from and chooses the most fitiing one.
public LinkedList<ReasonPair> InteractiveReasonFinding() {
LinkedList<ReasonPair> $ = new LinkedList<ReasonPair>();
final Properties props = new Properties();
props.put("annotators", "tokenize,ssplit, pos, regexner, parse,lemma,natlog,openie");
final StanfordCoreNLP pipeLine = new StanfordCoreNLP(props);
// inputText will be the text to evaluate in this example
final String inputText = input + "";
final Annotation document = new Annotation(inputText);
// Finally we use the pipeline to annotate the document we created
pipeLine.annotate(document);
for (final CoreMap sentence : document.get(SentencesAnnotation.class)) for (RelationTriple ¢ : sentence.get(NaturalLogicAnnotations.RelationTriplesAnnotation.class)) $.add(new ReasonPair(¢.confidence, ¢.relationGloss() + " " + ¢.objectGloss()));
return $;
}
use of main.database.ReasonPair in project Info-Evaluation by TechnionYP5777.
the class ReasonPairTest method test1.
@Test
public void test1() {
ReasonPair rp = new ReasonPair();
assertEquals(rp.getReason(), null);
assertEquals(rp.getProbability(), 0, 0);
}
use of main.database.ReasonPair in project Info-Evaluation by TechnionYP5777.
the class ReasonPairTest method test2.
@Test
public void test2() {
double p = 0.5;
ReasonPair rp = new ReasonPair(p, "drunk driving");
assertEquals(rp.getReason(), "drunk driving");
assertEquals(rp.getProbability(), p, 0);
}
use of main.database.ReasonPair in project Info-Evaluation by TechnionYP5777.
the class InteractiveReasonFindingTest method test1.
@Test
public void test1() {
for (ReasonPair ¢ : new AnalyzeParagragh(new Sentence("Axl Rose was arrested for consuming drugs on October 5th 2012 in NY during rock concert ."), "2015").InteractiveReasonFinding()) {
System.out.print(¢.getProbability() + " ");
System.out.println(¢.getReason());
}
}
use of main.database.ReasonPair in project Info-Evaluation by TechnionYP5777.
the class InteractiveTableTupleTest method test3.
@Test
public void test3() {
ReasonPair rp = new ReasonPair();
rp.setProbability(0.4);
rp.setReason("stubbing");
LinkedList<ReasonPair> lst = new LinkedList<>();
lst.add(rp);
InteractiveTableTuple t = new InteractiveTableTuple("Justin Bieber", "12/02/2016", lst);
assertEquals(t.getDate(), "12/02/2016");
assertEquals(t.getName(), "Justin Bieber");
assertEquals((t.getRegularDate() + ""), "Fri Dec 02 00:00:00 IST 2016");
assert t.getKeyWords().isEmpty();
assertEquals(t.getReasons().get(0).getProbability(), 0.4, 0);
assertEquals(t.getReasons().get(0).getReason(), "stubbing");
t.addKeyWord("stubbing");
assertEquals(t.getKeyWords().get(0), "stubbing");
t.addKeyWord("arrested");
assertEquals(t.getKeyWords().get(1), "arrested");
}
Aggregations