Mercurial > hg > anteater
comparison src/de/mpiwg/anteater/results/impl/ScientificNameResultFinder.java @ 0:036535fcd179
anteater
author | jdamerow |
---|---|
date | Fri, 14 Sep 2012 10:30:43 +0200 |
parents | |
children | dcc35f89dce3 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:036535fcd179 |
---|---|
1 package de.mpiwg.anteater.results.impl; | |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.List; | |
5 | |
6 import de.mpiwg.anteater.places.PlaceInformation; | |
7 import de.mpiwg.anteater.places.PlacesExtraction; | |
8 import de.mpiwg.anteater.results.IResultFinder; | |
9 import de.mpiwg.anteater.results.SpeciesScientificResult; | |
10 import de.mpiwg.anteater.species.scientific.ScientificName; | |
11 import de.mpiwg.anteater.species.scientific.ScientificNamesExtraction; | |
12 import de.mpiwg.anteater.text.TextInformation; | |
13 | |
14 public class ScientificNameResultFinder implements | |
15 IResultFinder<SpeciesScientificResult> { | |
16 | |
17 @Override | |
18 public List<SpeciesScientificResult> getResults(List<TextInformation> infos) { | |
19 List<SpeciesScientificResult> finalResults = new ArrayList<SpeciesScientificResult>(); | |
20 | |
21 for (TextInformation info : infos) { | |
22 | |
23 List<ScientificNamesExtraction> resultsExtractions = info.getScientificNamesExtractions(); | |
24 List<PlacesExtraction> placesExtraction = info.getPlacesExtractions(); | |
25 | |
26 | |
27 for (ScientificNamesExtraction nameExtraction : resultsExtractions) { | |
28 for (PlacesExtraction placeExtraction : placesExtraction) { | |
29 if (placeExtraction.getType() == nameExtraction.getType() && placeExtraction.getTextIdx() == nameExtraction.getTextIdx()) { | |
30 List<ScientificName> names = nameExtraction.getNames(); | |
31 List<PlaceInformation> places = placeExtraction.getPlaceInformation(); | |
32 | |
33 // put all indices where there is a place according to placemaker | |
34 // into list | |
35 List<Integer> placeIndices = new ArrayList<Integer>(); | |
36 for (PlaceInformation place : places) { | |
37 int start = place.getStart(); | |
38 int end = place.getStart() + place.getLength(); | |
39 for (int i = start; i < end; i++) { | |
40 placeIndices.add(i); | |
41 } | |
42 } | |
43 | |
44 for (ScientificName name : names) { | |
45 if (!placeIndices.contains(name.getStart())) | |
46 { | |
47 SpeciesScientificResult finalResult = new SpeciesScientificResult(); | |
48 finalResult.setFinding(name); | |
49 finalResult.setPrediction(1.0); | |
50 finalResult.setResult(nameExtraction); | |
51 finalResult.setTextInfo(info); | |
52 finalResults.add(finalResult); | |
53 } | |
54 } | |
55 } | |
56 } | |
57 } | |
58 } | |
59 return finalResults; | |
60 } | |
61 | |
62 } |