Search in sources :

Example 11 with Sentence

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());
}
Also used : TableTuple(main.database.TableTuple) AnalyzeParagragh(main.Analyze.AnalyzeParagragh) Sentence(edu.stanford.nlp.simple.Sentence) Test(org.junit.Test)

Example 12 with Sentence

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());
}
Also used : TableTuple(main.database.TableTuple) AnalyzeParagragh(main.Analyze.AnalyzeParagragh) Sentence(edu.stanford.nlp.simple.Sentence) Test(org.junit.Test)

Example 13 with Sentence

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());
}
Also used : TableTuple(main.database.TableTuple) AnalyzeParagragh(main.Analyze.AnalyzeParagragh) Sentence(edu.stanford.nlp.simple.Sentence) Test(org.junit.Test)

Example 14 with Sentence

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() + ""));
}
Also used : TableTuple(main.database.TableTuple) AnalyzeParagragh(main.Analyze.AnalyzeParagragh) Sentence(edu.stanford.nlp.simple.Sentence) Test(org.junit.Test)

Example 15 with Sentence

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;
}
Also used : CoreLabelTokenFactory(edu.stanford.nlp.process.CoreLabelTokenFactory) IdfPassageScorer(io.anserini.qa.passage.IdfPassageScorer) CoreLabel(edu.stanford.nlp.ling.CoreLabel) StringReader(java.io.StringReader) ScoredPassage(io.anserini.qa.passage.ScoredPassage) Sentence(edu.stanford.nlp.simple.Sentence)

Aggregations

Sentence (edu.stanford.nlp.simple.Sentence)29 Test (org.junit.Test)18 AnalyzeParagragh (main.Analyze.AnalyzeParagragh)16 TableTuple (main.database.TableTuple)12 CoreLabel (edu.stanford.nlp.ling.CoreLabel)5 Span (edu.stanford.nlp.ie.machinereading.structure.Span)3 CoreMap (edu.stanford.nlp.util.CoreMap)3 SentenceField (edu.stanford.nlp.util.TSVSentenceIterator.SentenceField)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 CoreLabelTokenFactory (edu.stanford.nlp.process.CoreLabelTokenFactory)2 ScoredPassage (io.anserini.qa.passage.ScoredPassage)2 StringReader (java.io.StringReader)2 InteractiveTableTuple (main.database.InteractiveTableTuple)2 ReasonPair (main.database.ReasonPair)2 edu.stanford.nlp.classify (edu.stanford.nlp.classify)1 NERTag (edu.stanford.nlp.ie.KBPRelationExtractor.NERTag)1 IOUtils (edu.stanford.nlp.io.IOUtils)1 RuntimeIOException (edu.stanford.nlp.io.RuntimeIOException)1 CoreAnnotations (edu.stanford.nlp.ling.CoreAnnotations)1