/** * Loads linear definition if url is set */ public void load() throws ResourceInstantiationException { if(null == url) { throw new ResourceInstantiationException("URL not set (null)."); } BufferedReader defReader = null; try { if("file".equals(url.getProtocol())) { File definitionFile = Files.fileFromURL(url); // create an new definition file only if not existing definitionFile.createNewFile(); } defReader = new BomStrippingInputStreamReader((url).openStream(), ENCODING); String line; LinearNode node; while(null != (line = defReader.readLine())) { node = new LinearNode(line); this.add(node); } // while isModified = false; } catch(Exception x) { throw new ResourceInstantiationException(x); } finally { IOUtils.closeQuietly(defReader); } } // load();
LinearDefinition ld = gazetter.getLinearDefinition(); //add .lst record LinearNode ln = new LinearNode("glossary.lst", "minor", "major", "en", "AnnotType"); ld.add(ln); //add Lookup record Map<String, Object> features = new HashMap<>(); features.put("someFeatureName", "some value"); GazetteerNode gn = new GazetteerNode("string to be found", features); gn.setSeparator("@"); GazetteerList theList = ld.getListsByNode().get(ln); theList.add(gn); //save updated files theList.store(); ld.store(); //optionally re-init the gazetteer to make changes to work gazetter.reInit();
LinearNode linearNode = new LinearNode(listName, "", "", "", ""); linearDefinition.add(linearNode); linearDefinition.getNodesByListNames().put(listName, linearNode);