# HG changeset patch # User jdamerow # Date 1351203963 25200 # Node ID 35d8c78ccd367cb57fe7954d53c2b403c7261b00 # Parent dcc35f89dce3ea6ff372a4df69664d68322edaba include linneaus findings diff -r dcc35f89dce3 -r 35d8c78ccd36 src/de/mpiwg/anteater/xml/ICommonNameFinderParser.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/anteater/xml/ICommonNameFinderParser.java Thu Oct 25 15:26:03 2012 -0700 @@ -0,0 +1,11 @@ +package de.mpiwg.anteater.xml; + +import java.util.List; + +import de.mpiwg.anteater.species.scientific.ScientificName; + +public interface ICommonNameFinderParser { + + public abstract List parseSpeciesNames(); + +} \ No newline at end of file diff -r dcc35f89dce3 -r 35d8c78ccd36 src/de/mpiwg/anteater/xml/impl/LinnaeusParser.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/anteater/xml/impl/LinnaeusParser.java Thu Oct 25 15:26:03 2012 -0700 @@ -0,0 +1,62 @@ +package de.mpiwg.anteater.xml.impl; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import org.jdom2.Attribute; +import org.jdom2.DataConversionException; +import org.jdom2.Element; + +import de.mpiwg.anteater.species.scientific.ScientificName; +import de.mpiwg.anteater.xml.ICommonNameFinderParser; + +public class LinnaeusParser extends JDOMParser implements ICommonNameFinderParser { + + public LinnaeusParser(String content) { + super(content, false); + } + + public LinnaeusParser(InputStream stream) { + super(stream); + } + + @Override + public List parseSpeciesNames() { + List names = executeXPath("/linnaeus/species", null); + + List commonNames = new ArrayList(); + for (Element name : names) { + ScientificName commonName = new ScientificName(); + + Attribute id = name.getAttribute("id"); + commonName.setNcbiId(id.getValue()); + commonName.setIdentifiedName(id.getValue()); + + Attribute start = name.getAttribute("start"); + try { + commonName.setStart(start.getIntValue()); + } catch (DataConversionException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + Attribute end = name.getAttribute("end"); + try { + commonName.setLength(end.getIntValue() - start.getIntValue()); + } catch (DataConversionException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + Attribute text = name.getAttribute("text"); + commonName.setScientificName(text.getValue()); + commonName.setReferenceInText(text.getValue()); + + commonNames.add(commonName); + } + + return commonNames; + } + +}