- Add the Codota plugin to your IDE and get smart completions
private void myMethod () {}
for(int i = 0; i < entries.size(); i++) { GazetteerNode node = entries.get(i); entry = node.getEntry().trim(); if(entry.length() > 0) { result.append(entry); Map<String,Object> featureMap = node.getFeatureMap(); if(featureMap != null && (featureMap.size() > 0)) { result.append(node.featureMapToString(featureMap));
/** * Parses and create a gazetteer node from a string * * @param node the gazetteer node to be parsed * @param separator the separator used in the gazetteer node string to delimit * each name-value pair of features. If the separator is null, then the whole * node will be used as the gazetteer entry * @param isOrdered true if the feature maps used should be ordered */ public GazetteerNode(String node, String separator, boolean isOrdered) { this.separator = (separator != null && separator.length() == 0)? null : separator; int index_sep; if(this.separator == null || (index_sep = node.indexOf(this.separator)) == -1 ) { entry = node; // leave featureMap null } else { entry = node.substring(0, index_sep); String features = node.substring(index_sep + 1); featureMap = getFeatures(features, isOrdered); } }
@Override public int hashCode() { return toString().hashCode(); }
@Override public Object getValueAt(int row, int column) { GazetteerNode node = gazetteerListFiltered.get(row); if (column == 0) { return node.getEntry(); } else { Map<String,Object> featureMap = node.getFeatureMap(); if (featureMap == null || featureMap.size()*2 < column) { return ""; } List<String> features = new ArrayList<String>(featureMap.keySet()); int featureCount = (column + (column % 2)) / 2; if (column % 2 == 1) { return features.get(featureCount-1); } else { return featureMap.get(features.get(featureCount-1)); } } }
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();
try { while(null != (line = listReader.readLine())) { tempEntries.add(new GazetteerNode(line, separator));
public void addEmptyFeatureColumns() { // find the first row fully filled with value if (getColumnCount() == 1) { GazetteerNode node = gazetteerListFiltered.get(0); Map<String, Object> map = new HashMap<String, Object>(); // add a couple of rows map.put("", ""); node.setFeatureMap(map); } else { for (Object object : gazetteerListFiltered) { GazetteerNode node = (GazetteerNode) object; Map<String,Object> map = node.getFeatureMap(); if (map != null && (2*map.size()+1) == getColumnCount()) { map.put("", ""); break; } } } for (Object object : gazetteerList) { GazetteerNode node = (GazetteerNode) object; node.setSeparator(linearDefinition.getSeparator()); } }
if (column == 0) { gazetteerNode.setEntry((String) value); } else { newFeatureMap.put(feature, val); gazetteerNode.setFeatureMap(newFeatureMap); fireTableRowsUpdated(row, row);
/** * Gets the string representation of this node * * @return the string representation of this node */ @Override public String toString() { if(featureMap == null || separator == null) return entry; else return entry + featureMapToString(featureMap); }
@Override public int getColumnCount() { if (columnCount > -1) { return columnCount; } if (gazetteerListFiltered == null) { return 0; } columnCount = 1; // read all the features maps to find the biggest one for (Object object : gazetteerListFiltered) { GazetteerNode node = (GazetteerNode) object; Map<String,Object> map = node.getFeatureMap(); if (map != null && columnCount < 2*map.size()+1) { columnCount = 2*map.size() + 1; } } return columnCount; }
for (Object object : gazetteerList) { GazetteerNode node = (GazetteerNode) object; if (node.getEntry().equals(value)) { found = true; break;
@Override public void actionPerformed(ActionEvent e) { GazetteerNode newGazetteerNode = new GazetteerNode(listEntryTextField.getText()); newGazetteerNode.setSeparator(listTableModel.gazetteerList .getSeparator());
node = new GazetteerNode(line, separator, isOrdered); } catch(Exception ex) { throw new GateRuntimeException("Could not read gazetteer entry "
GazetteerNode node = (GazetteerNode) object; boolean match = false; Map<String,Object> map = node.getFeatureMap(); if (map != null && !onlyValueCheckBox.isSelected()) { for (String key : map.keySet()) { if (match || pattern.matcher(node.getEntry()).find()) {
theLanguage)); theList.add(new GazetteerNode(text)); gazetteer.add(theString, new Lookup(listName, annotType, "inferred", theLanguage)); theList.add(new GazetteerNode(theString));
entry = gazNode.getEntry(); Map<String,Object> features = gazNode.getFeatureMap(); if (features == null) { lookup = defaultLookup;
/** * Checks this node vs another one for equality. * * @param o another node * @return true if the string representation of the entry and weighting match. */ @Override public boolean equals(Object o) { boolean result = false; if(o instanceof GazetteerNode) { result = this.toString().equals(o.toString()); } return result; }
/** * Stores the list to the specified url * * @throws ResourceInstantiationException */ public void store() throws ResourceInstantiationException { try { if(null == url) { throw new ResourceInstantiationException("URL not specified (null)"); } File fileo = Files.fileFromURL(url); fileo.delete(); OutputStreamWriter listWriter = new OutputStreamWriter(new FileOutputStream(fileo), encoding); // BufferedWriter listWriter = new BufferedWriter(new // FileWriter(fileo)); Iterator<GazetteerNode> iter = entries.iterator(); while(iter.hasNext()) { listWriter.write(iter.next().toString()); listWriter.write(13); listWriter.write(10); } listWriter.close(); } catch(Exception x) { throw new ResourceInstantiationException(x.getClass() + ":" + x.getMessage()); } isModified = false; } // store()
String normalisedWord = null; for(; iterator.hasNext(); add(normalisedWord, lookup1)) { String word = iterator.next().toString(); int wordLength = word.length(); for(int j = 0; j < wordLength; j++) {