Search in sources :

Example 6 with WikiParsing

use of infoeval.main.WikiData.WikiParsing in project Info-Evaluation by TechnionYP5777.

the class WikiParsingTest method test5.

@Test
public void test5() throws IOException {
    WikiParsing wp = new WikiParsing("https://en.wikipedia.org/wiki/Michelle_Williams");
    wp.Parse("refer");
    wp.CheckAmbiguities();
    assert wp.getNames().size() == 4;
    assert wp.getNames().contains("Michelle Williams (swimmer)");
    assert wp.getNames().contains("Michelle Williams (singer)");
    assert wp.getNames().contains("Michelle Williams (actress)");
    assert wp.getNames().contains("Michelle Ann Williams");
}
Also used : WikiParsing(infoeval.main.WikiData.WikiParsing) Test(org.junit.Test)

Example 7 with WikiParsing

use of infoeval.main.WikiData.WikiParsing in project Info-Evaluation by TechnionYP5777.

the class InfoevalServiceImp method checkAmbiguities.

@Override
@CrossOrigin
@RequestMapping(path = "Queries/checkAmbiguities", method = RequestMethod.GET)
public synchronized ArrayList<String> checkAmbiguities(String name) throws IOException {
    String UpdatedName = updteName(name);
    try {
        logger.log(Level.INFO, "Checking ambiguities in URL: " + "https://en.wikipedia.org/wiki/" + UpdatedName);
        WikiParsing wiki = (new WikiParsing("https://en.wikipedia.org/wiki/" + UpdatedName));
        // System.out.print("Trying to fetch from ,
        // https://en.wikipedia.org/wiki/" + UpdatedName);
        wiki.CheckAmbiguities();
        return !wiki.isConflictedName() ? null : wiki.getNames();
    } catch (Exception e) {
        logger.log(Level.WARNING, "Problem in checking ambiguities");
        throw e;
    }
}
Also used : WikiParsing(infoeval.main.WikiData.WikiParsing) IOException(java.io.IOException) CrossOrigin(org.springframework.web.bind.annotation.CrossOrigin) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with WikiParsing

use of infoeval.main.WikiData.WikiParsing in project Info-Evaluation by TechnionYP5777.

the class InfoevalServiceImp method getArrested.

@Override
@CrossOrigin
@RequestMapping(path = "Queries/Arrests", method = RequestMethod.GET)
public synchronized LinkedList<String> getArrested(String name) throws Exception {
    // Parse user's input:
    String UpdatedName = updteName(name);
    try {
        logger.log(Level.INFO, "Analyzing Arrests query from url: " + "https://en.wikipedia.org/wiki/" + UpdatedName);
        WikiParsing wiki = (new WikiParsing("https://en.wikipedia.org/wiki/" + UpdatedName));
        wiki.Parse("arrested");
        new ArrayList<>();
        analyze.setParagraphsArrests(wiki.getParagraphs());
        analyze.clearArrestsInformation();
        analyze.ArrestsQuery();
        return analyze.getArrestsInformation();
    } catch (Exception e) {
        logger.log(Level.WARNING, "Problem in arrests query");
        throw e;
    }
}
Also used : WikiParsing(infoeval.main.WikiData.WikiParsing) ArrayList(java.util.ArrayList) IOException(java.io.IOException) CrossOrigin(org.springframework.web.bind.annotation.CrossOrigin) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with WikiParsing

use of infoeval.main.WikiData.WikiParsing in project Info-Evaluation by TechnionYP5777.

the class AnalyzeParagraph method dynamicQuery.

