use of edu.stanford.nlp.simple.Sentence in project Info-Evaluation by TechnionYP5777.
the class AnalyzeParagraphTest method test10.
@Test
public void test10() {
final Sentence sent = new Sentence("Saul Hudson was arrested for cheating by Axl Rose on Jan 25 1992 .");
final TableTuple tt = new AnalyzeParagragh(sent, "1992").Analyze();
assertEquals("Saul Hudson", tt.getName());
assertEquals("01/25/1992", tt.getDate());
assertEquals("cheating", tt.getReason());
}
use of edu.stanford.nlp.simple.Sentence in project Info-Evaluation by TechnionYP5777.
the class AnalyzeParagraphTest method test12.
@Test
public void test12() {
final Sentence sent = new Sentence("The Weeknd was arrested for punching a dancer in a night club on April 11 2015");
final TableTuple tt = new AnalyzeParagragh(sent, "2015").Analyze();
assertEquals("The Weeknd", tt.getName());
assertEquals("04/11/2015", tt.getDate());
assertEquals("dancer punching", tt.getReason());
}
use of edu.stanford.nlp.simple.Sentence in project Info-Evaluation by TechnionYP5777.
the class AnalyzeParagraphTest method test2.
@Test
public void test2() {
final Sentence sent = new Sentence("Justin Bieber was arrested for drunk driving in Georgia on February 22, 2015 .");
final TableTuple tt = new AnalyzeParagragh(sent, "2015").Analyze();
assertEquals("Justin Bieber", tt.getName());
assertEquals("drunk driving in Georgia", tt.getReason());
assertEquals("02/22/2015", tt.getDate());
}
use of edu.stanford.nlp.simple.Sentence in project Info-Evaluation by TechnionYP5777.
the class AnalyzeParagraphTest method test14.
@Test
public void test14() {
final Sentence sent = new Sentence("Mark Salling was arrested for felony possession of child pornography on Dec 29. His representative had no comment on the matter.");
final TableTuple tt = new AnalyzeParagragh(sent, "2015").Analyze();
assertEquals("12/29/2015", tt.getDate());
System.out.println((tt.getRegularDate() + ""));
}
use of edu.stanford.nlp.simple.Sentence in project Anserini by castorini.
the class PyseriniEntryPoint method getRankedPassages.
public List<String> getRankedPassages(String query, int numHits, int k) throws Exception {
Map<String, Float> docScore = search(query, numHits);
Map<String, Float> sentencesMap = new LinkedHashMap<>();
TokenizerFactory<CoreLabel> tokenizerFactory = PTBTokenizer.factory(new CoreLabelTokenFactory(), "");
for (Map.Entry<String, Float> doc : docScore.entrySet()) {
List<Sentence> sentences = indexUtils.getSentDocument(doc.getKey());
for (Sentence thisSent : sentences) {
List<CoreLabel> tokens = tokenizerFactory.getTokenizer(new StringReader(thisSent.text())).tokenize();
String answerTokens = tokens.stream().map(CoreLabel::toString).collect(Collectors.joining(" "));
sentencesMap.put(answerTokens, doc.getValue());
}
}
passageScorer = new IdfPassageScorer(indexDir, k);
String queryTokens = tokenizerFactory.getTokenizer(new StringReader(query)).tokenize().stream().map(CoreLabel::toString).collect(Collectors.joining(" "));
passageScorer.score(query, sentencesMap);
List<String> topSentences = new ArrayList<>();
List<ScoredPassage> topPassages = passageScorer.extractTopPassages();
for (ScoredPassage s : topPassages) {
topSentences.add(s.getSentence() + "\t" + s.getScore());
}
return topSentences;
}
Aggregations