ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seanfi...@apache.org
Subject svn commit: r1765436 - in /ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/pretty: html/CssWriter.java html/HtmlTextWriter.java plaintext/PrettyTextWriter.java
Date Tue, 18 Oct 2016 13:20:04 GMT
Author: seanfinan
Date: Tue Oct 18 13:20:04 2016
New Revision: 1765436

URL: http://svn.apache.org/viewvc?rev=1765436&view=rev
Log:
Margins in body and sentence
refactoring

Modified:
    ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/pretty/html/CssWriter.java
    ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/pretty/html/HtmlTextWriter.java
    ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/pretty/plaintext/PrettyTextWriter.java

Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/pretty/html/CssWriter.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/pretty/html/CssWriter.java?rev=1765436&r1=1765435&r2=1765436&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/pretty/html/CssWriter.java
(original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/pretty/html/CssWriter.java
Tue Oct 18 13:20:04 2016
@@ -28,6 +28,7 @@ final class CssWriter {
          return false;
       }
       try ( final BufferedWriter writer = new BufferedWriter( new FileWriter( outputFile
) ) ) {
+         writer.write( setBody() );
          writer.write( setUnderline( "affirmed", "green", "solid", "0.2" ) );
          writer.write( setUnderline( "uncertain", "gold", "dotted", "0.2" ) );
          writer.write( setUnderline( "negated", "red", "dashed", "0.2" ) );
@@ -46,6 +47,15 @@ final class CssWriter {
    }
 
 
+   static private String setBody() {
+      return "\nbody {\n" +
+             "  margin: 20px;\n" +
+             "}\n" +
+             "\ndiv {\n" +
+             "  margin-bottom: 0.4em;\n" +
+             "}\n";
+   }
+
    // dashType is solid or dashed or double or dotted, try wavy      size is relative: 0.1
or 0.2 for 10%, 20%
    static private String setUnderline( final String className, final String color, final
String dashType,
                                        final String size ) {
@@ -57,8 +67,9 @@ final class CssWriter {
    }
 
    static private String setColor( final String className, final String color ) {
-      return "\n." + className + " {\n" +
-             "  color: " + color + ";\n" +
+      return "\n." + className + "::first-letter {\n" +
+//             "  color: " + color + ";\n" +
+             "  font-weight: bold;\n" +
              "}\n";
    }
 

Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/pretty/html/HtmlTextWriter.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/pretty/html/HtmlTextWriter.java?rev=1765436&r1=1765435&r2=1765436&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/pretty/html/HtmlTextWriter.java
(original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/pretty/html/HtmlTextWriter.java
Tue Oct 18 13:20:04 2016
@@ -151,7 +151,7 @@ final public class HtmlTextWriter extend
          if ( beginTag != null ) {
             sb.append( beginTag );
          }
-         sb.append( entry.getKey() );
+         sb.append( entry.getValue() );
          final String endTag = tags.get( entry.getKey().getEnd() );
          if ( endTag != null ) {
             sb.append( endTag );
@@ -187,16 +187,23 @@ final public class HtmlTextWriter extend
       final Map<Integer, String> tags = createTags( annotationMap );
       final StringBuilder sb = new StringBuilder();
       int previousEndIndex = -1;
+      boolean annotation;
       for ( Map.Entry<TextSpan, String> entry : baseTokenMap.entrySet() ) {
+         annotation = false;
          final TextSpan textSpan = entry.getKey();
          if ( textSpan.getBegin() != previousEndIndex ) {
             // If the previous end index was this begin index then the tag was already written
             final String beginTag = tags.get( textSpan.getBegin() );
             if ( beginTag != null ) {
                sb.append( beginTag );
+               annotation = true;
             }
          }
+//         if ( annotation ) {
+//            sb.append( "<b>" ).append( entry.getValue().charAt( 0 ) ).append( "</b>"
).append( entry.getValue().substring( 1 ) );
+//         } else {
          sb.append( entry.getValue() );
+//         }
          final String endTag = tags.get( textSpan.getEnd() );
          if ( endTag != null ) {
             sb.append( endTag );

Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/pretty/plaintext/PrettyTextWriter.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/pretty/plaintext/PrettyTextWriter.java?rev=1765436&r1=1765435&r2=1765436&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/pretty/plaintext/PrettyTextWriter.java
(original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/pretty/plaintext/PrettyTextWriter.java
Tue Oct 18 13:20:04 2016
@@ -28,6 +28,7 @@ import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.util.*;
+import java.util.stream.Collectors;
 
 
 /**
@@ -245,12 +246,15 @@ final public class PrettyTextWriter {
                                  offsetAdjustedMap.get( textSpan.getBegin() );
             if ( needWidth > nowWidth ) {
                final int delta = needWidth - nowWidth;
-               for ( Integer originalOffset : offsetList ) {
-                  if ( originalOffset >= textSpan.getEnd() ) {
-                     final Integer oldAdjustedOffset = offsetAdjustedMap.get( originalOffset
);
-                     offsetAdjustedMap.put( originalOffset, oldAdjustedOffset + delta );
-                  }
-               }
+               offsetList.stream()
+                     .filter( o -> o >= textSpan.getEnd() )
+                     .forEach( o -> offsetAdjustedMap.put( o, offsetAdjustedMap.get( o
) + delta ) );
+//               for ( Integer originalOffset : offsetList ) {
+//                  if ( originalOffset >= textSpan.getEnd() ) {
+//                     final Integer oldAdjustedOffset = offsetAdjustedMap.get( originalOffset
);
+//                     offsetAdjustedMap.put( originalOffset, oldAdjustedOffset + delta );
+//                  }
+//               }
             }
          }
       }
@@ -337,13 +341,10 @@ final public class PrettyTextWriter {
     */
    static private Collection<ItemCell> getCoveredBaseItems( final TextSpan textSpan,
                                                             final Map<TextSpan, ItemCell>
baseItemMap ) {
-      final Collection<ItemCell> coveredBaseItems = new ArrayList<>();
-      for ( Map.Entry<TextSpan, ItemCell> baseItemEntry : baseItemMap.entrySet() )
{
-         if ( baseItemEntry.getKey().overlaps( textSpan ) ) {
-            coveredBaseItems.add( baseItemEntry.getValue() );
-         }
-      }
-      return coveredBaseItems;
+      return baseItemMap.entrySet().stream()
+            .filter( e -> e.getKey().overlaps( textSpan ) )
+            .map( Map.Entry::getValue )
+            .collect( Collectors.toList() );
    }
 
 



Mime
View raw message