ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlig...@apache.org
Subject svn commit: r1763926 - /ctakes/sandbox/ctakes-wsd/src/main/java/org/apache/ctakes/pipelines/ExtractCuis.java
Date Sat, 08 Oct 2016 17:44:12 GMT
Author: dligach
Date: Sat Oct  8 17:44:12 2016
New Revision: 1763926

URL: http://svn.apache.org/viewvc?rev=1763926&view=rev
Log:
now including original text + semantic type

Modified:
    ctakes/sandbox/ctakes-wsd/src/main/java/org/apache/ctakes/pipelines/ExtractCuis.java

Modified: ctakes/sandbox/ctakes-wsd/src/main/java/org/apache/ctakes/pipelines/ExtractCuis.java
URL: http://svn.apache.org/viewvc/ctakes/sandbox/ctakes-wsd/src/main/java/org/apache/ctakes/pipelines/ExtractCuis.java?rev=1763926&r1=1763925&r2=1763926&view=diff
==============================================================================
--- ctakes/sandbox/ctakes-wsd/src/main/java/org/apache/ctakes/pipelines/ExtractCuis.java (original)
+++ ctakes/sandbox/ctakes-wsd/src/main/java/org/apache/ctakes/pipelines/ExtractCuis.java Sat
Oct  8 17:44:12 2016
@@ -103,27 +103,29 @@ public class ExtractCuis {
 
       List<String> cuis = new ArrayList<>();
       for (EventMention eventMention : JCasUtil.select(systemView, EventMention.class)) {
-        // String text = eventMention.getCoveredText().toLowerCase();
-        // String semanticType = eventMention.getClass().getSimpleName();
+        String text = eventMention.getCoveredText().toLowerCase().replaceAll(" ", "_");
+        String semanticType = eventMention.getClass().getSimpleName();
         int polarity = eventMention.getPolarity();
         for(String code : getOntologyConceptCodes(eventMention)) {
+          String output = String.format("%s|%s|%s", code, text, semanticType);
           if(polarity > 0) {
-            cuis.add(code);
+            cuis.add(output);
           } else {
-            cuis.add("-1" + code);
+            cuis.add("-" + output);
           }
         }
       }
 
       for (EntityMention entityMention : JCasUtil.select(systemView, EntityMention.class))
{
-        // String text = entityMention.getCoveredText().toLowerCase();
-        // String semanticType = entityMention.getClass().getSimpleName();
+        String text = entityMention.getCoveredText().toLowerCase().replaceAll(" ", "_");
+        String semanticType = entityMention.getClass().getSimpleName();
         int polarity = entityMention.getPolarity();
         for(String code : getOntologyConceptCodes(entityMention)) {
+          String output = String.format("%s|%s|%s", code, text, semanticType);
           if(polarity > 0) {
-            cuis.add(code);
+            cuis.add(output);
           } else {
-            cuis.add("-" + code);
+            cuis.add("-" + output);
           }
         }
       }
@@ -132,7 +134,7 @@ public class ExtractCuis {
       String fileName = noteFile.getName();
       String outputString = String.join(" ", cuis);
       try {
-        Files.write(Paths.get(outputDir + fileName), outputString.getBytes());
+        Files.write(Paths.get(outputDir + fileName + ".txt"), outputString.getBytes());
       } catch (IOException e) {
         e.printStackTrace();
       }



Mime
View raw message