ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tm...@apache.org
Subject svn commit: r1680395 - /ctakes/sandbox/ctakes-coref-cleartk/src/main/java/org/apache/ctakes/coreference/ae/CoreferenceChainScoringOutput.java
Date Tue, 19 May 2015 21:21:21 GMT
Author: tmill
Date: Tue May 19 21:21:21 2015
New Revision: 1680395

URL: http://svn.apache.org/r1680395
Log:
Some minor changes in output format for icarus GUI error analysis tool.

Modified:
    ctakes/sandbox/ctakes-coref-cleartk/src/main/java/org/apache/ctakes/coreference/ae/CoreferenceChainScoringOutput.java

Modified: ctakes/sandbox/ctakes-coref-cleartk/src/main/java/org/apache/ctakes/coreference/ae/CoreferenceChainScoringOutput.java
URL: http://svn.apache.org/viewvc/ctakes/sandbox/ctakes-coref-cleartk/src/main/java/org/apache/ctakes/coreference/ae/CoreferenceChainScoringOutput.java?rev=1680395&r1=1680394&r2=1680395&view=diff
==============================================================================
--- ctakes/sandbox/ctakes-coref-cleartk/src/main/java/org/apache/ctakes/coreference/ae/CoreferenceChainScoringOutput.java
(original)
+++ ctakes/sandbox/ctakes-coref-cleartk/src/main/java/org/apache/ctakes/coreference/ae/CoreferenceChainScoringOutput.java
Tue May 19 21:21:21 2015
@@ -34,10 +34,11 @@ public class CoreferenceChainScoringOutp
   @ConfigurationParameter(
       name = PARAM_OUTPUT_FILENAME,
       mandatory = true,
-      description = "Directory to write output"
+      description = "Name of chain file in CoNLL format"
       )
   private String outputFilename;
   private PrintWriter out = null;
+  private PrintWriter icOut = null;
   
   public static final String PARAM_GOLD_VIEW_NAME = "GoldViewName";
   @ConfigurationParameter(
@@ -46,6 +47,7 @@ public class CoreferenceChainScoringOutp
       description = "Name of gold view in jcas"
       )
   private String goldViewName = null;
+  boolean isGold;
   
   private int docNum = 0;
   
@@ -59,6 +61,17 @@ public class CoreferenceChainScoringOutp
       e.printStackTrace();
       throw new ResourceInitializationException(e);
     }
+    
+    if(goldViewName != null) isGold = true;
+    else{
+      isGold = false;
+      try {
+        icOut = new PrintWriter(outputFilename + ".icarus");
+      } catch (FileNotFoundException e) {
+        e.printStackTrace();
+        throw new ResourceInitializationException(e);
+      }
+    }
   }
   
   @Override
@@ -73,8 +86,14 @@ public class CoreferenceChainScoringOutp
     }
     int chainNum = 1;
     HashMap<Annotation, Integer> ent2chain = new HashMap<>();
-    if(goldViewName != null) System.out.println("\nGold chains:");
-    else System.out.println("\nSystem chains:");
+    
+    if(isGold) System.out.println("\nGold chains:");
+    else{
+      icOut.println(String.format("#begin document (%s); part 000", filename.getPath()));
+      System.out.println("\nSystem chains:");
+    }
+    
+    
     Collection<CollectionTextRelation> rels = JCasUtil.select(chainsCas, CollectionTextRelation.class);
     if(rels.size() == 0){
       return;
@@ -104,6 +123,7 @@ public class CoreferenceChainScoringOutp
     List<BaseToken> tokens = new ArrayList<>(JCasUtil.select(jCas, BaseToken.class));
     Multiset<Integer> endSet = HashMultiset.create();
     int tokenId = 0;
+    int sentId = 0;
 
     for(int i = 0; i < tokens.size(); i++){
       BaseToken token = tokens.get(i);
@@ -114,6 +134,7 @@ public class CoreferenceChainScoringOutp
         if(tokenId > 0){
           out.println();
           tokenId = 0;
+          sentId++;
         }
         continue;
       }
@@ -145,6 +166,10 @@ public class CoreferenceChainScoringOutp
             }
             endMention.add(ent2chain.get(markable));
           }
+          
+          if(!isGold){
+            icOut.println(String.format("%d-%d-%d\n", sentId, markable.getBegin(), markable.getEnd()));
+          }
         }
       }
       
@@ -220,6 +245,9 @@ public class CoreferenceChainScoringOutp
 //    out.println();
 //      lastToken = token;
     }
+    if(!isGold){
+      icOut.println("#end document");
+    }
     out.println("#end document " + filename.getPath());
     out.flush();
     docNum++;



Mime
View raw message