{
ArrayList<String> syns=new ArrayList<String>(1);
syns.add(sid);
s=new Sense(sid,"",syns);
URL url=new URL(this.path+"wiki/"+sid.replace(" ", "_"));
Document xml=this.loadURL(url);
Element body=this.getContentNode(xml);
//Check if definition is a section
if(!xml.getRootElement().getValue().contains(this.redirect))
{
boolean start=false;
for(Element e:body.getChildren())
{
if(e.getName().equals("p"))
{
start=true;
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
{
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;