Revision: 15116
          http://gate.svn.sourceforge.net/gate/?rev=15116&view=rev
Author:   valyt
Date:     2012-01-18 16:30:37 +0000 (Wed, 18 Jan 2012)
Log Message:
-----------
Some sources.

Added Paths:
-----------
    futures/orthoref/src/
    futures/orthoref/src/gate/
    futures/orthoref/src/gate/creole/
    futures/orthoref/src/gate/creole/coref/
    futures/orthoref/src/gate/creole/coref/CorefBase.java

Property Changed:
----------------
    futures/orthoref/


Property changes on: futures/orthoref
___________________________________________________________________
Added: svn:ignore
   + classes


Added: futures/orthoref/src/gate/creole/coref/CorefBase.java
===================================================================
--- futures/orthoref/src/gate/creole/coref/CorefBase.java                       
        (rev 0)
+++ futures/orthoref/src/gate/creole/coref/CorefBase.java       2012-01-18 
16:30:37 UTC (rev 15116)
@@ -0,0 +1,89 @@
+/*
+ *  OrthoRef.java
+ *
+ *  Copyright (c) 1995-2010, The University of Sheffield. See the file
+ *  COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
+ *
+ *  This file is part of GATE (see http://gate.ac.uk/), and is free
+ *  software, licenced under the GNU Library General Public License,
+ *  Version 2, June 1991 (in the distribution as file licence.html,
+ *  and also available at http://gate.ac.uk/gate/licence.html).
+ *
+ *  $Id$
+ */
+package gate.creole.coref;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import gate.Annotation;
+import gate.Utils;
+import gate.creole.AbstractLanguageAnalyser;
+import gate.creole.ExecutionException;
+import gate.creole.metadata.CreoleResource;
+
+@CreoleResource (comment = "An orthographic coreferencer")
+/**
+ * Base class for coreferencers. This class has no internal state, so it safe 
to
+ * use in a multi-threaded environment. The same may not be true about 
+ * subclasses: check their own documentation first! 
+ */
+public abstract class CorefBase extends AbstractLanguageAnalyser {
+  
+  /**
+   * Which annotation types are seen as anaphors
+   */
+  private Set<String> anaphorAnnotationTypes;
+  
+  private String annotationSetName;
+  
+  public abstract Set<String> anaphorTags(Annotation anaphor);
+  
+  public abstract boolean matches(Annotation anaphor, Annotation antecedent);
+
+  @Override
+  public void execute() throws ExecutionException {
+    fireProgressChanged(1);
+    //collect all candidates
+    List<Annotation> anaphors = new ArrayList<Annotation>(
+        ((annotationSetName == null || annotationSetName.trim().length() == 0) 
?
+        document.getAnnotations() : 
+        
document.getAnnotations(annotationSetName)).get(anaphorAnnotationTypes));
+    Collections.sort(anaphors, Utils.OFFSET_COMPARATOR);
+    
+    Map<String, Annotation> tag2candidate = new HashMap<String, Annotation>();
+    Map<Annotation, String> anaphor2chain = new HashMap<Annotation, String>();
+    
+    // for each candidate, check the hash map 
+    for(Annotation anaphor : anaphors) {
+      Set<String> newTags = anaphorTags(anaphor);
+      for(String tag : newTags) {
+        Annotation candidate = tag2candidate.get(tag);
+        if(candidate != null && matches(anaphor, candidate)) {
+          // we have a match
+          String chainLabel  = anaphor2chain.get(candidate);
+          if(chainLabel == null) {
+            // first match for this chain
+            chainLabel = Utils.contentFor(document, candidate).toString();
+            anaphor2chain.put(candidate, chainLabel);
+          }
+          anaphor2chain.put(anaphor, chainLabel);
+        }
+      }
+    }
+    
+    
+    
+    
+    fireProgressChanged(100);
+    fireProcessFinished();
+  }
+
+  
+  
+  
+}


Property changes on: futures/orthoref/src/gate/creole/coref/CorefBase.java
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to