{
//Retrieve all the <a> for extracting the inGloss relation
if(ge.getName().equals("a"))
{
String nurl=ge.getAttributeValue("href");
s.addRelation("inGloss", new Relation("inGloss", nurl.replace("/wiki/", ""), ""));
}
}
}
else
{
if(start)
break;
}
}
}
else//Look for the start of the section
{
String all=xml.getRootElement().getValue();
String section=all.substring(all.indexOf(this.redirect)+this.redirect.length());
section=section.substring(0,section.indexOf("\")"));
boolean start=false;
for(Element e:body.getChildren())
{
if(start)
{
if(e.getName().equals("p"))
{
s.addBagOfWords(e.getValue(),e.getValue().split(" "),this.name);
for(Element ge:e.getChildren())
{
//Retrieve all the <a> for extracting the inGloss relation
if(ge.getName().equals("a"))
{
String nurl=ge.getAttributeValue("href");
s.addRelation("inGloss", new Relation("inGloss", nurl.replace("/wiki/", ""), ""));
}
}
}
else
{
break;
}
}
else
{
if(e.getName().startsWith("h"))
{
for(Element es:e.getChildren())
{
if(es.getName().equals("span")&§ion.equals(es.getAttributeValue("id")))
{
start=true;
}
}
}
}
}
}
Element navbox=null;
for(Element e:xml.getRootElement().getDescendants(new ElementFilter("table")))
{
if(e.getAttributeValue("class")!=null&&e.getAttributeValue("class").equals("navbox"))
{
navbox=e;
break;
}
}
//Add inNavBox relations
if(navbox!=null)
{
for(Element e:navbox.getDescendants(new ElementFilter("a")))
{
String nurl=e.getAttributeValue("href");
if(nurl!=null&&!this.isNotAnArticle(nurl))
{
s.addRelation("inNavBox", new Relation("inNavBox", nurl.replace("/wiki/", ""), ""));
}
}
}
//Add in CatLinks relations
Element catlinks=null;
String aux="catlinks";
for(Element e:body.getParent().getDescendants(new ElementFilter("div")))
{
if(aux.equals(e.getAttributeValue("id")))
{
catlinks=e;
break;
}
}
if(catlinks!=null)
{
for(Element e:catlinks.getDescendants(new ElementFilter("a")))
{
String nurl=e.getAttributeValue("href");
if(nurl!=null&&!this.isNotAnArticle(nurl))
{
s.addRelation("inCatLinks", new Relation("inCatLinks", nurl.replace("/wiki/", ""), ""));
}
}
}
Util.writeObject(f, s);
}