-
Notifications
You must be signed in to change notification settings - Fork 5
/
Extractor.java
31 lines (25 loc) · 976 Bytes
/
Extractor.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package org.genericsystem.reinforcer;
import java.util.ArrayList;
import java.util.List;
public class Extractor {
// Receives labels together with their class. Retrieves appropriate data.
private final List<Template3> templates = new ArrayList<>();
public void reinforce(Labels labels, String templateName) {
Template3 template = templates.stream().filter(t -> t.getName().equals(templateName)).findFirst().orElse(null);
if (template == null) {
template = new Template3(templateName);
templates.add(template);
}
template.reinforce(labels);
}
public List<DetectedContent> extractData(Labels labels, String templateName) {
Template3 template = templates.stream().filter(t -> t.getName().equals(templateName)).findFirst().orElse(null);
if (template == null)
throw new IllegalStateException("Inexistent template " + templateName);
return template.extractData(labels);
}
@Override
public String toString() {
return templates.toString();
}
}