ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seanfi...@apache.org
Subject svn commit: r1885693 - in /ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core: cr/AbstractFileTreeReader.java util/doc/JCasBuilder.java
Date Tue, 19 Jan 2021 17:08:52 GMT
Author: seanfinan
Date: Tue Jan 19 17:08:52 2021
New Revision: 1885693

URL: http://svn.apache.org/viewvc?rev=1885693&view=rev
Log:
Fix/workaround for jcas.setDocText being callable only once.

Modified:
    ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cr/AbstractFileTreeReader.java
    ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/util/doc/JCasBuilder.java

Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cr/AbstractFileTreeReader.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cr/AbstractFileTreeReader.java?rev=1885693&r1=1885692&r2=1885693&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cr/AbstractFileTreeReader.java
(original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cr/AbstractFileTreeReader.java
Tue Jan 19 17:08:52 2021
@@ -7,6 +7,7 @@ import org.apache.ctakes.core.resource.F
 import org.apache.ctakes.core.util.NumberedSuffixComparator;
 import org.apache.ctakes.core.util.doc.JCasBuilder;
 import org.apache.ctakes.core.util.doc.NoteSpecs;
+import org.apache.ctakes.core.util.doc.SourceMetadataUtil;
 import org.apache.log4j.Logger;
 import org.apache.uima.UimaContext;
 import org.apache.uima.collection.CollectionException;
@@ -212,7 +213,7 @@ abstract public class AbstractFileTreeRe
     * @return the patientId for that file.  By default this is the name of the directory
containing the file.
     */
    protected String getPatientId( final File file ) {
-      return _filePatients.get( file );
+      return _filePatients.getOrDefault( file, SourceMetadataUtil.UNKNOWN_PATIENT );
    }
 
    /**
@@ -532,14 +533,15 @@ abstract public class AbstractFileTreeRe
       final String idPrefix = createDocumentIdPrefix( file, getRootDir() );
       final String docType = createDocumentType( id );
       final String docTime = createDocumentTime( file );
-      final String patientId = _filePatients.get( file );
+      final String patientId = getPatientId( file );
       return new JCasBuilder()
             .setDocId( id )
             .setDocIdPrefix( idPrefix )
             .setDocType( docType )
             .setDocTime( docTime )
             .setPatientId( patientId )
-            .setDocPath( file.getAbsolutePath() );
+            .setDocPath( file.getAbsolutePath() )
+            .nullDocText();
    }
 
    /**
@@ -562,9 +564,9 @@ abstract public class AbstractFileTreeRe
       final File file = _files.get( _currentIndex );
       ProgressManager.getInstance().updateProgress( _currentIndex );
       _currentIndex++;
-      readFile( jcas, file );
       // Add document metadata based upon file path
       getJCasBuilder( file ).populate( jcas );
+      readFile( jcas, file );
    }
 
 

Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/util/doc/JCasBuilder.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/util/doc/JCasBuilder.java?rev=1885693&r1=1885692&r2=1885693&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/util/doc/JCasBuilder.java
(original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/util/doc/JCasBuilder.java
Tue Jan 19 17:08:52 2021
@@ -199,7 +199,7 @@ final public class JCasBuilder {
    }
 
    private boolean ifWrite( final String value, final String defaultValue ) {
-      return _overwrite || !value.equals( defaultValue );
+      return value != null && ( _overwrite || !defaultValue.equals( value ) );
    }
 
    private boolean ifWrite( final int value, final int defaultValue ) {



Mime
View raw message