Skip to content
Snippets Groups Projects
Commit 606a5b7f authored by Lange, Dr. Herbert's avatar Lange, Dr. Herbert
Browse files

load annotation specification from resource

parent 9c4b7ffe
No related branches found
No related tags found
1 merge request!6add feature to load criteria file from resource and place all criteria files...
...@@ -73,14 +73,15 @@ abstract class AnnotationChecker extends Checker implements CorpusFunction { ...@@ -73,14 +73,15 @@ abstract class AnnotationChecker extends Checker implements CorpusFunction {
/** /**
* Loads the tags from an annotation specification file * Loads the tags from an annotation specification file
* see https://exmaralda.org/en/utilities/ Templates for working with the Annotation Panel * see https://exmaralda.org/en/utilities/ Templates for working with the Annotation Panel
* @param fileName the name of the annotation specification file * @param fileName the name of the annotation specification file as a resource
* @return the list of tags specified * @return the list of tags specified
*/ */
private Collection<String> loadAnnotationSpecification(String fileName) { private Collection<String> loadAnnotationSpecification(String fileName) {
SAXBuilder sb = new SAXBuilder(); SAXBuilder sb = new SAXBuilder();
List<String> tags = new ArrayList<>(); List<String> tags = new ArrayList<>();
try { try {
Document dom = sb.build(new File(fileName)); //Document dom = sb.build(new File(fileName));
Document dom = sb.build(this.getClass().getClassLoader().getResourceAsStream(fileName));
List<Attribute> names = Collections.checkedList(XPath.newInstance("//tag/@name").selectNodes(dom), List<Attribute> names = Collections.checkedList(XPath.newInstance("//tag/@name").selectNodes(dom),
Attribute.class); Attribute.class);
// Extract attribute values and add them to the tags list // Extract attribute values and add them to the tags list
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment