ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tm...@apache.org
Subject svn commit: r1444073 - in /incubator/ctakes/trunk/ctakes-constituency-parser/src/main/java/org/apache/ctakes/constituency/parser: ae/ConstituencyParser.java util/CommandLineParserUtil.java util/TreeUtils.java
Date Fri, 08 Feb 2013 15:33:52 GMT
Author: tmill
Date: Fri Feb  8 15:33:52 2013
New Revision: 1444073

URL: http://svn.apache.org/r1444073
Log:
ctakes-153 - correction in new parser code -- returned wrong treebank node.

Modified:
    incubator/ctakes/trunk/ctakes-constituency-parser/src/main/java/org/apache/ctakes/constituency/parser/ae/ConstituencyParser.java
    incubator/ctakes/trunk/ctakes-constituency-parser/src/main/java/org/apache/ctakes/constituency/parser/util/CommandLineParserUtil.java
    incubator/ctakes/trunk/ctakes-constituency-parser/src/main/java/org/apache/ctakes/constituency/parser/util/TreeUtils.java

Modified: incubator/ctakes/trunk/ctakes-constituency-parser/src/main/java/org/apache/ctakes/constituency/parser/ae/ConstituencyParser.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-constituency-parser/src/main/java/org/apache/ctakes/constituency/parser/ae/ConstituencyParser.java?rev=1444073&r1=1444072&r2=1444073&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-constituency-parser/src/main/java/org/apache/ctakes/constituency/parser/ae/ConstituencyParser.java
(original)
+++ incubator/ctakes/trunk/ctakes-constituency-parser/src/main/java/org/apache/ctakes/constituency/parser/ae/ConstituencyParser.java
Fri Feb  8 15:33:52 2013
@@ -33,17 +33,23 @@ import org.apache.uima.resource.Resource
 
 public class ConstituencyParser extends JCasAnnotator_ImplBase {
 	public static final String PARAM_MODELFILE = "modelFilename";
+	public static final String defaultModel = "org/apache/ctakes/constituency/parser/models/sharpacq-1.5.bin";
+	
 	ParserWrapper parser = null;
 	Logger logger = Logger.getLogger(this.getClass());
-	
+
 	@Override
 	public void initialize(UimaContext aContext)
 			throws ResourceInitializationException {
 		super.initialize(aContext);
 		String modelFileOrDirname = (String) aContext.getConfigParameterValue(PARAM_MODELFILE);
+		if(modelFileOrDirname == null){
+			modelFileOrDirname = defaultModel;
+		}
 		try {
-					logger.info("Initializing parser...");
-					parser = new MaxentParserWrapper(FileLocator.locateFile(modelFileOrDirname).getAbsolutePath());
+			logger.info("Initializing parser...");
+			
+			parser = new MaxentParserWrapper(FileLocator.locateFile(modelFileOrDirname).getAbsolutePath());
 		} catch (FileNotFoundException e) {
 			e.printStackTrace();
 			logger.error("Error reading parser model file/directory: " + e.getMessage());
@@ -53,6 +59,6 @@ public class ConstituencyParser extends 
 
 	@Override
 	public void process(JCas jcas) throws AnalysisEngineProcessException {
-			parser.createAnnotations(jcas);
+		parser.createAnnotations(jcas);
 	}
 }

Modified: incubator/ctakes/trunk/ctakes-constituency-parser/src/main/java/org/apache/ctakes/constituency/parser/util/CommandLineParserUtil.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-constituency-parser/src/main/java/org/apache/ctakes/constituency/parser/util/CommandLineParserUtil.java?rev=1444073&r1=1444072&r2=1444073&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-constituency-parser/src/main/java/org/apache/ctakes/constituency/parser/util/CommandLineParserUtil.java
(original)
+++ incubator/ctakes/trunk/ctakes-constituency-parser/src/main/java/org/apache/ctakes/constituency/parser/util/CommandLineParserUtil.java
Fri Feb  8 15:33:52 2013
@@ -21,13 +21,20 @@ package org.apache.ctakes.constituency.p
 import java.io.IOException;
 import java.util.Scanner;
 
+import org.apache.ctakes.constituency.parser.ae.ConstituencyParser;
+import org.apache.ctakes.core.ae.SentenceDetector;
+import org.apache.ctakes.core.ae.SimpleSegmentAnnotator;
+import org.apache.ctakes.core.ae.TokenizerAnnotatorPTB;
+import org.apache.ctakes.core.resource.SuffixMaxentModelResourceImpl;
 import org.apache.ctakes.typesystem.type.syntax.TopTreebankNode;
 import org.apache.uima.UIMAException;
 import org.apache.uima.analysis_engine.AnalysisEngine;
 import org.apache.uima.cas.FSIterator;
 import org.apache.uima.jcas.JCas;
 import org.apache.uima.resource.metadata.TypeSystemDescription;
+import org.uimafit.factory.AggregateBuilder;
 import org.uimafit.factory.AnalysisEngineFactory;
+import org.uimafit.factory.ExternalResourceFactory;
 import org.uimafit.factory.JCasFactory;
 import org.uimafit.factory.TypeSystemDescriptionFactory;
 import org.uimafit.pipeline.SimplePipeline;
@@ -42,7 +49,18 @@ public class CommandLineParserUtil {
 	public static void main(String[] args) throws UIMAException, IOException {
 		TypeSystemDescription types = TypeSystemDescriptionFactory.createTypeSystemDescription();
 		
-		AnalysisEngine ae = AnalysisEngineFactory.createAnalysisEngineFromPath("desc/analysis_engine/AggregateParsingProcessor.xml");
+//		AnalysisEngine ae = AnalysisEngineFactory.createAnalysisEngineFromPath("desc/analysis_engine/AggregateParsingProcessor.xml");
+		AggregateBuilder builder = new AggregateBuilder();
+		builder.add(AnalysisEngineFactory.createPrimitiveDescription(SimpleSegmentAnnotator.class));
+		builder.add(AnalysisEngineFactory.createPrimitiveDescription(SentenceDetector.class,
+				"MaxentModel",
+		        ExternalResourceFactory.createExternalResourceDescription(
+		                SuffixMaxentModelResourceImpl.class,
+		                SentenceDetector.class.getResource("../sentdetect/sdmed.mod"))));
+		builder.add(AnalysisEngineFactory.createPrimitiveDescription(TokenizerAnnotatorPTB.class));
+		builder.add(AnalysisEngineFactory.createPrimitiveDescription(ConstituencyParser.class));
+		
+		AnalysisEngine ae = builder.createAggregate();
 		
 		Scanner scanner = new Scanner(System.in);
 		while(scanner.hasNextLine()){

Modified: incubator/ctakes/trunk/ctakes-constituency-parser/src/main/java/org/apache/ctakes/constituency/parser/util/TreeUtils.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-constituency-parser/src/main/java/org/apache/ctakes/constituency/parser/util/TreeUtils.java?rev=1444073&r1=1444072&r2=1444073&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-constituency-parser/src/main/java/org/apache/ctakes/constituency/parser/util/TreeUtils.java
(original)
+++ incubator/ctakes/trunk/ctakes-constituency-parser/src/main/java/org/apache/ctakes/constituency/parser/util/TreeUtils.java
Fri Feb  8 15:33:52 2013
@@ -171,10 +171,10 @@ public class TreeUtils {
 	}
 
 	public static TopTreebankNode buildAlignedTree(JCas jcas, Parse parse, Sentence sent) throws
AnalysisEngineProcessException {
-		TopTreebankNode root = new TopTreebankNode(jcas, sent.getBegin(), sent.getEnd());
 		FSArray termArray = TreeUtils.getTerminals(jcas, sent);
 		
 		StringBuffer parseBuff = new StringBuffer();
+		parse.show(parseBuff);
 		
 		TopTreebankNode top = new TopTreebankNode(jcas, sent.getBegin(), sent.getEnd());
 		top.setTreebankParse(parseBuff.toString());
@@ -182,7 +182,7 @@ public class TreeUtils {
 		top.setParent(null);
 		if(parse != null) recursivelyCreateStructure(jcas, top, parse, top);
 	
-		return root;
+		return top;
 	}
 	
 	public static FSArray getTerminals(JCas jcas, Sentence sent){



Mime
View raw message