public void dynamicQuery(String name, String query) throws Exception {
    clearDynamicInformation();
    try {
        // Prepare list of similar words to the query
        LinkedList<String> keywords = new LinkedList<String>();
        keywords.add(query);
        name = name.trim().replaceAll(" ", "_");
        WikiParsing wiki = (new WikiParsing("https://en.wikipedia.org/wiki/" + name));
        Annotation doc = new Annotation(query);
        this.pipeLine.annotate(doc);
        for (CoreMap sentence : doc.get(SentencesAnnotation.class)) for (CoreLabel token : sentence.get(TokensAnnotation.class)) keywords.add(token.get(LemmaAnnotation.class));
        // The query itself
        for (String queryWord : keywords) {
            wiki.Parse(queryWord);
            setParagraphsDynamic(wiki.getParagraphs());
            for (final Element paragraph : this.dynamicParagraphs) for (String sent : paragraph.text().split("\\.")) {
                // Split
                // to
                // sentences.
                boolean hasTerm = false;
                for (String word : sent.split("\\s+")) for (String keyword : keywords) if (word.equals(keyword)) {
                    hasTerm = true;
                    break;
                }
                if (!hasTerm)
                    continue;
                sent = sent.replaceAll("\\[\\d+\\]", "");
                this.dynamicInformation.add(sent);
            }
        }
    } catch (Exception e) {
        throw e;
    }
}
Also used : WikiParsing(infoeval.main.WikiData.WikiParsing) CoreLabel(edu.stanford.nlp.ling.CoreLabel) Element(org.jsoup.nodes.Element) CoreMap(edu.stanford.nlp.util.CoreMap) LemmaAnnotation(edu.stanford.nlp.ling.CoreAnnotations.LemmaAnnotation) LinkedList(java.util.LinkedList) SentencesAnnotation(edu.stanford.nlp.ling.CoreAnnotations.SentencesAnnotation) TokensAnnotation(edu.stanford.nlp.ling.CoreAnnotations.TokensAnnotation) Annotation(edu.stanford.nlp.pipeline.Annotation) CollapsedDependenciesAnnotation(edu.stanford.nlp.semgraph.SemanticGraphCoreAnnotations.CollapsedDependenciesAnnotation) LemmaAnnotation(edu.stanford.nlp.ling.CoreAnnotations.LemmaAnnotation) TokensAnnotation(edu.stanford.nlp.ling.CoreAnnotations.TokensAnnotation) IOException(java.io.IOException)

Example 10 with WikiParsing

use of infoeval.main.WikiData.WikiParsing in project Info-Evaluation by TechnionYP5777.

the class AnalyzeParagraph method LoadNLPClassifiers.

public void LoadNLPClassifiers() throws IOException {
    // Load coreNLP classifiers
    WikiParsing wiki = (new WikiParsing("https://en.wikipedia.org/wiki/The_Weeknd"));
    wiki.Parse("arrested");
    setParagraphsArrests(wiki.getParagraphs());
    clearArrestsInformation();
    AnalyzeArrestsQuery();
    clearArrestsInformation();
}
Also used : WikiParsing(infoeval.main.WikiData.WikiParsing)

Aggregations

WikiParsing (infoeval.main.WikiData.WikiParsing)18 Test (org.junit.Test)12 IOException (java.io.IOException)4 AnalyzeParagraph (infoeval.main.Analysis.AnalyzeParagraph)3 CrossOrigin (org.springframework.web.bind.annotation.CrossOrigin)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ArrayList (java.util.ArrayList)2 LemmaAnnotation (edu.stanford.nlp.ling.CoreAnnotations.LemmaAnnotation)1 SentencesAnnotation (edu.stanford.nlp.ling.CoreAnnotations.SentencesAnnotation)1 TokensAnnotation (edu.stanford.nlp.ling.CoreAnnotations.TokensAnnotation)1 CoreLabel (edu.stanford.nlp.ling.CoreLabel)1 Annotation (edu.stanford.nlp.pipeline.Annotation)1 CollapsedDependenciesAnnotation (edu.stanford.nlp.semgraph.SemanticGraphCoreAnnotations.CollapsedDependenciesAnnotation)1 CoreMap (edu.stanford.nlp.util.CoreMap)1 AwardsQuery (infoeval.main.Analysis.AwardsQuery)1 LinkedList (java.util.LinkedList)1 Element (org.jsoup.nodes.Element)1