/** * Adds a string item to the model and associates it with a Lookup * @param singleItem the string item to be added * @param lookup the lookup to be associated with the string item * @return true if the item has been added, otherwise - false. */ @Override public boolean add(String singleItem, Lookup lookup) { return gaz.add(singleItem,lookup); }
/** Executes this onto gazetteer over a pre-set document * @throws ExecutionException if something goes wrong with the execution */ @Override public void execute()throws ExecutionException { if (null == gaz) { throw new ExecutionException("gazetteer not initialized (null)."); } gaz.setDocument(document); gaz.setAnnotationSetName(annotationSetName); gaz.setEncoding(encoding); gaz.setCorpus(corpus); gaz.execute(); } // execute
/**Overrides {@link gate.creole.gazetteer.Gazetteer} * and retrieves the linear definition from the underlying * linear gazetteer*/ @Override public LinearDefinition getLinearDefinition() { if (null == gaz){ throw new gate.util.GateRuntimeException( "linear gazetteer should be set before \n"+ "attempting to retrieve the linear definition"); } return gaz.getLinearDefinition(); }
GazetteerList theList = null; Iterator<GazetteerList> theListsIter = gazetteer.getLinearDefinition().getListsByNode().values() .iterator(); while(theListsIter.hasNext() && listName.equals("")) { Set<Lookup> lookupResult = gazetteer.lookup(text); if(lookupResult != null && lookupResult.size() > 0) continue; gazetteer.add(text, new Lookup(listName, annotType, "inferred", theLanguage)); for(int i = 0; i < strings.size(); i++) { String theString = strings.get(i); Set<Lookup> lookupResult1 = gazetteer.lookup(theString); if(lookupResult1 != null && lookupResult1.size() > 0) continue; if(theString.length() < 3) continue; gazetteer.add(theString, new Lookup(listName, annotType, "inferred", theLanguage)); theList.add(new GazetteerNode(theString));
gazetteerInst.setDocument(tempDoc); gazetteerInst.setAnnotationSetName(wrappedOutputASName); fireStatusChanged("Executing Gazetteer..."); gazetteerInst.execute(); gazetteerInst.setDocument(null); if(tempDoc != null) {
linearDefinition = gazetteer.getLinearDefinition(); if (null == linearDefinition) { throw new GateRuntimeException( defFile = Files.fileFromURL(gazetteer.getListsURL().toURL());
@Override public Set<Lookup> lookup(String singleItem) { return gaz.lookup(singleItem); }
@Override public void setTarget(Object target) { if (null == target) { throw new GateRuntimeException("The resource set is null."); } if (! (target instanceof Gazetteer) ) { throw new GateRuntimeException( "The resource set must be of type gate.creole.gazetteer.Gazetteer\n"+ "and not " + target.getClass()); } if(((Gazetteer)target).getListsURL() == null) { // not a file based gazetteer: we cannot display it. throw new IllegalArgumentException("Not a file-based gazetteer."); } ((Gazetteer) target).addGazetteerListener(this); processGazetteerEvent(new GazetteerEvent(target, GazetteerEvent.REINIT)); }
/** * Removes a single string item from the gazetteer model * @param singleItem removes a string item from the gazetteer model * @return true if the string is removed from the model, otherwise - false */ @Override public boolean remove(String singleItem) { return gaz.remove(singleItem); }
@Override public void actionPerformed(ActionEvent e) { try { if (linearDefinition.isModified()) { linearDefinition.store(); } for (Object object : linearDefinition.getListsByNode().values()) { GazetteerList gazetteerList = (GazetteerList) object; if (gazetteerList.isModified()) { gazetteerList.store(); } } gazetteer.reInit(); MainFrame.getInstance().statusChanged("Gazetteer saved in " + linearDefinition.getURL().getPath()); definitionTable.repaint(); } catch (ResourceInstantiationException re) { MainFrame.getInstance().statusChanged( "Unable to save the Gazetteer."); Err.prln("Unable to save the Gazetteer.\n" + re.getMessage()); } } }
gazetteer.getLinearDefinition().getListsByNode(); Iterator<LinearNode> iter1 = theLists.keySet().iterator(); while(iter1.hasNext()) {