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");
}
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;
}
}
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;
}
}
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;
}
}
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();
}
Aggregations