2013-08-22 5 views
0

Я очень комфортно с UIMA, но моя новая работа требует, чтобы я использовать GATEКак хранить и сравнивать аннотацию (с золотой стандарт) в GATE

Итак, я начал изучать GATE. Мой вопрос заключается в том, как рассчитать производительность моих механизмов тегов (java based).

С помощью UIMA я вообще дамлю всю аннотацию системы в файл xmi, а затем используя код Java, сравните это с аннотированными аннотациями (золотым стандартом) человека, чтобы вычислить Precision/Recall и F-score.

Но я все еще пытаюсь найти что-то подобное с GATE. Пройдя через Gate Annotation-Diff и прочую информацию на этой странице, я чувствую, что в JAVA должен быть простой способ сделать это. Но я не могу понять, как это сделать, используя JAVA. Подумав, чтобы задать этот вопрос, кто-то, возможно, уже понял это.

  1. Как сохранить системную аннотацию в файл xmi или любой формат программно.
  2. Как создать одноразовые данные золотого стандарта (т. Е. Аннотированные данные человека) для расчета производительности.

Сообщите мне, если вам нужно больше деталей или деталей.

ответ

0

Этот код представляется полезным при написании аннотаций в XML-файле. http://gate.ac.uk/wiki/code-repository/src/sheffield/examples/BatchProcessApp.java

 String docXMLString = null; 
     // if we want to just write out specific annotation types, we must 
     // extract the annotations into a Set 
     if(annotTypesToWrite != null) { 
      // Create a temporary Set to hold the annotations we wish to write out 
      Set annotationsToWrite = new HashSet(); 

      // we only extract annotations from the default (unnamed) AnnotationSet 
      // in this example 
      AnnotationSet defaultAnnots = doc.getAnnotations(); 
      Iterator annotTypesIt = annotTypesToWrite.iterator(); 
      while(annotTypesIt.hasNext()) { 
       // extract all the annotations of each requested type and add them to 
       // the temporary set 
       AnnotationSet annotsOfThisType = 
         defaultAnnots.get((String)annotTypesIt.next()); 
       if(annotsOfThisType != null) { 
        annotationsToWrite.addAll(annotsOfThisType); 
       } 
      } 

      // create the XML string using these annotations 
      docXMLString = doc.toXml(annotationsToWrite); 
     } 
     // otherwise, just write out the whole document as GateXML 
     else { 
      docXMLString = doc.toXml(); 
     } 

     // Release the document, as it is no longer needed 
     Factory.deleteResource(doc); 

     // output the XML to <inputFile>.out.xml 
     String outputFileName = docFile.getName() + ".out.xml"; 
     File outputFile = new File(docFile.getParentFile(), outputFileName); 

     // Write output files using the same encoding as the original 
     FileOutputStream fos = new FileOutputStream(outputFile); 
     BufferedOutputStream bos = new BufferedOutputStream(fos); 
     OutputStreamWriter out; 
     if(encoding == null) { 
      out = new OutputStreamWriter(bos); 
     } 
     else { 
      out = new OutputStreamWriter(bos, encoding); 
     } 

     out.write(docXMLString); 

     out.close(); 
     System.out.println("done"); 

 Смежные вопросы

  • Нет связанных вопросов^_^