Mercurial > hg > anteater
diff src/de/mpiwg/anteater/species/common/CommonNameFindController.java @ 3:ae96e4bc7fb2
save found species to analysis files
author | jdamerow |
---|---|
date | Mon, 22 Oct 2012 14:21:14 -0700 |
parents | 1c2b4f5e2c05 |
children | dcc35f89dce3 |
line wrap: on
line diff
--- a/src/de/mpiwg/anteater/species/common/CommonNameFindController.java Mon Oct 22 13:46:54 2012 -0700 +++ b/src/de/mpiwg/anteater/species/common/CommonNameFindController.java Mon Oct 22 14:21:14 2012 -0700 @@ -5,8 +5,12 @@ import java.util.List; import de.mpiwg.anteater.AnteaterConfiguration; +import de.mpiwg.anteater.species.common.impl.LinnaeusNameFinder; +import de.mpiwg.anteater.species.scientific.IScientificNamesFinder; import de.mpiwg.anteater.species.scientific.ScientificNamesExtraction; +import de.mpiwg.anteater.species.scientific.impl.GNRDNameFinder; import de.mpiwg.anteater.text.TextInformation; +import de.mpiwg.anteater.text.TextPart; import de.mpiwg.anteater.xml.impl.AnalysisXMLManager; public class CommonNameFindController { @@ -19,7 +23,7 @@ this.configuration = configuration; } - public List<ScientificNamesExtraction> findCommonNamesInXML(TextInformation info) { + public List<CommonNamesExtraction> findCommonNamesInXML(TextInformation info) { List<CommonNamesExtraction> results = new ArrayList<CommonNamesExtraction>(); List<String> summaryAnalysisResults = new ArrayList<String>(); List<String> supplinfAnalysisResults = new ArrayList<String>(); @@ -40,6 +44,40 @@ configuration.getLogger().logMessage("found " + supplinfAnalysisResults.size() + " result(s)."); } + ICommonNameFinder nameFinder = new LinnaeusNameFinder(configuration.getLogger()); + + // if there are no results for summaries, ask GNRD name finding service. + if (summaryAnalysisResults.size() == 0) { + configuration.getLogger().logMessage(COMPONENT_NAME, "No results found for summaries, so will ask LinnaeusNameFinder."); + + for (TextPart sum : info.getSummaries()) { + String sumResult = nameFinder.findCommonNames(sum.getText()); + if (sumResult != null) { + summaryAnalysisResults.add(sumResult); + + // if there is an analysis folder, add result to analysis file + if (analysisManager != null) + analysisManager.addSummaryCommonNamesResult(sumResult); + } + } + } + + // if there are no results for supplementary information, ask GNRD name fining service + if (supplinfAnalysisResults.size() == 0) { + configuration.getLogger().logMessage(COMPONENT_NAME, "No results found for supplementary information, so will ask LinnaeusNameFinder."); + + for (TextPart sInf : info.getSupplInfos()) { + String supinfResult = nameFinder.findCommonNames(sInf.getText()); + if (supinfResult != null) { + supplinfAnalysisResults.add(supinfResult); + + // if there is an analysis folder, add result to analysis file + if (analysisManager != null) + analysisManager.addSupplInfCommonNamesResult(supinfResult); + } + } + } + return null; }