You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ctakes.apache.org by tm...@apache.org on 2016/12/06 16:31:50 UTC

svn commit: r1772913 - in /ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/factory: ./ CoreferenceAnnotatorFactory.java

Author: tmill
Date: Tue Dec  6 16:31:50 2016
New Revision: 1772913

URL: http://svn.apache.org/viewvc?rev=1772913&view=rev
Log:
Factory methods for grabbing partial or complete coref pipelines.

Added:
    ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/factory/
    ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/factory/CoreferenceAnnotatorFactory.java

Added: ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/factory/CoreferenceAnnotatorFactory.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/factory/CoreferenceAnnotatorFactory.java?rev=1772913&view=auto
==============================================================================
--- ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/factory/CoreferenceAnnotatorFactory.java (added)
+++ ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/factory/CoreferenceAnnotatorFactory.java Tue Dec  6 16:31:50 2016
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ctakes.coreference.factory;
+
+import org.apache.ctakes.coreference.ae.DeterministicMarkableAnnotator;
+import org.apache.ctakes.coreference.ae.MarkableHeadTreeCreator;
+import org.apache.ctakes.coreference.ae.MarkableSalienceAnnotator;
+import org.apache.ctakes.coreference.ae.MentionClusterCoreferenceAnnotator;
+import org.apache.uima.analysis_engine.AnalysisEngineDescription;
+import org.apache.uima.fit.factory.AggregateBuilder;
+import org.apache.uima.fit.factory.AnalysisEngineFactory;
+import org.apache.uima.resource.ResourceInitializationException;
+
+public class CoreferenceAnnotatorFactory {
+
+  // This method is for the use case where an outside caller has their own types they want resolved -- say for the
+  // breast cancer use case you may just want tumor, cancer, anatomical sites resolved.
+  public static AnalysisEngineDescription getMentionClusterResolverDescription() throws ResourceInitializationException{
+    AggregateBuilder builder = new AggregateBuilder();
+    
+    // Creates a data structure that maps from markables to dependency head nodes that is used in multiple feature extractors
+    builder.add(AnalysisEngineFactory.createEngineDescription(MarkableHeadTreeCreator.class));
+    
+    // annotate every markable for "salience": how important is it to the discourse in context
+    builder.add(MarkableSalienceAnnotator.createAnnotatorDescription("/org/apache/ctakes/temporal/ae/salience/model.jar"));
+    
+    // use the mention-cluster model with default trained model:
+    builder.add(MentionClusterCoreferenceAnnotator.createAnnotatorDescription("/org/apache/ctakes/coreference/models/mention-cluster/model.jar"));
+    
+    return builder.createAggregateDescription();
+  }
+  
+  // This method is a one-stop shop for default coreference resolution -- uses the default
+  public static AnalysisEngineDescription getMentionClusterCoreferenceDescription() throws ResourceInitializationException {
+    AggregateBuilder builder = new AggregateBuilder();
+
+    // Add markables using syntax: (nouns and pronouns)
+    builder.add(AnalysisEngineFactory.createEngineDescription(DeterministicMarkableAnnotator.class));
+
+    builder.add(getMentionClusterResolverDescription());
+    
+    return builder.createAggregateDescription();
+  }
+  
+  // This method will point at the method we think is most likely to be useful for callers of mixed understanding
+  // who may not grok the method names for the systems named for their implementation.
+  public static AnalysisEngineDescription getDefaultCoreferencePipeline() throws ResourceInitializationException {
+    return getMentionClusterCoreferenceDescription();
+  }
+}