The purpose of this lab session is to extract structured information from a natural language text corpus.
~senellar/inf396/text on the computers used during the labs. The format of
this file is as follows: The first line is the title of the first article, while the following lines (up
to the first blank line) form the content of this article, in plain text format. The second article
comes after the next blank line, and so on. There are 50,441 articles in total.
~senellar/inf396/full on the computers used during the labs. The format of the file is as
explained in the lecture.
We provide the following classes:
Extractor, which has a method extract(Page):Triple. Create a simple extractor, TestExtractor, which produces triples of the form <PageTitle, is, processed>. Create a class InformationExtractor, which has only one method: run. This method takes as input a corpus file, a target file and a list of extractors. It iterates over all pages in the corpus, calls all extractors and writes the triples, TAB-separated, into the target file. Test this method with the TestExtractor on the small sample corpus.
DateExtractor that uses a regular expression to find the first date mentioned in the article. Let it return a triple of the form <PageTitle, hasDate, Date>. Try the extractor with the pages of Elvis Presley and Alan Turing. If you are adventurous, try normalizing the dates you extract to the form [-]YYYY-MM-DD. Regular expressions work as follows in Java:
Pattern pattern=Pattern.compile(EXPRESSION);
Matcher matcher=pattern.matcher(STRING);
while(matcher.find()) {
// matcher.group(N) holds the N-th group of the match
// matcher.group() holds the entire match
}
TypeExtractor that extracts the type of the article entity ("Leicester is a city"). Manually exclude terms that are too abstract ("member of...", "way of..."). The results should be triples of the form <PageTitle, is_a, Type>. A triple is correct if Type is the answer to the question "What is PageTitle?" ("What is Leceister?" — "Leceister is a city!").LocationExtractor that extracts the location of a place ("Hollywood is a district in Los Angeles"). Alternatively or additionally: Write a TypeAndLocationExtractor, which first calls the TypeExtractor, checks if the article entity is a city, district, etc., and, if so, extracts the location. Measure the precision on 20 output pairs manually, hand in the results.