view src/de/mpiwg/anteater/species/common/CommonNameFindController.java @ 2:1c2b4f5e2c05

linnaeus for finding species
author jdamerow
date Mon, 22 Oct 2012 13:46:54 -0700
parents
children ae96e4bc7fb2
line wrap: on
line source

package de.mpiwg.anteater.species.common;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import de.mpiwg.anteater.AnteaterConfiguration;
import de.mpiwg.anteater.species.scientific.ScientificNamesExtraction;
import de.mpiwg.anteater.text.TextInformation;
import de.mpiwg.anteater.xml.impl.AnalysisXMLManager;

public class CommonNameFindController {

public final static String COMPONENT_NAME = CommonNameFindController.class.getSimpleName();
	
	private AnteaterConfiguration configuration;

	public CommonNameFindController(AnteaterConfiguration configuration) {
		this.configuration = configuration;
	}
	
	public List<ScientificNamesExtraction> findCommonNamesInXML(TextInformation info) {
		List<CommonNamesExtraction> results = new ArrayList<CommonNamesExtraction>();
		List<String> summaryAnalysisResults = new ArrayList<String>();
		List<String> supplinfAnalysisResults = new ArrayList<String>();
		
		// check if there are already stored results
		AnalysisXMLManager analysisManager = null;
		if (configuration.getAnalysisPath() != null && !configuration.getAnalysisPath().isEmpty()) {
			File file = new File(info.getFilepath());
			
			analysisManager = new AnalysisXMLManager(configuration.getAnalysisPath() + File.separator +  file.getName());
			
			configuration.getLogger().logMessageWithoutNewLine(COMPONENT_NAME, "Check analysis file for scientific names in summaries...");
			summaryAnalysisResults = analysisManager.getSummaryCommonNamesResults();
			configuration.getLogger().logMessage("found " + summaryAnalysisResults.size() + " result(s).");
		
			configuration.getLogger().logMessageWithoutNewLine(COMPONENT_NAME, "Check analysis file for scientific names in supplementary information...");
			supplinfAnalysisResults = analysisManager.getSupplementaryInfoCommonNamesResults();
			configuration.getLogger().logMessage("found " + supplinfAnalysisResults.size() + " result(s).");
		}
		
		return null;
	}
	
}