Mercurial > hg > anteater
view src/de/mpiwg/anteater/AnteaterController.java @ 0:036535fcd179
anteater
author | jdamerow |
---|---|
date | Fri, 14 Sep 2012 10:30:43 +0200 |
parents | |
children | ae96e4bc7fb2 |
line wrap: on
line source
package de.mpiwg.anteater; import java.io.File; import java.io.FilenameFilter; import java.util.ArrayList; import java.util.List; import de.mpiwg.anteater.events.EventController; import de.mpiwg.anteater.persons.PersonFinderController; import de.mpiwg.anteater.persons.PersonsExtraction; import de.mpiwg.anteater.places.PlaceFinderController; import de.mpiwg.anteater.places.PlacesExtraction; import de.mpiwg.anteater.results.ResultController; import de.mpiwg.anteater.results.ResultsCarrier; import de.mpiwg.anteater.species.scientific.ScientificNameFindController; import de.mpiwg.anteater.species.scientific.ScientificNamesExtraction; import de.mpiwg.anteater.text.TextInformation; import de.mpiwg.anteater.text.TextManager; public class AnteaterController { public final static String COMPONENT_NAME = AnteaterController.class.getSimpleName(); public void runAnteater(AnteaterConfiguration configuration) { configuration.getLogger().logMessage(COMPONENT_NAME, "Retrieving files..."); File folder = new File(configuration.getPathToTexts()); File[] files = folder.listFiles(new FilenameFilter() { @Override public boolean accept(File arg0, String arg1) { File child = new File(arg0.getAbsolutePath() + File.separator + arg1); if (child.isFile() && arg1.endsWith(".xml")) return true; return false; } }); ScientificNameFindController scienceNameFindController = new ScientificNameFindController(configuration); PlaceFinderController placesController = new PlaceFinderController(configuration); PersonFinderController personsController = new PersonFinderController(configuration); List<TextInformation> textInformations = new ArrayList<TextInformation>(); TextManager textManager = new TextManager(configuration); for (File f : files) { TextInformation info = textManager.createTextInformations(f); textInformations.add(info); } for (TextInformation info : textInformations) { configuration.getLogger().logMessage(COMPONENT_NAME, "Working on file: " + info.getFilepath()); // get scientific names List<ScientificNamesExtraction> scienNameResults = scienceNameFindController.findScientificNamesInXML(info); info.setScientificNamesExtractions(scienNameResults); // get places List<PlacesExtraction> placesResults = placesController.findPlacesInXML(info); info.setPlacesExtractions(placesResults); // get persons List<PersonsExtraction> personsResults = personsController.findPersonsInXML(info); info.setPersonsExtractions(personsResults); } // retrieve and save results ResultController resultController = new ResultController(configuration); List<ResultsCarrier> resultCarriers = resultController.saveResults(textInformations); EventController eventController = new EventController(configuration); eventController.createEvents(resultCarriers); } }