You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ctakes.apache.org by se...@apache.org on 2017/03/10 21:02:09 UTC
svn commit: r1786449 - in /ctakes/trunk:
ctakes-assertion-res/src/main/resources/org/apache/ctakes/assertion/pipeline/
ctakes-core/src/main/java/org/apache/ctakes/core/cc/
ctakes-core/src/main/java/org/apache/ctakes/core/config/
ctakes-core/src/main/ja...
Author: seanfinan
Date: Fri Mar 10 21:02:09 2017
New Revision: 1786449
URL: http://svn.apache.org/viewvc?rev=1786449&view=rev
Log:
PiperFileReader deprecated addPackage in favor of new command package
PiperFileReader Added classpath lookup to load command
AbstractOutputFileWriter added parameter SubDirectory
ConfigParameterConstants added LookupXml for dictionary lookup xml specification
CliOptionals removed -l
CliOptionalsHandler removed -l
PiperFileRunner added use of cli Option -l for LookupXml
StandardOptions added cli option -l for LookupXml
FileLocator added quiet version getFullPathQuiet for looped calls
AbstractJCasTermAnnotator added LookupXml in favor of deprecated DictionaryDescriptor
JCasTermAnnotator deprecated DictionaryDescriptor
UmlsUserApprover utilize DotLogger instead of older in-class implementation
Modified:
ctakes/trunk/ctakes-assertion-res/src/main/resources/org/apache/ctakes/assertion/pipeline/AssertionSubPipe.piper
ctakes/trunk/ctakes-assertion-res/src/main/resources/org/apache/ctakes/assertion/pipeline/AttributeCleartkSubPipe.piper
ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/AbstractOutputFileWriter.java
ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/config/ConfigParameterConstants.java
ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/CliOptionals.java
ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/CliOptionalsHandler.java
ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/PiperFileReader.java
ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/PiperFileRunner.java
ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/StandardOptions.java
ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/resource/FileLocator.java
ctakes/trunk/ctakes-dependency-parser/src/main/java/org/apache/ctakes/dependency/parser/util/ClearDependencyUtility.java
ctakes/trunk/ctakes-dependency-parser/src/main/java/org/apache/ctakes/dependency/parser/util/DependencyUtility.java
ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/AbstractJCasTermAnnotator.java
ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/JCasTermAnnotator.java
ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/UmlsUserApprover.java
ctakes/trunk/ctakes-examples-res/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorld.piper
ctakes/trunk/ctakes-examples-res/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldProps.piper
ctakes/trunk/ctakes-examples-res/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldTkProps.piper
Modified: ctakes/trunk/ctakes-assertion-res/src/main/resources/org/apache/ctakes/assertion/pipeline/AssertionSubPipe.piper
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-assertion-res/src/main/resources/org/apache/ctakes/assertion/pipeline/AssertionSubPipe.piper?rev=1786449&r1=1786448&r2=1786449&view=diff
==============================================================================
--- ctakes/trunk/ctakes-assertion-res/src/main/resources/org/apache/ctakes/assertion/pipeline/AssertionSubPipe.piper (original)
+++ ctakes/trunk/ctakes-assertion-res/src/main/resources/org/apache/ctakes/assertion/pipeline/AssertionSubPipe.piper Fri Mar 10 21:02:09 2017
@@ -6,8 +6,8 @@ addDescription ClearNLPDependencyParserA
addLogged ClearNLPSemanticRoleLabelerAE
// Add the assertion packages for class lookups
-addPackage org.apache.ctakes.assertion.medfacts
-addPackage org.apache.ctakes.assertion.attributes
+package org.apache.ctakes.assertion.medfacts
+package org.apache.ctakes.assertion.attributes
add ConceptConverterAnalysisEngine
add AssertionAnalysisEngineFit
add GenericAttributeAnalysisEngine
Modified: ctakes/trunk/ctakes-assertion-res/src/main/resources/org/apache/ctakes/assertion/pipeline/AttributeCleartkSubPipe.piper
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-assertion-res/src/main/resources/org/apache/ctakes/assertion/pipeline/AttributeCleartkSubPipe.piper?rev=1786449&r1=1786448&r2=1786449&view=diff
==============================================================================
--- ctakes/trunk/ctakes-assertion-res/src/main/resources/org/apache/ctakes/assertion/pipeline/AttributeCleartkSubPipe.piper (original)
+++ ctakes/trunk/ctakes-assertion-res/src/main/resources/org/apache/ctakes/assertion/pipeline/AttributeCleartkSubPipe.piper Fri Mar 10 21:02:09 2017
@@ -6,7 +6,7 @@ addDescription ClearNLPDependencyParserA
addLogged ClearNLPSemanticRoleLabelerAE
// Add the cleartk package for cleartk class lookups
-addPackage org.apache.ctakes.assertion.medfacts.cleartk
+package org.apache.ctakes.assertion.medfacts.cleartk
// Add the cleartk attribute engines
addDescription PolarityCleartkAnalysisEngine
addDescription UncertaintyCleartkAnalysisEngine
Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/AbstractOutputFileWriter.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/AbstractOutputFileWriter.java?rev=1786449&r1=1786448&r2=1786449&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/AbstractOutputFileWriter.java (original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/cc/AbstractOutputFileWriter.java Fri Mar 10 21:02:09 2017
@@ -40,6 +40,12 @@ abstract public class AbstractOutputFile
)
private File _outputRootDir;
+ @ConfigurationParameter(
+ name = "SubDirectory",
+ description = "SubDirectory for all output files.",
+ defaultValue = ""
+ )
+ private String _subDirectory;
/**
* {@inheritDoc}
@@ -112,19 +118,24 @@ abstract public class AbstractOutputFile
*/
protected String getSubdirectory( final JCas jCas, final String documentId ) {
String subDirectory = "";
+ String subSeparator = "";
+ if ( _subDirectory != null && !_subDirectory.isEmpty() ) {
+ subDirectory = _subDirectory;
+ subSeparator = "/";
+ }
final Collection<DocumentIdPrefix> prefices = JCasUtil.select( jCas, DocumentIdPrefix.class );
if ( prefices == null || prefices.isEmpty() ) {
LOGGER.debug( "No subdirectory information for " + documentId );
- return "";
+ return subDirectory;
}
for ( DocumentIdPrefix prefix : prefices ) {
- subDirectory = prefix.getDocumentIdPrefix();
- if ( subDirectory != null && !subDirectory.isEmpty() ) {
- return subDirectory;
+ String docSubDirectory = prefix.getDocumentIdPrefix();
+ if ( docSubDirectory != null && !docSubDirectory.isEmpty() ) {
+ return subDirectory + subSeparator + docSubDirectory;
}
}
LOGGER.debug( "No subdirectory information for " + documentId );
- return "";
+ return subDirectory;
}
/**
Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/config/ConfigParameterConstants.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/config/ConfigParameterConstants.java?rev=1786449&r1=1786448&r2=1786449&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/config/ConfigParameterConstants.java (original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/config/ConfigParameterConstants.java Fri Mar 10 21:02:09 2017
@@ -26,5 +26,12 @@ final public class ConfigParameterConsta
static public final String OPTION_OUTPUTDIR = "-o";
static public final String DESC_OUTPUTDIR = "Directory for all output files.";
+ /**
+ * Name of configuration parameter that can be set to the path of
+ * a file containing dictionary lookup configuration.
+ */
+ static public final String PARAM_LOOKUP_XML = "LookupXml";
+ static public final String OPTION_LOOKUP_XML = "-l";
+ static public final String DESC_LOOKUP_XML = "Directory for all output files.";
}
Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/CliOptionals.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/CliOptionals.java?rev=1786449&r1=1786448&r2=1786449&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/CliOptionals.java (original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/CliOptionals.java Fri Mar 10 21:02:09 2017
@@ -65,10 +65,7 @@ public interface CliOptionals extends St
defaultValue = "" )
String getOption_k();
- @Option(
- shortName = "l",
- defaultValue = "" )
- String getOption_l();
+ // -l is reserved for common parameter "LookupXml"
@Option(
shortName = "m",
@@ -236,10 +233,7 @@ public interface CliOptionals extends St
defaultValue = "" )
String getOption_K();
- @Option(
- shortName = "L",
- defaultValue = "" )
- String getOption_L();
+ // -l is reserved for common parameter "LookupXml"
@Option(
shortName = "M",
Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/CliOptionalsHandler.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/CliOptionalsHandler.java?rev=1786449&r1=1786448&r2=1786449&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/CliOptionalsHandler.java (original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/CliOptionalsHandler.java Fri Mar 10 21:02:09 2017
@@ -43,8 +43,6 @@ final public class CliOptionalsHandler {
return optionals.getOption_j();
case "k":
return optionals.getOption_k();
- case "l":
- return optionals.getOption_l();
case "m":
return optionals.getOption_m();
case "n":
@@ -109,8 +107,6 @@ final public class CliOptionalsHandler {
return optionals.getOption_J();
case "K":
return optionals.getOption_K();
- case "L":
- return optionals.getOption_L();
case "M":
return optionals.getOption_M();
case "N":
Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/PiperFileReader.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/PiperFileReader.java?rev=1786449&r1=1786448&r2=1786449&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/PiperFileReader.java (original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/PiperFileReader.java Fri Mar 10 21:02:09 2017
@@ -11,6 +11,7 @@ import org.apache.uima.collection.Collec
import org.apache.uima.resource.ResourceInitializationException;
import java.io.BufferedReader;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
@@ -25,8 +26,8 @@ import java.util.regex.Pattern;
* Creates a pipeline (PipelineBuilder) from specifications in a flat plaintext file.
*
* <p>There are several basic commands:
+ * package <i>user_package_name</i>
* load <i>path_to_another_pipeline_file</i>
- * addPackage <i>user_package_name</i>
* set <i>ae_parameter_name=ae_parameter_value e_parameter_name=ae_parameter_value</i> ...
* cli <i>ae_parameter_name=cli_parameter_char e_parameter_name=cli_parameter_char</i> ...
* reader <i>collection_reader_class_name</i>
@@ -45,7 +46,7 @@ import java.util.regex.Pattern;
* // and # and ! may be used to mark line comments
* </p>
* class names must be fully-specified with package unless they are in standard ctakes cr ae or cc packages,
- * or in a package specified by an earlier addPackage command.
+ * or in a package specified by an earlier package command.
*
* @author SPF , chip-nlp
* @version %I%
@@ -139,7 +140,7 @@ final public class PiperFileReader {
public void loadPipelineFile( final String filePath ) throws UIMAException {
try ( final BufferedReader reader
= new BufferedReader( new InputStreamReader(
- FileLocator.getAsStream( FileLocator.getFullPath( filePath ) ) ) ) ) {
+ FileLocator.getAsStream( getPiperPath( filePath ) ) ) ) ) {
String line = reader.readLine();
while ( line != null ) {
line = line.trim();
@@ -177,7 +178,7 @@ final public class PiperFileReader {
case "load":
loadPipelineFile( parameter );
break;
- case "addPackage":
+ case "package":
_userPackages.add( parameter );
break;
case "set":
@@ -317,6 +318,43 @@ final public class PiperFileReader {
}
/**
+ * @param filePath fully-specified or simple path of a piper file
+ * @return discovered path for the piper file
+ */
+ private String getPiperPath( final String filePath ) throws FileNotFoundException {
+ String fullPath = FileLocator.getFullPathQuiet( filePath );
+ if ( fullPath != null && !fullPath.isEmpty() ) {
+ return fullPath;
+ }
+ // Check user packages
+ for ( String packageName : _userPackages ) {
+ fullPath = FileLocator.getFullPathQuiet( packageName.replace( '.', '/' ) + '/' + filePath );
+ if ( fullPath != null && !fullPath.isEmpty() ) {
+ return fullPath;
+ }
+ fullPath = FileLocator.getFullPathQuiet( packageName.replace( '.', '/' ) + "/pipeline/" + filePath );
+ if ( fullPath != null && !fullPath.isEmpty() ) {
+ return fullPath;
+ }
+ }
+ // Check ctakes packages
+ for ( String packageName : CTAKES_PACKAGES ) {
+ fullPath = FileLocator
+ .getFullPathQuiet( "org/apache/ctakes/" + packageName.replace( '.', '/' ) + '/' + filePath );
+ if ( fullPath != null && !fullPath.isEmpty() ) {
+ return fullPath;
+ }
+ fullPath = FileLocator
+ .getFullPathQuiet( "org/apache/ctakes/" + packageName.replace( '.', '/' ) + "/pipeline/" + filePath );
+ if ( fullPath != null && !fullPath.isEmpty() ) {
+ return fullPath;
+ }
+ }
+ throw new FileNotFoundException( "No piper file found for " + filePath );
+ }
+
+
+ /**
* This requires that the component class has a static createAnnotatorDescription method with no parameters
* @param className component class for which a descriptor should be created
* @param values optional parameter values for the descriptor creator
Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/PiperFileRunner.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/PiperFileRunner.java?rev=1786449&r1=1786448&r2=1786449&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/PiperFileRunner.java (original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/PiperFileRunner.java Fri Mar 10 21:02:09 2017
@@ -41,6 +41,11 @@ final public class PiperFileRunner {
} else if ( !xmiOutDir.isEmpty() ) {
builder.set( ConfigParameterConstants.PARAM_OUTPUTDIR, xmiOutDir );
}
+ // set the dictionary lookup descriptor xml
+ final String lookupXml = options.getLookupXml();
+ if ( !lookupXml.isEmpty() ) {
+ builder.set( ConfigParameterConstants.PARAM_LOOKUP_XML, lookupXml );
+ }
// set the umls user and password parameters if needed
final String umlsUser = options.getUmlsUserName();
if ( !umlsUser.isEmpty() ) {
Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/StandardOptions.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/StandardOptions.java?rev=1786449&r1=1786448&r2=1786449&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/StandardOptions.java (original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/StandardOptions.java Fri Mar 10 21:02:09 2017
@@ -37,6 +37,12 @@ interface StandardOptions {
String getXmiOutDirectory();
@Option(
+ shortName = "l",
+ longName = "lookupXml",
+ description = "path to the xml file containing information for dictionary lookup configuration." )
+ String getLookupXml();
+
+ @Option(
longName = "user",
description = "UMLS username.",
defaultValue = "" )
Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/resource/FileLocator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/resource/FileLocator.java?rev=1786449&r1=1786448&r2=1786449&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/resource/FileLocator.java (original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/resource/FileLocator.java Fri Mar 10 21:02:09 2017
@@ -117,6 +117,48 @@ final public class FileLocator {
* @throws FileNotFoundException if the file cannot be found
*/
static public String getFullPath( final String relativePath ) throws FileNotFoundException {
+ final String fullPath = getFullPathQuiet( relativePath );
+ if ( fullPath != null && !fullPath.isEmpty() ) {
+ return fullPath;
+ }
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "Could not find " ).append( relativePath ).append( "\nas absolute or in $CLASSPATH :\n" );
+ final ClassLoader classLoader = ClassLoader.getSystemClassLoader();
+ final URL[] classpathUrls = ((URLClassLoader)classLoader).getURLs();
+ for ( URL url : classpathUrls ) {
+ sb.append( url.getFile() ).append( "\n" );
+ }
+ final String cwd = System.getProperty( "user.dir" );
+ sb.append( "or in working directory : " ).append( cwd ).append( "\n" );
+ sb.append( "or in any parent thereof (with or without /ctakes/)\n" );
+ final String cTakesHome = System.getenv( CTAKES_HOME );
+ sb.append( "or in $CTAKES_HOME : " ).append( cTakesHome );
+ LOGGER.error( sb.toString() );
+ throw new FileNotFoundException( "No File exists at " + relativePath );
+ }
+
+ /**
+ * QUIETLY Attempts to discover the real location of a file pointed to by relativePath.
+ * The search will be performed in the following order:
+ * <p>
+ * 1. By checking to see if the provided relative path is actually an absolute path
+ * 2. By checking within the ClassPath
+ * 3. By checking directly under the current working directory
+ * 4. By checking under $CTAKES_HOME
+ * 5. By traversing above the current working directory. Useful when running under a module directory in an IDE
+ * Example: cwd = /usr/bin/ctakes/ctakes-module , relativePath = ctakes-other-module/more/file.ext
+ * The directory above cwd /usr/bin/ctakes will be checked for containment of the relative path
+ * If /usr/bin/ctakes/ctakes-other-module/more/file.txt exists then that is returned
+ * 6. By traversing above the current working directory and under a subdirectory ctakes/
+ * Example: cwd = /usr/bin/my_custom_ctakes/my_ctakes-module , relativePath = ctakes-other-module/more/file.ext
+ * The directory above cwd /usr/bin will be checked for containment of ctakes/ plus the relative path
+ * If /usr/bin/ctakes/ctakes-other-module/more/file.txt exists then that is returned
+ * </p>
+ *
+ * @param relativePath some relative path to a file
+ * @return the canonical path of the file or the absolute path of the file if the canonical cannot be made
+ */
+ static public String getFullPathQuiet( final String relativePath ) {
File file = new File( relativePath );
if ( file.exists() ) {
return createDiscoveredPath( relativePath, file, "without adjustment" );
@@ -158,18 +200,7 @@ final public class FileLocator {
return createDiscoveredPath( relativePath, file, "above Working Directory /ctakes" );
}
}
- final StringBuilder sb = new StringBuilder();
- sb.append( "Could not find " ).append( relativePath ).append( "\nas absolute or in $CLASSPATH :\n" );
- final ClassLoader classLoader = ClassLoader.getSystemClassLoader();
- final URL[] classpathUrls = ((URLClassLoader)classLoader).getURLs();
- for ( URL url : classpathUrls ) {
- sb.append( url.getFile() ).append( "\n" );
- }
- sb.append( "or in working directory : " ).append( cwd ).append( "\n" );
- sb.append( "or in any parent thereof (with or without /ctakes/)\n" );
- sb.append( "or in $CTAKES_HOME : " ).append( cTakesHome );
- LOGGER.error( sb.toString() );
- throw new FileNotFoundException( "No File exists at " + relativePath );
+ return "";
}
/**
Modified: ctakes/trunk/ctakes-dependency-parser/src/main/java/org/apache/ctakes/dependency/parser/util/ClearDependencyUtility.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dependency-parser/src/main/java/org/apache/ctakes/dependency/parser/util/ClearDependencyUtility.java?rev=1786449&r1=1786448&r2=1786449&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dependency-parser/src/main/java/org/apache/ctakes/dependency/parser/util/ClearDependencyUtility.java (original)
+++ ctakes/trunk/ctakes-dependency-parser/src/main/java/org/apache/ctakes/dependency/parser/util/ClearDependencyUtility.java Fri Mar 10 21:02:09 2017
@@ -18,9 +18,8 @@
*/
package org.apache.ctakes.dependency.parser.util;
-import java.util.ArrayList;
-import java.util.List;
-
+import com.googlecode.clearnlp.dependency.DEPNode;
+import com.googlecode.clearnlp.dependency.DEPTree;
import org.apache.ctakes.typesystem.type.syntax.BaseToken;
import org.apache.ctakes.typesystem.type.syntax.ConllDependencyNode;
import org.apache.ctakes.typesystem.type.textspan.Sentence;
@@ -28,8 +27,8 @@ import org.apache.log4j.Logger;
import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.tcas.Annotation;
-import com.googlecode.clearnlp.dependency.DEPNode;
-import com.googlecode.clearnlp.dependency.DEPTree;
+import java.util.ArrayList;
+import java.util.List;
/**
* @author m081914
@@ -73,8 +72,8 @@ public class ClearDependencyUtility exte
public static ArrayList<ConllDependencyNode> convert(JCas jcas, DEPTree clearTree, Sentence sentence, List<BaseToken> tokens) {
ArrayList<ConllDependencyNode> uimaNodes = new ArrayList<ConllDependencyNode>(tokens.size()+1);
-
- // Create the root node first
+
+ // Create the root node first
int rootBegin = tokens.get(0).getBegin();
int rootEnd = tokens.get(tokens.size()-1).getEnd();
uimaNodes.add( 0, new ConllDependencyNode(jcas, rootBegin, rootEnd));
Modified: ctakes/trunk/ctakes-dependency-parser/src/main/java/org/apache/ctakes/dependency/parser/util/DependencyUtility.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dependency-parser/src/main/java/org/apache/ctakes/dependency/parser/util/DependencyUtility.java?rev=1786449&r1=1786448&r2=1786449&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dependency-parser/src/main/java/org/apache/ctakes/dependency/parser/util/DependencyUtility.java (original)
+++ ctakes/trunk/ctakes-dependency-parser/src/main/java/org/apache/ctakes/dependency/parser/util/DependencyUtility.java Fri Mar 10 21:02:09 2017
@@ -18,19 +18,18 @@
*/
package org.apache.ctakes.dependency.parser.util;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Pattern;
-
+import org.apache.ctakes.typesystem.type.syntax.ConllDependencyNode;
+import org.apache.ctakes.typesystem.type.textspan.Sentence;
import org.apache.log4j.Logger;
import org.apache.uima.cas.FSIterator;
import org.apache.uima.cas.text.AnnotationIndex;
+import org.apache.uima.fit.util.JCasUtil;
import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.tcas.Annotation;
-import org.apache.uima.fit.util.JCasUtil;
-import org.apache.ctakes.typesystem.type.syntax.ConllDependencyNode;
-import org.apache.ctakes.typesystem.type.textspan.Sentence;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
/**
* @author m081914
@@ -122,15 +121,15 @@ public abstract class DependencyUtility
ArrayList<ConllDependencyNode> anodes = new ArrayList<ConllDependencyNode>(nodes);
Boolean[][] matrixofheads = new Boolean[anodes.size()][anodes.size()];
List<ConllDependencyNode> outnodes = new ArrayList<ConllDependencyNode>();
-
- // Remove root from consideration
+
+ // Remove root from consideration
for (int i=0; i<anodes.size(); i++) {
if (anodes.get(i).getId()==0) {
anodes.remove(i);
}
}
-
- // Create a dependency matrix
+
+ // Create a dependency matrix
for (int id1=0; id1<anodes.size(); id1++) {
for (int id2=0; id2<anodes.size(); id2++) {
// no head-dependency relationship between id1 and id2
@@ -164,8 +163,8 @@ public abstract class DependencyUtility
}
}
}
-
- // Unheaded phrases
+
+ // Unheaded phrases
if (outnodes.isEmpty()) {
// pick a noun from the left, if there is one
for (int i=0; i<anodes.size(); i++) {
Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/AbstractJCasTermAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/AbstractJCasTermAnnotator.java?rev=1786449&r1=1786448&r2=1786449&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/AbstractJCasTermAnnotator.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/AbstractJCasTermAnnotator.java Fri Mar 10 21:02:09 2017
@@ -18,6 +18,7 @@
*/
package org.apache.ctakes.dictionary.lookup2.ae;
+import org.apache.ctakes.core.config.ConfigParameterConstants;
import org.apache.ctakes.core.fsm.token.NumberToken;
import org.apache.ctakes.core.resource.FileLocator;
import org.apache.ctakes.core.util.JCasUtil;
@@ -66,6 +67,14 @@ abstract public class AbstractJCasTermAn
private DictionarySpec _dictionarySpec;
private final Set<String> _exclusionPartsOfSpeech = new HashSet<>();
+ @ConfigurationParameter( name = ConfigParameterConstants.PARAM_LOOKUP_XML, mandatory = false,
+ description = ConfigParameterConstants.DESC_LOOKUP_XML, defaultValue = "" )
+ private String _lookupXml;
+
+ /**
+ * @deprecated replaced by _lookupXml
+ */
+ @Deprecated
@ConfigurationParameter( name = JCasTermAnnotator.DICTIONARY_DESCRIPTOR_KEY, mandatory = false,
description = "Path to Dictionary spec xml", defaultValue = DEFAULT_DICT_DESC_PATH )
private String _descriptorFilePath;
@@ -111,8 +120,12 @@ abstract public class AbstractJCasTermAn
_minimumLookupSpan = parseInt( minimumSpan, PARAM_MIN_SPAN_KEY, _minimumLookupSpan );
}
LOGGER.info( "Using minimum term text span: " + _minimumLookupSpan );
- LOGGER.info( "Using Dictionary Descriptor: " + _descriptorFilePath );
- try ( InputStream descriptorStream = FileLocator.getAsStream( _descriptorFilePath ) ) {
+ String descriptorFilePath = _descriptorFilePath;
+ if ( _lookupXml != null && !_lookupXml.isEmpty() ) {
+ descriptorFilePath = _lookupXml;
+ }
+ LOGGER.info( "Using Dictionary Descriptor: " + descriptorFilePath );
+ try ( InputStream descriptorStream = FileLocator.getAsStream( descriptorFilePath ) ) {
_dictionarySpec = DictionaryDescriptorParser.parseDescriptor( descriptorStream, uimaContext );
} catch ( IOException | AnnotatorContextException multE ) {
throw new ResourceInitializationException( multE );
Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/JCasTermAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/JCasTermAnnotator.java?rev=1786449&r1=1786448&r2=1786449&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/JCasTermAnnotator.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/JCasTermAnnotator.java Fri Mar 10 21:02:09 2017
@@ -18,6 +18,7 @@
*/
package org.apache.ctakes.dictionary.lookup2.ae;
+import org.apache.ctakes.core.config.ConfigParameterConstants;
import org.apache.ctakes.core.util.collection.CollectionMap;
import org.apache.ctakes.dictionary.lookup2.dictionary.RareWordDictionary;
import org.apache.ctakes.dictionary.lookup2.textspan.TextSpan;
@@ -37,6 +38,10 @@ import java.util.List;
*/
public interface JCasTermAnnotator extends AnalysisComponent {
+ /**
+ * @deprecated replaced by {@link ConfigParameterConstants#PARAM_LOOKUP_XML }
+ */
+ @Deprecated
static final String DICTIONARY_DESCRIPTOR_KEY = "DictionaryDescriptor";
/**
* specifies the type of window to use for lookup
Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/UmlsUserApprover.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/UmlsUserApprover.java?rev=1786449&r1=1786448&r2=1786449&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/UmlsUserApprover.java (original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/UmlsUserApprover.java Fri Mar 10 21:02:09 2017
@@ -18,6 +18,7 @@
*/
package org.apache.ctakes.dictionary.lookup2.util;
+import org.apache.ctakes.core.util.DotLogger;
import org.apache.ctakes.utils.env.EnvironmentVariable;
import org.apache.log4j.Logger;
import org.apache.uima.UimaContext;
@@ -26,7 +27,9 @@ import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Properties;
/**
@@ -58,17 +61,12 @@ public enum UmlsUserApprover {
final static String UMLSPW_PARAM = "ctakes.umlspw";
static final private Logger LOGGER = Logger.getLogger( "UmlsUserApprover" );
- static final private Logger DOT_LOGGER = Logger.getLogger( "ProgressAppender" );
- static final private Logger EOL_LOGGER = Logger.getLogger( "ProgressDone" );
static final private String CHANGEME = "CHANGEME";
// cache of valid users
static private final Collection<String> _validUsers = new ArrayList<>();
- private UmlsUserApprover() {
- }
-
/**
* validate the UMLS license / user
*
@@ -134,10 +132,8 @@ public enum UmlsUserApprover {
return false;
}
- final Timer timer = new Timer();
- try {
+ try ( DotLogger dotter = new DotLogger() ) {
LOGGER.info( "Checking UMLS Account at " + umlsUrl + " for user " + user + ":" );
- timer.scheduleAtFixedRate( new DotPlotter(), 333, 333 );
final URL url = new URL( umlsUrl );
final URLConnection connection = url.openConnection();
connection.setDoOutput( true );
@@ -157,8 +153,6 @@ public enum UmlsUserApprover {
}
writer.close();
reader.close();
- timer.cancel();
- EOL_LOGGER.error( "" );
if ( isValidUser ) {
LOGGER.info( " UMLS Account at " + umlsUrl + " for user " + user + " has been validated" );
_validUsers.add( cacheCode );
@@ -167,24 +161,10 @@ public enum UmlsUserApprover {
}
return isValidUser;
} catch ( IOException ioE ) {
- timer.cancel();
- EOL_LOGGER.error( "" );
LOGGER.error( ioE.getMessage() );
return false;
}
}
- static private class DotPlotter extends TimerTask {
- private int _count = 0;
-
- @Override
- public void run() {
- DOT_LOGGER.info( "." );
- _count++;
- if ( _count % 50 == 0 ) {
- EOL_LOGGER.info( " " + _count );
- }
- }
- }
}
Modified: ctakes/trunk/ctakes-examples-res/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorld.piper
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-examples-res/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorld.piper?rev=1786449&r1=1786448&r2=1786449&view=diff
==============================================================================
--- ctakes/trunk/ctakes-examples-res/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorld.piper (original)
+++ ctakes/trunk/ctakes-examples-res/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorld.piper Fri Mar 10 21:02:09 2017
@@ -1,7 +1,7 @@
// This file contains commands and parameters to run the ctakes-examples "Hello World" pipeline
// Load a simple token processing pipeline from another pipeline file
-load org/apache/ctakes/core/pipeline/DefaultTokenizerPipeline.piper
+load DefaultTokenizerPipeline.piper
// Add non-core annotators
add ContextDependentTokenizerAnnotator
Modified: ctakes/trunk/ctakes-examples-res/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldProps.piper
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-examples-res/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldProps.piper?rev=1786449&r1=1786448&r2=1786449&view=diff
==============================================================================
--- ctakes/trunk/ctakes-examples-res/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldProps.piper (original)
+++ ctakes/trunk/ctakes-examples-res/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldProps.piper Fri Mar 10 21:02:09 2017
@@ -5,7 +5,7 @@
load org/apache/ctakes/examples/pipeline/HelloWorld.piper
// Add Named Entity Context Entity Attribute annotators
-load org/apache/ctakes/necontexts/pipeline/NeContextsSubPipe.piper
+load NeContextsSubPipe.piper
// Collect discovered Entity information for post-run access
collectEntities
Modified: ctakes/trunk/ctakes-examples-res/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldTkProps.piper
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-examples-res/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldTkProps.piper?rev=1786449&r1=1786448&r2=1786449&view=diff
==============================================================================
--- ctakes/trunk/ctakes-examples-res/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldTkProps.piper (original)
+++ ctakes/trunk/ctakes-examples-res/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldTkProps.piper Fri Mar 10 21:02:09 2017
@@ -5,7 +5,7 @@
load org/apache/ctakes/examples/pipeline/HelloWorld.piper
// Add Cleartk Entity Attribute annotators
-load org/apache/ctakes/assertion/pipeline/AttributeCleartkSubPipe.piper
+load AttributeCleartkSubPipe.piper
// Collect discovered Entity information for post-run access
collectEntities