当前位置: 首页>>代码示例>>Java>>正文


Java GateRuntimeException类代码示例

本文整理汇总了Java中gate.util.GateRuntimeException的典型用法代码示例。如果您正苦于以下问题:Java GateRuntimeException类的具体用法?Java GateRuntimeException怎么用?Java GateRuntimeException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GateRuntimeException类属于gate.util包,在下文中一共展示了GateRuntimeException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: actionPerformed

import gate.util.GateRuntimeException; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent evt) {
  int increment = 1;
  if((evt.getModifiers() & ActionEvent.SHIFT_MASK) > 0) {
    // CTRL pressed -> use tokens for advancing
    increment = SHIFT_INCREMENT;
    if((evt.getModifiers() & ActionEvent.CTRL_MASK) > 0) {
      increment = CTRL_SHIFT_INCREMENT;
    }
  }
  long newValue = ann.getStartNode().getOffset().longValue() - increment;
  if(newValue < 0) newValue = 0;
  try {
    moveAnnotation(set, ann, new Long(newValue), ann.getEndNode()
        .getOffset());
  } catch(InvalidOffsetException ioe) {
    throw new GateRuntimeException(ioe);
  }
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:20,代码来源:AnnotationEditor.java

示例2: documentRemoved

import gate.util.GateRuntimeException; //导入依赖的package包/类
/**
 * This method is invoked whenever a document is removed from a corpus
 */
@Override
public void documentRemoved(CorpusEvent ce) {
  Object docLRID = ce.getDocumentLRID();

  /*
   * we need to remove this document from the index
   */
  if(docLRID != null) {
    ArrayList<Object> removed = new ArrayList<Object>();
    removed.add(docLRID);
    try {
      synchronized(indexer) {
        indexer.remove(removed);
      }
    } catch(IndexException ie) {
      throw new GateRuntimeException(ie);
    }
    // queueForIndexing(docLRID);
  }
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:24,代码来源:LuceneDataStoreImpl.java

示例3: setExecutable

import gate.util.GateRuntimeException; //导入依赖的package包/类
/**
 * Sets the {@link Executable} currently under execution. At a given time
 * there can be only one executable set. After the executable has finished its
 * execution this value should be set back to null. An attempt to set the
 * executable while this value is not null will result in the method call
 * waiting until the old executable is set to null.
 */
public synchronized static void setExecutable(gate.Executable executable) {
  if(executable == null)
    currentExecutable = executable;
  else {
    while(getExecutable() != null) {
      try {
        Thread.sleep(200);
      }
      catch(InterruptedException ie) {
        throw new GateRuntimeException(ie.toString());
      }
    }
    currentExecutable = executable;
  }
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:23,代码来源:Gate.java

示例4: normaliseCreoleUrl

import gate.util.GateRuntimeException; //导入依赖的package包/类
/**
 * Makes sure the provided URL ends with "/" (CREOLE URLs always point to
 * directories so thry should always end with a slash.
 *
 * @param url
 *          the URL to be normalised
 * @return the (maybe) corrected URL.
 */
public static URL normaliseCreoleUrl(URL url) {
  // CREOLE URLs are directory URLs so they should end with "/"
  String urlName = url.toExternalForm();
  String separator = "/";
  if(urlName.endsWith(separator)) {
    return url;
  }
  else {
    urlName += separator;
    try {
      return new URL(urlName);
    }
    catch(MalformedURLException mue) {
      throw new GateRuntimeException(mue);
    }
  }
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:26,代码来源:Gate.java

示例5: getVREnabledAnnotationTypes

import gate.util.GateRuntimeException; //导入依赖的package包/类
/**
 * Returns a list of strings representing annotations types for which there
 * are custom viewers/editor registered.
 */
@Override
public List<String> getVREnabledAnnotationTypes() {
  LinkedList<String> responseList = new LinkedList<String>();
  Iterator<String> vrIterator = vrTypes.iterator();
  while(vrIterator.hasNext()) {
    String vrClassName = vrIterator.next();
    ResourceData vrResourceData = this.get(vrClassName);
    if(vrResourceData == null)
      throw new GateRuntimeException(
          "Couldn't get resource data for VR called " + vrClassName);
    // Test if VR can display all types of annotations
    if(vrResourceData.getGuiType() == ResourceData.NULL_GUI
        && vrResourceData.getAnnotationTypeDisplayed() != null) {

      String annotationTypeDisplayed =
          vrResourceData.getAnnotationTypeDisplayed();
      responseList.add(annotationTypeDisplayed);
    } // End if
  } // End while
  return Collections.unmodifiableList(responseList);
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:26,代码来源:CreoleRegisterImpl.java

示例6: toString

import gate.util.GateRuntimeException; //导入依赖的package包/类
/** String representation */
@Override
public String toString() {
  try{
    return "Parameter: name="+ name+ "; valueString=" + typeName +
           "; optional=" + optional +
           "; defaultValueString=" + defaultValueString +
           "; defaultValue=" + getDefaultValue() + "; comment=" +
           comment + "; helpURL=" +
           helpURL + "; runtime=" + runtime +
           "; itemClassName=" + itemClassName +
           "; suffixes=" + suffixes;
  }catch(ParameterException pe){
    throw new GateRuntimeException(pe.toString());
  }
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:17,代码来源:Parameter.java

示例7: updateSetsTypesAndFeatures

import gate.util.GateRuntimeException; //导入依赖的package包/类
protected void updateSetsTypesAndFeatures() {

    try {
      annotationSetIDsFromDataStore = searcher.getIndexedAnnotationSetNames();
      allAnnotTypesAndFeaturesFromDatastore = searcher.getAnnotationTypesMap();
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          updateAnnotationSetsList();
        }
      });

    } catch(SearchException se) {
      throw new GateRuntimeException(se);
    }
  }
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:17,代码来源:LuceneDataStoreSearchGUI.java

示例8: setTarget

import gate.util.GateRuntimeException; //导入依赖的package包/类
@Override
public void setTarget(Object target){
  if(target == null) return;
  if(!(target instanceof Resource)){
    throw new GateRuntimeException(this.getClass().getName() +
                                   " can only be used to display " +
                                   Resource.class.getName() +
                                   "\n" + target.getClass().getName() +
                                   " is not a " +
                                   Resource.class.getName() + "!");
  }

  Resource pr = (Resource)target;
  ResourceData rData =
      Gate.getCreoleRegister().get(pr.getClass().getName());
  if(rData != null) {
    editor.init(pr, rData.getParameterList().getInitimeParameters());
  } else {
    editor.init(pr, null);
  }

  editor.removeCreoleListenerLink();
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:24,代码来源:PRViewer.java

示例9: scrollAnnotationToVisible

import gate.util.GateRuntimeException; //导入依赖的package包/类
public void scrollAnnotationToVisible(Annotation ann) {
  // if at least part of the blinking section is visible then we
  // need to do no scrolling
  // this is required for long annotations that span more than a
  // screen
  Rectangle visibleView = scroller.getViewport().getViewRect();
  int viewStart = textView.viewToModel(visibleView.getLocation());
  Point endPoint = new Point(visibleView.getLocation());
  endPoint.translate(visibleView.width, visibleView.height);
  int viewEnd = textView.viewToModel(endPoint);
  int annStart = ann.getStartNode().getOffset().intValue();
  int annEnd = ann.getEndNode().getOffset().intValue();
  if(annEnd < viewStart || viewEnd < annStart) {
    try {
      textView.scrollRectToVisible(textView.modelToView(annStart));
    } catch(BadLocationException ble) {
      // this should never happen
      throw new GateRuntimeException(ble);
    }
  }
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:22,代码来源:TextualDocumentView.java

示例10: updateValues

import gate.util.GateRuntimeException; //导入依赖的package包/类
/**
 * Called when a resource has been unloaded from the system;
 * If any of the parameters has this resource as value then the value will be
 * deleted.
 * If the resource is null then an attempt will be made to reinitialise the
 * null values.
 */
protected void updateValues(Resource res){
  for(int i =0 ; i < values.length; i++){
    if(values[i] == res){
      values[i] = null;
      try{
        values[i] = (resource == null) ?
                    null : resource.getParameterValue(params[i].getName());
        if(values[i] == null) values[i] = params[i].getDefaultValue();
      }catch(ResourceInstantiationException rie){
        throw new GateRuntimeException(
          "Could not get read accessor method for \"" + names[i] +
          "\"property of " + resource.getClass().getName());
      }catch(ParameterException pe){
        throw new GateRuntimeException(
          "Could not get default value for \"" + names[i] +
          "\"property of " + resource.getClass().getName());
      }
    }
  }
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:28,代码来源:ParameterDisjunction.java

示例11: shortenUriString

import gate.util.GateRuntimeException; //导入依赖的package包/类
/**
 * Compact an URI String using base URI and namespace prefixes.
 * The prefixes map, which maps name prefixes of the form "ns:" or the empty
 * string to URI prefixes is searched for the first URI prefix in the value
 * set that matches the beginning of the uriString. The corresponding name prefix
 * is then used to replace that URI prefix.
 * In order to control which URI prefix is matched first if the map contains
 * several prefixes which can all match some URIs, a LinkedHashMap can be 
 * used so that the first matching URI prefix will be deterministic.
 *  
 * @param uriString a full URI String that should get shortened using prefix names or a base URI
 * @param prefixes a map containing name prefixes mapped to URI prefixes (same as for expandUriString)
 * @return a shortened URI where the URI prefix is replaced with a prefix name or the empty string
 */
public static String shortenUriString(String uriString, Map<String, String> prefixes) {
  // get the URI prefixes 
  String uriPrefix = "";
  String namePrefix = "";
  for(Map.Entry<String,String> entry : prefixes.entrySet()) {
    String np = entry.getKey();
    String uri = entry.getValue();
    if(uriString.startsWith(uri)) {
      uriPrefix = uri;
      namePrefix = np;
      break;
    }
  }
  if(uriPrefix.equals("")) {
    throw new GateRuntimeException("No prefix found in prefixes map for "+uriString);
  }
  return namePrefix + uriString.substring(uriPrefix.length());
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:33,代码来源:Utils.java

示例12: split

import gate.util.GateRuntimeException; //导入依赖的package包/类
public void split(svm_problem all, svm_problem train, svm_problem test, int idx[]) {
  // this assumes that train and test already have the correct sizes and that
  // the size of idx is the sum of these sizes
  // IMPORTANT: the train and test sets hold references to the indep rows in all, 
  // these should not get modified! However the ys are always new arrays!
  if(idx.length != all.l || idx.length != (train.l+test.l)) {
    throw new GateRuntimeException("Cannot split, odd sizes all="+all.l+",idx="+idx.length+",train="+train.l+",test="+test.l);
  }
  train.x = new svm_node[train.l][];
  train.y = new double[train.l];
  for(int i=0; i<train.l; i++) {
    train.x[i] = all.x[idx[i]];
    train.y[i] = all.y[idx[i]];
  }
  test.x = new svm_node[test.l][];
  test.y = new double[test.l];
  for(int i=0; i<test.l; i++) {
    test.x[i] = all.x[idx[i+train.l]];
    test.y[i] = all.y[idx[i+train.l]];
  }
}
 
开发者ID:GateNLP,项目名称:gateplugin-LearningFramework,代码行数:22,代码来源:EngineLibSVM.java

示例13: saveModel

import gate.util.GateRuntimeException; //导入依赖的package包/类
@Override
protected void saveModel(File directory) {
  if(model==null) {
    // TODO: this should eventually throw an exception, we leave it for testing now.
    System.err.println("WARNING: saving a null model!!!");
  }
  ObjectOutputStream oos = null;
  try {
    oos = new ObjectOutputStream(new FileOutputStream(new File(directory, FILENAME_MODEL)));
    oos.writeObject(model);
  } catch (Exception e) {
    throw new GateRuntimeException("Could not store Mallet model", e);
  } finally {
    if (oos != null) {
      try {
        oos.close();
      } catch (IOException ex) {
        logger.error("Could not close object output stream", ex);
      }
    }
  }
}
 
开发者ID:GateNLP,项目名称:gateplugin-LearningFramework,代码行数:23,代码来源:EngineMBMallet.java

示例14: createEngine

import gate.util.GateRuntimeException; //导入依赖的package包/类
/** 
 * A factory method to create a new instance of an engine with the given backend algorithm.
 * This works in two steps: first the instance of the engine is created, then that instance's
 * method for initializing the algorithm is called (initializeAlgorithm) with the given parameters.
 * However, some training algorithms cannot be instantiated until all the training data is
 * there (e.g. Mallet CRF) - for these, the initializeAlgorithm method does nothing and the
 * actual algorithm initialization happens when the train method is called. 
 * The engine also stores a reference to the Mallet corpus representation (and thus, the Pipe),
 * which enables the Engine to know about the fields and other meta-information.
 * <p>
 * The creation of a specific Engine subclass is influenced by its implementation of the following
 * methods:
 * <ul>
 * <li>
 * </ul>
 * @param algorithm
 * @param parms
 * @param featureInfo
 * @param directory
 * @return 
 */
public static Engine createEngine(Algorithm algorithm, String parms, FeatureInfo featureInfo, TargetType targetType, URL directory) {
  Engine eng;
  try {
    System.err.println("CREATE ENGINE: trying to create for class "+algorithm.getEngineClass());
    eng = (Engine)algorithm.getEngineClass().newInstance();
  } catch (Exception ex) {
    throw new GateRuntimeException("Could not create the Engine "+algorithm.getEngineClass(),ex);
  }
  eng.algorithm = algorithm;
  eng.initializeAlgorithm(algorithm,parms);
  eng.initWhenCreating(directory, algorithm, parms, featureInfo, targetType);
  eng.info = new Info();
  // we have to prevent a NPE for those algorithms where the trainer class is not stored
  // in the Algorithm instance
  if(algorithm.getTrainerClass()!=null) {
    eng.info.trainerClass = algorithm.getTrainerClass().getName();
  }
  eng.info.engineClass = algorithm.getEngineClass().getName();
  eng.info.task = eng.getAlgorithm().getAlgorithmKind().toString();
  eng.info.algorithmClass = algorithm.getClass().getName();
  eng.info.algorithmName = algorithm.toString();
  eng.algorithm = algorithm;
  return eng;
}
 
开发者ID:GateNLP,项目名称:gateplugin-LearningFramework,代码行数:46,代码来源:Engine.java

示例15: pipe

import gate.util.GateRuntimeException; //导入依赖的package包/类
public Instance pipe(Instance carrier) {
  if (!(carrier.getData() instanceof FeatureVector)) {
    System.out.println(carrier.getData().getClass());
    throw new IllegalArgumentException("Data must be of type FeatureVector not " + carrier.getData().getClass() + " we got " + carrier.getData());
  }

  if (this.means.length != this.getDataAlphabet().size()
          || this.variances.length != this.getDataAlphabet().size()) {
    throw new GateRuntimeException("Size mismatch, alphabet="+getDataAlphabet().size()+", stats="+means.length);    }

  FeatureVector fv = (FeatureVector) carrier.getData();
  int[] indices = fv.getIndices();
  double[] values = fv.getValues();
  for (int i = 0; i < indices.length; i++) {
    int index = indices[i];
    if(normalize[index]) {
      double value = values[i];
      double mean = means[index];
      double variance = variances[index];
      double newvalue = (value - mean) / Math.sqrt(variance);
      fv.setValue(index, newvalue);
    }
  }
  return carrier;
}
 
开发者ID:GateNLP,项目名称:gateplugin-LearningFramework,代码行数:26,代码来源:PipeScaleMeanVarAll.java


注:本文中的gate.util.GateRuntimeException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。