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


Java AnnotationDiffer类代码示例

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


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

示例1: isCellEditable

import gate.util.AnnotationDiffer; //导入依赖的package包/类
@Override
public boolean isCellEditable(int rowIndex, int columnIndex){
  if (pairings.size() == 0) { return false; }
  AnnotationDiffer.Pairing pairing = pairings.get(rowIndex);
  switch(columnIndex) {
    case COL_KEY_COPY:
    case COL_KEY_START:
    case COL_KEY_END:
    case COL_KEY_FEATURES: return pairing.getKey() != null;
    case COL_RES_COPY:
    case COL_RES_START:
    case COL_RES_END:
    case COL_RES_FEATURES: return pairing.getResponse() != null;
    default: return false;
  }
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:17,代码来源:AnnotationDiffGUI.java

示例2: getBackgroundAt

import gate.util.AnnotationDiffer; //导入依赖的package包/类
/**
 * Gets the background color of a cell
 * 
 * @param row
 * @param column
 * @return
 */
public Color getBackgroundAt(int row, int column) {
  AnnotationDiffer.Pairing pairing = pairings.get(row);
  switch(pairing.getType()) {
    case (AnnotationDiffer.CORRECT_TYPE):
      return BG;
    case (AnnotationDiffer.PARTIALLY_CORRECT_TYPE):
      return PARTIALLY_CORRECT_BG;
    case (AnnotationDiffer.MISMATCH_TYPE):
      if(column < COL_MATCH)
        return MISSING_BG;
      else if(column > COL_MATCH)
        return FALSE_POSITIVE_BG;
      else return BG;
    case (AnnotationDiffer.MISSING_TYPE):
      return MISSING_BG;
    case (AnnotationDiffer.SPURIOUS_TYPE):
      return FALSE_POSITIVE_BG;
    default:
      return BG;
  }
}
 
开发者ID:SemanticSoftwareLab,项目名称:TextMining-Rhetector,代码行数:29,代码来源:AnnotationDiffExporter.java

示例3: initLocalData

import gate.util.AnnotationDiffer; //导入依赖的package包/类
protected void initLocalData(){
  differ = new AnnotationDiffer();
  pairings = new ArrayList<AnnotationDiffer.Pairing>();
  keyCopyValueRows = new ArrayList<Boolean>();
  resCopyValueRows = new ArrayList<Boolean>();
  significantFeatures = new HashSet<String>();
  keyDoc = null;
  resDoc = null;
  Component root = SwingUtilities.getRoot(AnnotationDiffGUI.this);
  isStandalone = (root instanceof MainFrame);
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:12,代码来源:AnnotationDiffGUI.java

示例4: getBackgroundAt

import gate.util.AnnotationDiffer; //导入依赖的package包/类
public Color getBackgroundAt(int row, int column){
      AnnotationDiffer.Pairing pairing = pairings.get(row);
      switch(pairing.getType()){
        case(AnnotationDiffer.CORRECT_TYPE): return diffTable.getBackground();
        case(AnnotationDiffer.PARTIALLY_CORRECT_TYPE): return PARTIALLY_CORRECT_BG;
        case(AnnotationDiffer.MISMATCH_TYPE):
          if(column < COL_MATCH) return MISSING_BG;
          else if(column > COL_MATCH) return FALSE_POSITIVE_BG;
          else return diffTable.getBackground();
        case(AnnotationDiffer.MISSING_TYPE): return MISSING_BG;
        case(AnnotationDiffer.SPURIOUS_TYPE): return FALSE_POSITIVE_BG;
        default: return diffTable.getBackground();
      }
//      
//      Color colKey = pairing.getType() == 
//          AnnotationDiffer.CORRECT_TYPE ?
//          diffTable.getBackground() :
//          (pairing.getType() == AnnotationDiffer.PARTIALLY_CORRECT_TYPE ?
//           PARTIALLY_CORRECT_BG : MISSING_BG);
//      if(pairing.getKey() == null) colKey = diffTable.getBackground();
//      
//      Color colRes = pairing.getType() == AnnotationDiffer.CORRECT_TYPE ?
//                     diffTable.getBackground() :
//                       (pairing.getType() == AnnotationDiffer.PARTIALLY_CORRECT_TYPE ?
//                       PARTIALLY_CORRECT_BG :
//                         FALSE_POSITIVE_BG);
//      if(pairing.getResponse() == null) colRes = diffTable.getBackground();
//      switch(column){
//        case COL_KEY_START: return colKey;
//        case COL_KEY_END: return colKey;
//        case COL_KEY_STRING: return colKey;
//        case COL_KEY_FEATURES: return colKey;
//        case COL_MATCH: return diffTable.getBackground();
//        case COL_RES_START: return colRes;
//        case COL_RES_END: return colRes;
//        case COL_RES_STRING: return colRes;
//        case COL_RES_FEATURES: return colRes;
//        default: return diffTable.getBackground();
//      }
    }
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:41,代码来源:AnnotationDiffGUI.java

示例5: DiffTable

import gate.util.AnnotationDiffer; //导入依赖的package包/类
/**
 * Constructor
 * 
 * @param pairings results of annotation diff
 */
public DiffTable(List<AnnotationDiffer.Pairing> pairings) {
  matchLabel = new String[5];
  matchLabel[AnnotationDiffer.CORRECT_TYPE] = "=";
  matchLabel[AnnotationDiffer.PARTIALLY_CORRECT_TYPE] = "~";
  matchLabel[AnnotationDiffer.MISSING_TYPE] = "-?";
  matchLabel[AnnotationDiffer.SPURIOUS_TYPE] = "?-";
  matchLabel[AnnotationDiffer.MISMATCH_TYPE] = "<>";

  this.pairings = pairings;
}
 
开发者ID:SemanticSoftwareLab,项目名称:TextMining-Rhetector,代码行数:16,代码来源:AnnotationDiffExporter.java

示例6: getMeasureValue

import gate.util.AnnotationDiffer; //导入依赖的package包/类
/**
 * Given an instance of Differ and the measure, this method returns
 * the value for the given measure. It returns three values,
 * precision, recall and f-measure
 */
private double[] getMeasureValue(AnnotationDiffer differ, String measure) {
  double[] vals = new double[3];
  // recall
  if(measure.endsWith("strict")) {
    vals[0] = differ.getRecallStrict();
  }
  else if(measure.endsWith("lenient")) {
    vals[0] = differ.getRecallLenient();
  }
  else {
    vals[0] = differ.getRecallAverage();
  }

  // precision
  if(measure.endsWith("strict")) {
    vals[1] = differ.getPrecisionStrict();
  }
  else if(measure.endsWith("lenient")) {
    vals[1] = differ.getPrecisionLenient();
  }
  else {
    vals[1] = differ.getPrecisionAverage();
  }

  // f-measure
  double beta = Double.valueOf(measure.substring(1, measure.indexOf('-')));
  if(measure.endsWith("strict")) {
    vals[2] = differ.getFMeasureStrict(beta);
  }
  else if(measure.endsWith("lenient")) {
    vals[2] = differ.getFMeasureLenient(beta);
  }
  else {
    vals[2] = differ.getFMeasureAverage(beta);
  }
  return vals;
}
 
开发者ID:SemanticSoftwareLab,项目名称:TextMining-Rhetector,代码行数:43,代码来源:QualityAssurancePR.java

示例7: testGazetteerApplication2BE3

import gate.util.AnnotationDiffer; //导入依赖的package包/类
public void testGazetteerApplication2BE3() 
    throws ResourceInstantiationException, ExecutionException, IOException {
  System.out.println("Running gazetteer application test 2 for news1pre");
  FeatureMap parms = Factory.newFeatureMap();
  File defFile = new File(testingDir,"annie/lists.def");
  URL gazURL = defFile.toURI().toURL();
  parms.put("configFileURL", gazURL);
  ExtendedGazetteer eg = (ExtendedGazetteer)Factory.createResource(
          "com.jpetrak.gate.stringannotation.extendedgazetteer.ExtendedGazetteer", parms);
  // load the document
  eg.setOutputAnnotationSet("EXT");
  parms = Factory.newFeatureMap();
  File docFile = new File(testingDir,"news1pre.xml");
  parms.put("sourceUrl",docFile.toURI().toURL());
  Document doc = (Document) 
       Factory.createResource("gate.corpora.DocumentImpl", parms);
  AnnotationSet lookups = doc.getAnnotations("EXT").get("Lookup");
  assertEquals(0,lookups.size());
  // run the gazetteer on the document
  eg.setDocument(doc);
  eg.execute();
  AnnotationDiffer differ = new AnnotationDiffer();
  differ.setSignificantFeaturesSet(new HashSet<String>());
  AnnotationSet keys = doc.getAnnotations().get("Lookup");
  System.out.println("Lookups old: "+keys.size());
  AnnotationSet responses = doc.getAnnotations("EXT").get("Lookup");
  System.out.println("Lookups new: "+responses.size());
  differ.calculateDiff(keys, responses);
  int correct = differ.getCorrectMatches();
  int falsePositives = differ.getFalsePositivesStrict();
  int missing = differ.getMissing();
  System.out.println("Diff: correct="+correct+" false positives="+falsePositives+" missing="+missing);
  File outFile = new File(testingDir,"news1pre_procBE.xml");
  FileUtils.writeStringToFile(outFile, doc.toXml(),"UTF-8");
  assertEquals(194,correct);
  assertEquals(33,falsePositives);    
  assertEquals(2,missing);
  System.out.println("Gazetteer application test 2 finished");
}
 
开发者ID:johann-petrak,项目名称:gateplugin-StringAnnotation,代码行数:40,代码来源:Tests1.java

示例8: getMeasureValue

import gate.util.AnnotationDiffer; //导入依赖的package包/类
/**
 * Given an instance of Differ and the measure, this method returns
 * the value for the given measure. It returns three values,
 * precision, recall and f-measure
 * 
 * @param differ
 * @param measure
 * @return
 */
private double[] getMeasureValue(AnnotationDiffer differ, String measure) {
  double[] vals = new double[3];
  // recall
  if(measure.endsWith("strict")) {
    vals[0] = differ.getRecallStrict();
  }
  else if(measure.endsWith("lenient")) {
    vals[0] = differ.getRecallLenient();
  }
  else {
    vals[0] = differ.getRecallAverage();
  }

  // precision
  if(measure.endsWith("strict")) {
    vals[1] = differ.getPrecisionStrict();
  }
  else if(measure.endsWith("lenient")) {
    vals[1] = differ.getPrecisionLenient();
  }
  else {
    vals[1] = differ.getPrecisionAverage();
  }

  // f-measure
  double beta = Double.valueOf(measure.substring(1, measure.indexOf('-')));
  if(measure.endsWith("strict")) {
    vals[2] = differ.getFMeasureStrict(beta);
  }
  else if(measure.endsWith("lenient")) {
    vals[2] = differ.getFMeasureLenient(beta);
  }
  else {
    vals[2] = differ.getFMeasureAverage(beta);
  }
  return vals;
}
 
开发者ID:eduardoguzman,项目名称:sisob-data-extractor,代码行数:47,代码来源:QualityAssurancePR.java

示例9: getValueAt

import gate.util.AnnotationDiffer; //导入依赖的package包/类
/**
 * Gets a value of a particular cell
 * 
 * @param row
 * @param column
 * @return
 */
public Object getValueAt(int row, int column) {

  // result at the given row
  AnnotationDiffer.Pairing pairing = pairings.get(row);

  // key and response annotation
  Annotation key = pairing.getKey();
  Annotation res = pairing.getResponse();

  // find out the column
  switch(column) {
    case COL_KEY_START:
      return key == null ? "" : key.getStartNode().getOffset().toString();
    case COL_KEY_END:
      return key == null ? "" : key.getEndNode().getOffset().toString();
    case COL_KEY_STRING:
      String keyStr = "";
      if(key != null && document != null) {
        keyStr = Utils.stringFor(document, key);
      }
      // cut annotated text in the middle if too long
      if(keyStr.length() > maxCellLength) {
        keyStr = keyStr.substring(0, maxCellLength / 2) + "..."
                + keyStr.substring(keyStr.length() - (maxCellLength / 2));
      }
      // use special characters for newline, tab and space
      keyStr = keyStr.replaceAll("(?:\r?\n)|\r", "↓");
      keyStr = keyStr.replaceAll("\t", "→");
      keyStr = keyStr.replaceAll(" ", "·");
      return keyStr;
    case COL_KEY_FEATURES:
      return key == null ? "" : key.getFeatures().toString();
    case COL_MATCH:
      return matchLabel[pairing.getType()];
    case COL_RES_START:
      return res == null ? "" : res.getStartNode().getOffset().toString();
    case COL_RES_END:
      return res == null ? "" : res.getEndNode().getOffset().toString();
    case COL_RES_STRING:
      String resStr = "";
      if(res != null && document != null) {
        resStr = Utils.stringFor(document, res);
      }
      if(resStr.length() > maxCellLength) {
        resStr = resStr.substring(0, maxCellLength / 2) + "..."
                + resStr.substring(resStr.length() - (maxCellLength / 2));
      }
      // use special characters for newline, tab and space
      resStr = resStr.replaceAll("(?:\r?\n)|\r", "↓");
      resStr = resStr.replaceAll("\t", "→");
      resStr = resStr.replaceAll(" ", "·");
      return resStr;
    case COL_RES_FEATURES:
      return res == null ? "" : res.getFeatures().toString();
    default:
      return "?";
  }
}
 
开发者ID:SemanticSoftwareLab,项目名称:TextMining-Rhetector,代码行数:66,代码来源:AnnotationDiffExporter.java

示例10: AnnotationDiffExporter

import gate.util.AnnotationDiffer; //导入依赖的package包/类
/**
 * Constructor
 * 
 * @param differs a map containing instance of AnnotationDiffer
 *          objects (one for one annotation type) and a list of
 *          AnnotationDiffer.Pairing objects - each referring to an
 *          annotation in the document of that type
 * @param document document on which the annotation diff is performed.
 * @param keySetName name of the key annotation set
 * @param respSetName name of the response annotaiton set
 */
public AnnotationDiffExporter(
        Map<AnnotationDiffer, List<AnnotationDiffer.Pairing>> differs,
        Document document, String keySetName, String respSetName) {
  this.differs = differs;
  this.document = document;
  this.keySetName = keySetName;
  this.respSetName = respSetName;
}
 
开发者ID:SemanticSoftwareLab,项目名称:TextMining-Rhetector,代码行数:20,代码来源:AnnotationDiffExporter.java


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