You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ctakes.apache.org by ja...@apache.org on 2012/10/31 06:26:55 UTC

svn commit: r1403989 [22/28] - in /incubator/ctakes/branches/SHARPn-cTAKES: Constituency Parser/src/org/chboston/cnlp/ctakes/parser/ Constituency Parser/src/org/chboston/cnlp/ctakes/parser/uima/ae/ Constituency Parser/src/org/chboston/cnlp/ctakes/parse...

Modified: incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/lookup/vo/LookupAnnotationToTokAdapter.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/lookup/vo/LookupAnnotationToTokAdapter.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/lookup/vo/LookupAnnotationToTokAdapter.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/lookup/vo/LookupAnnotationToTokAdapter.java Wed Oct 31 05:26:43 2012
@@ -1,18 +1,11 @@
 /*
- * Copyright: (c) 2009   Mayo Foundation for Medical Education and 
- * Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the
- * triple-shield Mayo logo are trademarks and service marks of MFMER.
- *
- * Except as contained in the copyright notice above, or as used to identify 
- * MFMER as the author of this software, the trade names, trademarks, service
- * marks, or product names of the copyright holder shall not be used in
- * advertising, promotion or otherwise in connection with this software without
- * prior written authorization of the copyright holder.
- * 
- * Licensed 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
- * 
+ * 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
@@ -21,61 +14,61 @@
  * See the License for the specific language governing permissions and 
  * limitations under the License. 
  */
-/*
- * Created on Aug 24, 2005
- *
- */
-package edu.mayo.bmi.lookup.vo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import edu.mayo.bmi.nlp.tokenizer.Token;
-
-/**
- * @author Mayo Clinic
- *
- */
-public class LookupAnnotationToTokAdapter
-        implements LookupToken, LookupAnnotation
-{
-        private Map iv_attrMap = new HashMap();
-
-        private Token iv_tok;
-
-        public LookupAnnotationToTokAdapter(Token tok)
-        {
-            iv_tok = tok;
-        }
-
-        public void addStringAttribute(String attrKey, String attrVal)
-        {
-            iv_attrMap.put(attrKey, attrVal);
-        }
-
-        public int getEndOffset()
-        {
-            return iv_tok.getEndOffset();
-        }
-
-        public int getLength()
-        {
-            return getStartOffset() - getEndOffset();
-        }
-
-        public int getStartOffset()
-        {
-            return iv_tok.getStartOffset();
-        }
-
-        public String getStringAttribute(String attrKey)
-        {
-            return (String) iv_attrMap.get(attrKey);
-        }
-
-        public String getText()
-        {
-            return iv_tok.getText();
-        }
-
-}
+/*
+ * Created on Aug 24, 2005
+ *
+ */
+package edu.mayo.bmi.lookup.vo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import edu.mayo.bmi.nlp.tokenizer.Token;
+
+/**
+ * @author Mayo Clinic
+ *
+ */
+public class LookupAnnotationToTokAdapter
+        implements LookupToken, LookupAnnotation
+{
+        private Map iv_attrMap = new HashMap();
+
+        private Token iv_tok;
+
+        public LookupAnnotationToTokAdapter(Token tok)
+        {
+            iv_tok = tok;
+        }
+
+        public void addStringAttribute(String attrKey, String attrVal)
+        {
+            iv_attrMap.put(attrKey, attrVal);
+        }
+
+        public int getEndOffset()
+        {
+            return iv_tok.getEndOffset();
+        }
+
+        public int getLength()
+        {
+            return getStartOffset() - getEndOffset();
+        }
+
+        public int getStartOffset()
+        {
+            return iv_tok.getStartOffset();
+        }
+
+        public String getStringAttribute(String attrKey)
+        {
+            return (String) iv_attrMap.get(attrKey);
+        }
+
+        public String getText()
+        {
+            return iv_tok.getText();
+        }
+
+}

Modified: incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/lookup/vo/LookupHit.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/lookup/vo/LookupHit.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/lookup/vo/LookupHit.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/lookup/vo/LookupHit.java Wed Oct 31 05:26:43 2012
@@ -1,18 +1,11 @@
 /*
- * Copyright: (c) 2009   Mayo Foundation for Medical Education and 
- * Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the
- * triple-shield Mayo logo are trademarks and service marks of MFMER.
- *
- * Except as contained in the copyright notice above, or as used to identify 
- * MFMER as the author of this software, the trade names, trademarks, service
- * marks, or product names of the copyright holder shall not be used in
- * advertising, promotion or otherwise in connection with this software without
- * prior written authorization of the copyright holder.
- * 
- * Licensed 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
- * 
+ * 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
@@ -21,95 +14,95 @@
  * See the License for the specific language governing permissions and 
  * limitations under the License. 
  */
-package edu.mayo.bmi.lookup.vo;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import edu.mayo.bmi.dictionary.MetaDataHit;
-
-/**
- * Represents a single hit found by a lookup algorithm. Meta data returned by
- * the Dictionary is also encapsulated here as well.
- * 
- * @author Mayo Clinic
- */
-public class LookupHit
-{
-    private int iv_startOffset;
-    private int iv_endOffset;
-    private MetaDataHit iv_mdh;
-
-    public LookupHit(MetaDataHit mdh, int startOffset, int endOffset)
-    {
-        iv_mdh = mdh;
-        iv_startOffset = startOffset;
-        iv_endOffset = endOffset;
-    }
-
-    public int getEndOffset()
-    {
-        return iv_endOffset;
-    }
-
-    public MetaDataHit getDictMetaDataHit()
-    {
-        return iv_mdh;
-    }
-
-    public int getStartOffset()
-    {
-        return iv_startOffset;
-    }
-
-    /**
-     * Override default equals method. Two LookupHit objects are equal if their
-     * offsets match and their MetaDataHit objects are equal.
-     */
-    public boolean equals(Object obj)
-    {
-        if (obj instanceof LookupHit)
-        {
-            LookupHit lh = (LookupHit) obj;
-            if ((iv_startOffset == lh.getStartOffset())
-                    && (iv_endOffset == lh.getEndOffset()))
-            {
-                return iv_mdh.equals(lh.getDictMetaDataHit());
-            }
-        }
-        return false;
-    }
-    
-    /**
-     * Generates a unique key based on this objects values.
-     * @return
-     */
-    public String getUniqueKey()
-    {
-        StringBuffer key = new StringBuffer();
-        
-        key.append("s=");
-        key.append(iv_startOffset);
-        key.append("/");
-        key.append("e=");
-        key.append(iv_endOffset);
-        key.append("/");
-
-        List mfNameList = new ArrayList(iv_mdh.getMetaFieldNames());
-        Collections.sort(mfNameList);
-        Iterator mfNameItr = mfNameList.iterator();
-        while (mfNameItr.hasNext())
-        {
-            String mfName = (String)mfNameItr.next();
-            String mfValue = iv_mdh.getMetaFieldValue(mfName);
-            key.append(mfName);
-            key.append("=");
-            key.append(mfValue);
-            key.append(",");
-        }
-        
-        return key.toString();        
-    }
-}
\ No newline at end of file
+package edu.mayo.bmi.lookup.vo;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import edu.mayo.bmi.dictionary.MetaDataHit;
+
+/**
+ * Represents a single hit found by a lookup algorithm. Meta data returned by
+ * the Dictionary is also encapsulated here as well.
+ * 
+ * @author Mayo Clinic
+ */
+public class LookupHit
+{
+    private int iv_startOffset;
+    private int iv_endOffset;
+    private MetaDataHit iv_mdh;
+
+    public LookupHit(MetaDataHit mdh, int startOffset, int endOffset)
+    {
+        iv_mdh = mdh;
+        iv_startOffset = startOffset;
+        iv_endOffset = endOffset;
+    }
+
+    public int getEndOffset()
+    {
+        return iv_endOffset;
+    }
+
+    public MetaDataHit getDictMetaDataHit()
+    {
+        return iv_mdh;
+    }
+
+    public int getStartOffset()
+    {
+        return iv_startOffset;
+    }
+
+    /**
+     * Override default equals method. Two LookupHit objects are equal if their
+     * offsets match and their MetaDataHit objects are equal.
+     */
+    public boolean equals(Object obj)
+    {
+        if (obj instanceof LookupHit)
+        {
+            LookupHit lh = (LookupHit) obj;
+            if ((iv_startOffset == lh.getStartOffset())
+                    && (iv_endOffset == lh.getEndOffset()))
+            {
+                return iv_mdh.equals(lh.getDictMetaDataHit());
+            }
+        }
+        return false;
+    }
+    
+    /**
+     * Generates a unique key based on this objects values.
+     * @return
+     */
+    public String getUniqueKey()
+    {
+        StringBuffer key = new StringBuffer();
+        
+        key.append("s=");
+        key.append(iv_startOffset);
+        key.append("/");
+        key.append("e=");
+        key.append(iv_endOffset);
+        key.append("/");
+
+        List mfNameList = new ArrayList(iv_mdh.getMetaFieldNames());
+        Collections.sort(mfNameList);
+        Iterator mfNameItr = mfNameList.iterator();
+        while (mfNameItr.hasNext())
+        {
+            String mfName = (String)mfNameItr.next();
+            String mfValue = iv_mdh.getMetaFieldValue(mfName);
+            key.append(mfName);
+            key.append("=");
+            key.append(mfValue);
+            key.append(",");
+        }
+        
+        return key.toString();        
+    }
+}

Modified: incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/lookup/vo/LookupToken.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/lookup/vo/LookupToken.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/lookup/vo/LookupToken.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/lookup/vo/LookupToken.java Wed Oct 31 05:26:43 2012
@@ -1,18 +1,11 @@
 /*
- * Copyright: (c) 2009   Mayo Foundation for Medical Education and 
- * Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the
- * triple-shield Mayo logo are trademarks and service marks of MFMER.
- *
- * Except as contained in the copyright notice above, or as used to identify 
- * MFMER as the author of this software, the trade names, trademarks, service
- * marks, or product names of the copyright holder shall not be used in
- * advertising, promotion or otherwise in connection with this software without
- * prior written authorization of the copyright holder.
- * 
- * Licensed 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
- * 
+ * 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
@@ -21,16 +14,16 @@
  * See the License for the specific language governing permissions and 
  * limitations under the License. 
  */
-package edu.mayo.bmi.lookup.vo;
-
-
-/**
- * This object represents the SMALLEST span of text that could potentially
- * be a lookup hit.  In some cases this may be a single word or it can be a 
- * group of words such as a noun phrase.
- * 
- * @author Mayo Clinic
- */
-public interface LookupToken extends LookupAnnotation
-{
-}
+package edu.mayo.bmi.lookup.vo;
+
+
+/**
+ * This object represents the SMALLEST span of text that could potentially
+ * be a lookup hit.  In some cases this may be a single word or it can be a 
+ * group of words such as a noun phrase.
+ * 
+ * @author Mayo Clinic
+ */
+public interface LookupToken extends LookupAnnotation
+{
+}

Modified: incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/lookup/vo/LookupTokenComparator.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/lookup/vo/LookupTokenComparator.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/lookup/vo/LookupTokenComparator.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/lookup/vo/LookupTokenComparator.java Wed Oct 31 05:26:43 2012
@@ -1,18 +1,11 @@
 /*
- * Copyright: (c) 2009   Mayo Foundation for Medical Education and 
- * Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the
- * triple-shield Mayo logo are trademarks and service marks of MFMER.
- *
- * Except as contained in the copyright notice above, or as used to identify 
- * MFMER as the author of this software, the trade names, trademarks, service
- * marks, or product names of the copyright holder shall not be used in
- * advertising, promotion or otherwise in connection with this software without
- * prior written authorization of the copyright holder.
- * 
- * Licensed 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
- * 
+ * 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
@@ -21,48 +14,48 @@
  * See the License for the specific language governing permissions and 
  * limitations under the License. 
  */
-package edu.mayo.bmi.lookup.vo;
-
-import java.util.Comparator;
-
-
-/**
- * Comparator that sorts LookupToken objects by their start and end offsets.
- * 
- * @author Mayo Clinic
- */
-public class LookupTokenComparator implements Comparator
-{
-
-    public int compare(Object o1, Object o2)
-    {
-        LookupToken tok1 = (LookupToken) o1;
-        LookupToken tok2 = (LookupToken) o2;
-
-        if (tok1.getStartOffset() < tok2.getStartOffset())
-        {
-            return -1;
-        }
-        else if (tok1.getStartOffset() > tok2.getStartOffset())
-        {
-            return 1;
-        }
-        else
-        {
-            // equal start offsets, now look at end offsets
-            if (tok1.getEndOffset() < tok2.getEndOffset())
-            {
-                return -1;
-            }
-            else if (tok1.getEndOffset() > tok2.getEndOffset())
-            {
-                return 1;
-            }
-            else
-            {
-                // all offsets are equal
-                return 0;
-            }
-        }
-    }
-}
\ No newline at end of file
+package edu.mayo.bmi.lookup.vo;
+
+import java.util.Comparator;
+
+
+/**
+ * Comparator that sorts LookupToken objects by their start and end offsets.
+ * 
+ * @author Mayo Clinic
+ */
+public class LookupTokenComparator implements Comparator
+{
+
+    public int compare(Object o1, Object o2)
+    {
+        LookupToken tok1 = (LookupToken) o1;
+        LookupToken tok2 = (LookupToken) o2;
+
+        if (tok1.getStartOffset() < tok2.getStartOffset())
+        {
+            return -1;
+        }
+        else if (tok1.getStartOffset() > tok2.getStartOffset())
+        {
+            return 1;
+        }
+        else
+        {
+            // equal start offsets, now look at end offsets
+            if (tok1.getEndOffset() < tok2.getEndOffset())
+            {
+                return -1;
+            }
+            else if (tok1.getEndOffset() > tok2.getEndOffset())
+            {
+                return 1;
+            }
+            else
+            {
+                // all offsets are equal
+                return 0;
+            }
+        }
+    }
+}

Modified: incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/BaseLookupConsumerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/uima/lookup/ae/BaseLookupConsumerImpl.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/BaseLookupConsumerImpl.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/BaseLookupConsumerImpl.java Wed Oct 31 05:26:43 2012
@@ -1,18 +1,11 @@
 /*
- * Copyright: (c) 2009   Mayo Foundation for Medical Education and 
- * Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the
- * triple-shield Mayo logo are trademarks and service marks of MFMER.
- *
- * Except as contained in the copyright notice above, or as used to identify 
- * MFMER as the author of this software, the trade names, trademarks, service
- * marks, or product names of the copyright holder shall not be used in
- * advertising, promotion or otherwise in connection with this software without
- * prior written authorization of the copyright holder.
- * 
- * Licensed 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
- * 
+ * 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
@@ -21,8 +14,8 @@
  * See the License for the specific language governing permissions and 
  * limitations under the License. 
  */
-package edu.mayo.bmi.uima.lookup.ae;
-
+package edu.mayo.bmi.uima.lookup.ae;
+
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -33,58 +26,58 @@ import org.apache.uima.analysis_engine.A
 import org.apache.uima.jcas.JCas;
 
 import edu.mayo.bmi.lookup.vo.LookupHit;
-
-/**
- * Provides some base functionality for subclasses.
- * 
- * @author Mayo Clinic
- * 
- */
-public abstract class BaseLookupConsumerImpl implements LookupConsumer
-{
-	/**
-	 * Organizes the LookupHit objects by begin and end offsets.
-	 * 
-	 * @param lhItr
-	 * @return Iterator over Set objects. Each Set object is a collection of
-	 *         LookupHit objects with the same begin,end offsets.
-	 */
-	protected Iterator organizeByOffset(Iterator lhItr)
-	{
-		// key = begin,end key (java.lang.String)
-		// val = Set of LookupHit objects corresponding to begin,end
-		Map m = new HashMap();
-
-		while (lhItr.hasNext())
-		{
-			LookupHit lh = (LookupHit) lhItr.next();
-			String keyStr = getKeyString(lh.getStartOffset(), lh.getEndOffset());
-
-			Set s = null;
-			if (m.containsKey(keyStr))
-			{
-				s = (Set) m.get(keyStr);
-			}
-			else
-			{
-				s = new HashSet();
-			}
-			s.add(lh);
-			m.put(keyStr, s);
-		}
-
-		return m.values().iterator();
-	}
-
-	private String getKeyString(int begin, int end)
-	{
-		StringBuffer sb = new StringBuffer();
-		sb.append(begin);
-		sb.append(',');
-		sb.append(end);
-		return sb.toString();
-	}
-
-	public abstract void consumeHits(JCas jcas, Iterator lookupHitItr)
-			throws AnalysisEngineProcessException;
-}
+
+/**
+ * Provides some base functionality for subclasses.
+ * 
+ * @author Mayo Clinic
+ * 
+ */
+public abstract class BaseLookupConsumerImpl implements LookupConsumer
+{
+	/**
+	 * Organizes the LookupHit objects by begin and end offsets.
+	 * 
+	 * @param lhItr
+	 * @return Iterator over Set objects. Each Set object is a collection of
+	 *         LookupHit objects with the same begin,end offsets.
+	 */
+	protected Iterator organizeByOffset(Iterator lhItr)
+	{
+		// key = begin,end key (java.lang.String)
+		// val = Set of LookupHit objects corresponding to begin,end
+		Map m = new HashMap();
+
+		while (lhItr.hasNext())
+		{
+			LookupHit lh = (LookupHit) lhItr.next();
+			String keyStr = getKeyString(lh.getStartOffset(), lh.getEndOffset());
+
+			Set s = null;
+			if (m.containsKey(keyStr))
+			{
+				s = (Set) m.get(keyStr);
+			}
+			else
+			{
+				s = new HashSet();
+			}
+			s.add(lh);
+			m.put(keyStr, s);
+		}
+
+		return m.values().iterator();
+	}
+
+	private String getKeyString(int begin, int end)
+	{
+		StringBuffer sb = new StringBuffer();
+		sb.append(begin);
+		sb.append(',');
+		sb.append(end);
+		return sb.toString();
+	}
+
+	public abstract void consumeHits(JCas jcas, Iterator lookupHitItr)
+			throws AnalysisEngineProcessException;
+}

Modified: incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/DebugConsumerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/uima/lookup/ae/DebugConsumerImpl.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/DebugConsumerImpl.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/DebugConsumerImpl.java Wed Oct 31 05:26:43 2012
@@ -1,18 +1,11 @@
 /*
- * Copyright: (c) 2009   Mayo Foundation for Medical Education and 
- * Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the
- * triple-shield Mayo logo are trademarks and service marks of MFMER.
- *
- * Except as contained in the copyright notice above, or as used to identify 
- * MFMER as the author of this software, the trade names, trademarks, service
- * marks, or product names of the copyright holder shall not be used in
- * advertising, promotion or otherwise in connection with this software without
- * prior written authorization of the copyright holder.
- * 
- * Licensed 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
- * 
+ * 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
@@ -21,55 +14,55 @@
  * See the License for the specific language governing permissions and 
  * limitations under the License. 
  */
-package edu.mayo.bmi.uima.lookup.ae;
-
-import java.util.Iterator;
-import java.util.Properties;
-
-import org.apache.log4j.Logger;
-
+package edu.mayo.bmi.uima.lookup.ae;
+
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.apache.log4j.Logger;
+
 import org.apache.uima.UimaContext;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
-import org.apache.uima.jcas.JCas;
-
-import edu.mayo.bmi.dictionary.MetaDataHit;
-import edu.mayo.bmi.lookup.vo.LookupHit;
-
-/**
- * LookupConsumer implementation that outputs debug info to the log about each LookupHit.
- * 
- * @author Mayo Clinic 
- * 
- */
-public class DebugConsumerImpl implements LookupConsumer
-{
-    // LOG4J logger based on class name
-    private Logger iv_logger = Logger.getLogger(getClass().getName());
-
-    public DebugConsumerImpl(UimaContext aCtx, Properties props)
-    {        
-    }
-    
-    public void consumeHits(JCas jcas, Iterator lookupHitItr)
-            throws AnalysisEngineProcessException
-    {
-        while (lookupHitItr.hasNext())
-        {
-            LookupHit lh = (LookupHit) lookupHitItr.next();
-            int begin = lh.getStartOffset();
-            int end = lh.getEndOffset();
-            String coveredText = jcas.getDocumentText().substring(begin, end);            
-            iv_logger.info("LookupHit offsets=("+begin+","+end+")\tcoveredText="+coveredText);
-            
-            MetaDataHit mdh = lh.getDictMetaDataHit();
-            Iterator nameItr = mdh.getMetaFieldNames().iterator();
-            while (nameItr.hasNext())
-            {
-                String mfName = (String)nameItr.next();
-                String mfValue = mdh.getMetaFieldValue(mfName);
-                iv_logger.info("\tmetafield="+mfName+"\tvalue="+mfValue);
-            }
-        }
-    }
-
-}
+import org.apache.uima.jcas.JCas;
+
+import edu.mayo.bmi.dictionary.MetaDataHit;
+import edu.mayo.bmi.lookup.vo.LookupHit;
+
+/**
+ * LookupConsumer implementation that outputs debug info to the log about each LookupHit.
+ * 
+ * @author Mayo Clinic 
+ * 
+ */
+public class DebugConsumerImpl implements LookupConsumer
+{
+    // LOG4J logger based on class name
+    private Logger iv_logger = Logger.getLogger(getClass().getName());
+
+    public DebugConsumerImpl(UimaContext aCtx, Properties props)
+    {        
+    }
+    
+    public void consumeHits(JCas jcas, Iterator lookupHitItr)
+            throws AnalysisEngineProcessException
+    {
+        while (lookupHitItr.hasNext())
+        {
+            LookupHit lh = (LookupHit) lookupHitItr.next();
+            int begin = lh.getStartOffset();
+            int end = lh.getEndOffset();
+            String coveredText = jcas.getDocumentText().substring(begin, end);            
+            iv_logger.info("LookupHit offsets=("+begin+","+end+")\tcoveredText="+coveredText);
+            
+            MetaDataHit mdh = lh.getDictMetaDataHit();
+            Iterator nameItr = mdh.getMetaFieldNames().iterator();
+            while (nameItr.hasNext())
+            {
+                String mfName = (String)nameItr.next();
+                String mfValue = mdh.getMetaFieldValue(mfName);
+                iv_logger.info("\tmetafield="+mfName+"\tvalue="+mfValue);
+            }
+        }
+    }
+
+}

Modified: incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/DictionaryLookupAnnotator.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/uima/lookup/ae/DictionaryLookupAnnotator.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/DictionaryLookupAnnotator.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/DictionaryLookupAnnotator.java Wed Oct 31 05:26:43 2012
@@ -1,18 +1,11 @@
 /*
- * Copyright: (c) 2009   Mayo Foundation for Medical Education and 
- * Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the
- * triple-shield Mayo logo are trademarks and service marks of MFMER.
- *
- * Except as contained in the copyright notice above, or as used to identify 
- * MFMER as the author of this software, the trade names, trademarks, service
- * marks, or product names of the copyright holder shall not be used in
- * advertising, promotion or otherwise in connection with this software without
- * prior written authorization of the copyright holder.
- * 
- * Licensed 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
- * 
+ * 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
@@ -21,8 +14,8 @@
  * See the License for the specific language governing permissions and 
  * limitations under the License. 
  */
-package edu.mayo.bmi.uima.lookup.ae;
-
+package edu.mayo.bmi.uima.lookup.ae;
+
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -49,93 +42,93 @@ import edu.mayo.bmi.lookup.vo.LookupHit;
 import edu.mayo.bmi.lookup.vo.LookupToken;
 import edu.mayo.bmi.lookup.vo.LookupTokenComparator;
 import edu.mayo.bmi.uima.core.resource.FileResource;
-
-/**
- * UIMA annotator that identified entities based on lookup.
- * 
- * @author Mayo Clinic
- */
-public class DictionaryLookupAnnotator extends JCasAnnotator_ImplBase
-{
-	// LOG4J logger based on class name
-	private Logger iv_logger = Logger.getLogger(getClass().getName());
-
-	private UimaContext iv_context;
-
-	private Set iv_lookupSpecSet = new HashSet();
-
-	private Comparator iv_lookupTokenComparator = new LookupTokenComparator();
-
-	// used to prevent duplicate hits
-	// key = hit begin,end key (java.lang.String)
-	// val = Set of MetaDataHit objects
-	private Map iv_dupMap = new HashMap();
-
-	public void initialize(UimaContext aContext)
-			throws ResourceInitializationException
-	{
-		super.initialize(aContext);
-
-		iv_context = aContext;
-		configInit();
-
-	}
-
-	/**
-	 * Reads configuration parameters.
-	 */
-	private void configInit() throws ResourceInitializationException
+
+/**
+ * UIMA annotator that identified entities based on lookup.
+ * 
+ * @author Mayo Clinic
+ */
+public class DictionaryLookupAnnotator extends JCasAnnotator_ImplBase
+{
+	// LOG4J logger based on class name
+	private Logger iv_logger = Logger.getLogger(getClass().getName());
+
+	private UimaContext iv_context;
+
+	private Set iv_lookupSpecSet = new HashSet();
+
+	private Comparator iv_lookupTokenComparator = new LookupTokenComparator();
+
+	// used to prevent duplicate hits
+	// key = hit begin,end key (java.lang.String)
+	// val = Set of MetaDataHit objects
+	private Map iv_dupMap = new HashMap();
+
+	public void initialize(UimaContext aContext)
+			throws ResourceInitializationException
+	{
+		super.initialize(aContext);
+
+		iv_context = aContext;
+		configInit();
+
+	}
+
+	/**
+	 * Reads configuration parameters.
+	 */
+	private void configInit() throws ResourceInitializationException
 	{
-		try {
-		FileResource fResrc = (FileResource) iv_context.getResourceObject("LookupDescriptor");
-		File descFile = fResrc.getFile();
-
-			iv_logger.info("Parsing descriptor: " + descFile.getAbsolutePath());
-			iv_lookupSpecSet = LookupParseUtilities.parseDescriptor(descFile, iv_context);
-		}
-		catch (Exception e) {
-			throw new ResourceInitializationException(e);
-		}
-
-	}
-
-	/**
-	 * Entry point for processing.
-	 */
-	public void process(JCas jcas)
-			throws AnalysisEngineProcessException {
-		
+		try {
+		FileResource fResrc = (FileResource) iv_context.getResourceObject("LookupDescriptor");
+		File descFile = fResrc.getFile();
+
+			iv_logger.info("Parsing descriptor: " + descFile.getAbsolutePath());
+			iv_lookupSpecSet = LookupParseUtilities.parseDescriptor(descFile, iv_context);
+		}
+		catch (Exception e) {
+			throw new ResourceInitializationException(e);
+		}
+
+	}
+
+	/**
+	 * Entry point for processing.
+	 */
+	public void process(JCas jcas)
+			throws AnalysisEngineProcessException {
+		
 		iv_logger.info("process(JCas)");
-		iv_dupMap.clear();
-		
-		try {
-
-			Iterator lsItr = iv_lookupSpecSet.iterator();
-			while (lsItr.hasNext()) {
-
-				LookupSpec ls = (LookupSpec) lsItr.next();
-				LookupInitializer lInit = ls.getLookupInitializer();
-
-				Iterator windowItr = lInit.getLookupWindowIterator(jcas);
-				while (windowItr.hasNext()) {
-
-					Annotation window = (Annotation) windowItr.next();
-					List lookupTokensInWindow = constrainToWindow(
-							window,
-	                        lInit.getLookupTokenIterator(jcas),
+		iv_dupMap.clear();
+		
+		try {
+
+			Iterator lsItr = iv_lookupSpecSet.iterator();
+			while (lsItr.hasNext()) {
+
+				LookupSpec ls = (LookupSpec) lsItr.next();
+				LookupInitializer lInit = ls.getLookupInitializer();
+
+				Iterator windowItr = lInit.getLookupWindowIterator(jcas);
+				while (windowItr.hasNext()) {
+
+					Annotation window = (Annotation) windowItr.next();
+					List lookupTokensInWindow = constrainToWindow(
+							window,
+	                        lInit.getLookupTokenIterator(jcas),
 	                        true); // assume tokens are sorted
-
-					Map ctxMap = lInit.getContextMap(
-							jcas,
-							window.getBegin(),
-							window.getEnd());
-					performLookup(jcas, ls, lookupTokensInWindow, ctxMap);
-				}
-			}
-
-		}
-		catch (Exception e) {
-			throw new AnalysisEngineProcessException(e);
+
+					Map ctxMap = lInit.getContextMap(
+							jcas,
+							window.getBegin(),
+							window.getEnd());
+					performLookup(jcas, ls, lookupTokensInWindow, ctxMap);
+				}
+			}
+
+		}
+		catch (Exception e) {
+			throw new AnalysisEngineProcessException(e);
 	    }
 	}
 
@@ -177,130 +170,130 @@ public class DictionaryLookupAnnotator e
                 
                 iv_logger.info(msg1 + " | " + msg2);
                 
-            }
-	}
-
-	/**
-	 * Executes the lookup algorithm on the lookup tokens. Hits are stored to
-	 * CAS.
-	 */
-	private void performLookup(JCas jcas, LookupSpec ls, List lookupTokenList,
-			Map ctxMap) throws Exception
-	{
-		// sort the lookup tokens
-		Collections.sort(lookupTokenList, iv_lookupTokenComparator);
-
-		// perform lookup
-		Collection lookupHitCol = null;
-
-		LookupAlgorithm la = (LookupAlgorithm) ls.getLookupAlgorithm();
-		lookupHitCol = la.lookup(lookupTokenList, ctxMap);
-
-		Collection uniqueHitCol = filterHitDups(lookupHitCol);
-
-		// consume hits
-		ls.getLookupConsumer().consumeHits(jcas, uniqueHitCol.iterator());
-	}
-
-	/**
-	 * Filters out duplicate LookupHit objects.
-	 * 
-	 * @param lookupHitCol
-	 * @return
-	 */
-	private Collection filterHitDups(Collection lookupHitCol)
-	{
-		List l = new ArrayList();
-		Iterator itr = lookupHitCol.iterator();
-		while (itr.hasNext())
-		{
-			LookupHit lh = (LookupHit) itr.next();
-			if (!isDuplicate(lh))
-			{
-				l.add(lh);
-			}
-		}
-		return l;
-	}
-
-	/**
-	 * Checks to see whether this hit is a duplicate.
-	 * 
-	 * @param lh
-	 * @return
-	 */
-	private boolean isDuplicate(LookupHit lh)
-	{
-		MetaDataHit mdh = lh.getDictMetaDataHit();
-
-		// iterate over MetaDataHits that have already been seen
-		String offsetKey = getOffsetKey(lh);
-		Set mdhDuplicateSet = (Set) iv_dupMap.get(offsetKey);
-		if (mdhDuplicateSet != null)
-		{
-			Iterator itr = mdhDuplicateSet.iterator();
-			while (itr.hasNext())
-			{
-				MetaDataHit otherMdh = (MetaDataHit) itr.next();
-				if (mdh.equals(otherMdh))
-				{
-					// current LookupHit is a duplicate
-					return true;
-				}
-			}
-		}
-		else
-		{
-			mdhDuplicateSet = new HashSet();
-		}
-
-		// current LookupHit is new, add it to the duplicate set
-		// for future checks
-		mdhDuplicateSet.add(mdh);
-		iv_dupMap.put(offsetKey, mdhDuplicateSet);
-		return false;
-	}
-
-	/**
-	 * Gets a list of LookupToken objects within the specified window annotation.
-	 * 
-	 * @param window
-	 * @param lookupTokenItr
+            }
+	}
+
+	/**
+	 * Executes the lookup algorithm on the lookup tokens. Hits are stored to
+	 * CAS.
+	 */
+	private void performLookup(JCas jcas, LookupSpec ls, List lookupTokenList,
+			Map ctxMap) throws Exception
+	{
+		// sort the lookup tokens
+		Collections.sort(lookupTokenList, iv_lookupTokenComparator);
+
+		// perform lookup
+		Collection lookupHitCol = null;
+
+		LookupAlgorithm la = (LookupAlgorithm) ls.getLookupAlgorithm();
+		lookupHitCol = la.lookup(lookupTokenList, ctxMap);
+
+		Collection uniqueHitCol = filterHitDups(lookupHitCol);
+
+		// consume hits
+		ls.getLookupConsumer().consumeHits(jcas, uniqueHitCol.iterator());
+	}
+
+	/**
+	 * Filters out duplicate LookupHit objects.
+	 * 
+	 * @param lookupHitCol
+	 * @return
+	 */
+	private Collection filterHitDups(Collection lookupHitCol)
+	{
+		List l = new ArrayList();
+		Iterator itr = lookupHitCol.iterator();
+		while (itr.hasNext())
+		{
+			LookupHit lh = (LookupHit) itr.next();
+			if (!isDuplicate(lh))
+			{
+				l.add(lh);
+			}
+		}
+		return l;
+	}
+
+	/**
+	 * Checks to see whether this hit is a duplicate.
+	 * 
+	 * @param lh
+	 * @return
+	 */
+	private boolean isDuplicate(LookupHit lh)
+	{
+		MetaDataHit mdh = lh.getDictMetaDataHit();
+
+		// iterate over MetaDataHits that have already been seen
+		String offsetKey = getOffsetKey(lh);
+		Set mdhDuplicateSet = (Set) iv_dupMap.get(offsetKey);
+		if (mdhDuplicateSet != null)
+		{
+			Iterator itr = mdhDuplicateSet.iterator();
+			while (itr.hasNext())
+			{
+				MetaDataHit otherMdh = (MetaDataHit) itr.next();
+				if (mdh.equals(otherMdh))
+				{
+					// current LookupHit is a duplicate
+					return true;
+				}
+			}
+		}
+		else
+		{
+			mdhDuplicateSet = new HashSet();
+		}
+
+		// current LookupHit is new, add it to the duplicate set
+		// for future checks
+		mdhDuplicateSet.add(mdh);
+		iv_dupMap.put(offsetKey, mdhDuplicateSet);
+		return false;
+	}
+
+	/**
+	 * Gets a list of LookupToken objects within the specified window annotation.
+	 * 
+	 * @param window
+	 * @param lookupTokenItr
 	 * @param lookupTokensAreSorted if true, can be faster by stopping once find a token that is after the end of the lookup window
-	 * @return
-	 * @throws Exception
-	 */
-	private List constrainToWindow(Annotation window, Iterator lookupTokenItr, boolean lookupTokensAreSorted)
-			throws Exception
-	{
-		List ltObjectList = new ArrayList();
-
-		while (lookupTokenItr.hasNext())
-		{
-			LookupToken lt = (LookupToken) lookupTokenItr.next();
-
-			// only consider if it's within the window
-			if ((lt.getStartOffset() >= window.getBegin())
-					&& (lt.getEndOffset() <= window.getEnd()))
-			{
-				ltObjectList.add(lt);
-			}
+	 * @return
+	 * @throws Exception
+	 */
+	private List constrainToWindow(Annotation window, Iterator lookupTokenItr, boolean lookupTokensAreSorted)
+			throws Exception
+	{
+		List ltObjectList = new ArrayList();
+
+		while (lookupTokenItr.hasNext())
+		{
+			LookupToken lt = (LookupToken) lookupTokenItr.next();
+
+			// only consider if it's within the window
+			if ((lt.getStartOffset() >= window.getBegin())
+					&& (lt.getEndOffset() <= window.getEnd()))
+			{
+				ltObjectList.add(lt);
+			}
 			
 			if (lookupTokensAreSorted && (lt.getStartOffset() >= window.getEnd())) {
 				// past the end of the window, don't need to keep going as long as the LookupToken are sorted
 				return ltObjectList;
 			}
 			
-		}
-		return ltObjectList;
-	}
-
-	private String getOffsetKey(LookupHit lh)
-	{
-		StringBuffer sb = new StringBuffer();
-		sb.append(lh.getStartOffset());
-		sb.append(',');
-		sb.append(lh.getEndOffset());
-		return sb.toString();
-	}
-}
\ No newline at end of file
+		}
+		return ltObjectList;
+	}
+
+	private String getOffsetKey(LookupHit lh)
+	{
+		StringBuffer sb = new StringBuffer();
+		sb.append(lh.getStartOffset());
+		sb.append(',');
+		sb.append(lh.getEndOffset());
+		return sb.toString();
+	}
+}

Modified: incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/DirectLookupInitializerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/uima/lookup/ae/DirectLookupInitializerImpl.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/DirectLookupInitializerImpl.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/DirectLookupInitializerImpl.java Wed Oct 31 05:26:43 2012
@@ -1,18 +1,11 @@
 /*
- * Copyright: (c) 2009   Mayo Foundation for Medical Education and 
- * Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the
- * triple-shield Mayo logo are trademarks and service marks of MFMER.
- *
- * Except as contained in the copyright notice above, or as used to identify 
- * MFMER as the author of this software, the trade names, trademarks, service
- * marks, or product names of the copyright holder shall not be used in
- * advertising, promotion or otherwise in connection with this software without
- * prior written authorization of the copyright holder.
- * 
- * Licensed 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
- * 
+ * 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
@@ -21,102 +14,102 @@
  * See the License for the specific language governing permissions and 
  * limitations under the License. 
  */
-package edu.mayo.bmi.uima.lookup.ae;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
+package edu.mayo.bmi.uima.lookup.ae;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
 import org.apache.uima.UimaContext;
-import org.apache.uima.analysis_engine.annotator.AnnotatorInitializationException;
-import org.apache.uima.jcas.JFSIndexRepository;
-import org.apache.uima.jcas.JCas;
-
-import edu.mayo.bmi.dictionary.DictionaryEngine;
-import edu.mayo.bmi.lookup.algorithms.DirectPassThroughImpl;
-import edu.mayo.bmi.lookup.algorithms.LookupAlgorithm;
-import edu.mayo.bmi.lookup.phrasebuilder.PhraseBuilder;
-import edu.mayo.bmi.lookup.phrasebuilder.VariantPhraseBuilderImpl;
-import edu.mayo.bmi.lookup.vo.LookupToken;
-import edu.mayo.bmi.uima.core.type.syntax.BaseToken;
-import edu.mayo.bmi.uima.core.type.syntax.ContractionToken;
-import edu.mayo.bmi.uima.core.type.syntax.NewlineToken;
-import edu.mayo.bmi.uima.core.type.syntax.PunctuationToken;
-import edu.mayo.bmi.uima.core.type.textspan.Sentence;
-import edu.mayo.bmi.uima.core.type.syntax.SymbolToken;
-import edu.mayo.bmi.uima.core.type.syntax.WordToken;
-
-/**
- * @author Mayo Clinic
- */
-public class DirectLookupInitializerImpl implements LookupInitializer
-{
-	private final String CANONICAL_VARIANT_ATTR = "canonicalATTR";
-
-	public DirectLookupInitializerImpl(UimaContext aCtx, Properties props)
-	{
-		// TODO property validation could be done here
-	}
-
-	public LookupAlgorithm getLookupAlgorithm(DictionaryEngine dictEngine)
-			throws AnnotatorInitializationException
-	{
-		// variant support
-		String[] variantArr = { CANONICAL_VARIANT_ATTR };
-		PhraseBuilder pb = new VariantPhraseBuilderImpl(variantArr, true);
-
-		return new DirectPassThroughImpl(dictEngine, pb);
-	}
-
-	public Iterator getLookupTokenIterator(JCas jcas)
-			throws AnnotatorInitializationException
-	{
-		List ltList = new ArrayList();
-
-		JFSIndexRepository indexes = jcas.getJFSIndexRepository();
-		Iterator btaItr = indexes.getAnnotationIndex(BaseToken.type)
-				.iterator();
-		while (btaItr.hasNext())
-		{
-			BaseToken bta = (BaseToken) btaItr.next();
-			if (!((bta instanceof NewlineToken)
-					|| (bta instanceof PunctuationToken)
-					|| (bta instanceof ContractionToken)
-					|| (bta instanceof SymbolToken)))
-			{
-				LookupToken lt = new LookupAnnotationToJCasAdapter(bta);
-
-				if (bta instanceof WordToken)
-				{
-					WordToken wta = (WordToken) bta;
-					String canonicalForm = wta.getCanonicalForm();
-					if (canonicalForm != null)
-					{
-						lt.addStringAttribute(
-								CANONICAL_VARIANT_ATTR,
-								canonicalForm);
-					}
-				}
-
-				ltList.add(lt);
-			}
-		}
-		return ltList.iterator();
-	}
-
-	public Iterator getLookupWindowIterator(JCas jcas)
-			throws AnnotatorInitializationException
-	{
-		JFSIndexRepository indexes = jcas.getJFSIndexRepository();
-		return indexes.getAnnotationIndex(Sentence.type).iterator();
-	}
-
-	public Map getContextMap(JCas jcas, int windowBegin, int windowEnd)
-	{
-		// not used for direct pass through algorithm, return empty map
-		return new HashMap();
-	}
-}
\ No newline at end of file
+import org.apache.uima.analysis_engine.annotator.AnnotatorInitializationException;
+import org.apache.uima.jcas.JFSIndexRepository;
+import org.apache.uima.jcas.JCas;
+
+import edu.mayo.bmi.dictionary.DictionaryEngine;
+import edu.mayo.bmi.lookup.algorithms.DirectPassThroughImpl;
+import edu.mayo.bmi.lookup.algorithms.LookupAlgorithm;
+import edu.mayo.bmi.lookup.phrasebuilder.PhraseBuilder;
+import edu.mayo.bmi.lookup.phrasebuilder.VariantPhraseBuilderImpl;
+import edu.mayo.bmi.lookup.vo.LookupToken;
+import edu.mayo.bmi.uima.core.type.syntax.BaseToken;
+import edu.mayo.bmi.uima.core.type.syntax.ContractionToken;
+import edu.mayo.bmi.uima.core.type.syntax.NewlineToken;
+import edu.mayo.bmi.uima.core.type.syntax.PunctuationToken;
+import edu.mayo.bmi.uima.core.type.textspan.Sentence;
+import edu.mayo.bmi.uima.core.type.syntax.SymbolToken;
+import edu.mayo.bmi.uima.core.type.syntax.WordToken;
+
+/**
+ * @author Mayo Clinic
+ */
+public class DirectLookupInitializerImpl implements LookupInitializer
+{
+	private final String CANONICAL_VARIANT_ATTR = "canonicalATTR";
+
+	public DirectLookupInitializerImpl(UimaContext aCtx, Properties props)
+	{
+		// TODO property validation could be done here
+	}
+
+	public LookupAlgorithm getLookupAlgorithm(DictionaryEngine dictEngine)
+			throws AnnotatorInitializationException
+	{
+		// variant support
+		String[] variantArr = { CANONICAL_VARIANT_ATTR };
+		PhraseBuilder pb = new VariantPhraseBuilderImpl(variantArr, true);
+
+		return new DirectPassThroughImpl(dictEngine, pb);
+	}
+
+	public Iterator getLookupTokenIterator(JCas jcas)
+			throws AnnotatorInitializationException
+	{
+		List ltList = new ArrayList();
+
+		JFSIndexRepository indexes = jcas.getJFSIndexRepository();
+		Iterator btaItr = indexes.getAnnotationIndex(BaseToken.type)
+				.iterator();
+		while (btaItr.hasNext())
+		{
+			BaseToken bta = (BaseToken) btaItr.next();
+			if (!((bta instanceof NewlineToken)
+					|| (bta instanceof PunctuationToken)
+					|| (bta instanceof ContractionToken)
+					|| (bta instanceof SymbolToken)))
+			{
+				LookupToken lt = new LookupAnnotationToJCasAdapter(bta);
+
+				if (bta instanceof WordToken)
+				{
+					WordToken wta = (WordToken) bta;
+					String canonicalForm = wta.getCanonicalForm();
+					if (canonicalForm != null)
+					{
+						lt.addStringAttribute(
+								CANONICAL_VARIANT_ATTR,
+								canonicalForm);
+					}
+				}
+
+				ltList.add(lt);
+			}
+		}
+		return ltList.iterator();
+	}
+
+	public Iterator getLookupWindowIterator(JCas jcas)
+			throws AnnotatorInitializationException
+	{
+		JFSIndexRepository indexes = jcas.getJFSIndexRepository();
+		return indexes.getAnnotationIndex(Sentence.type).iterator();
+	}
+
+	public Map getContextMap(JCas jcas, int windowBegin, int windowEnd)
+	{
+		// not used for direct pass through algorithm, return empty map
+		return new HashMap();
+	}
+}

Modified: incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/FirstTokenPermLookupInitializerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/uima/lookup/ae/FirstTokenPermLookupInitializerImpl.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/FirstTokenPermLookupInitializerImpl.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/FirstTokenPermLookupInitializerImpl.java Wed Oct 31 05:26:43 2012
@@ -1,18 +1,11 @@
 /*
- * Copyright: (c) 2009   Mayo Foundation for Medical Education and 
- * Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the
- * triple-shield Mayo logo are trademarks and service marks of MFMER.
- *
- * Except as contained in the copyright notice above, or as used to identify 
- * MFMER as the author of this software, the trade names, trademarks, service
- * marks, or product names of the copyright holder shall not be used in
- * advertising, promotion or otherwise in connection with this software without
- * prior written authorization of the copyright holder.
- * 
- * Licensed 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
- * 
+ * 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
@@ -21,238 +14,238 @@
  * See the License for the specific language governing permissions and 
  * limitations under the License. 
  */
-package edu.mayo.bmi.uima.lookup.ae;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-
+package edu.mayo.bmi.uima.lookup.ae;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+
 import org.apache.uima.UimaContext;
-import org.apache.uima.analysis_engine.annotator.AnnotatorInitializationException;
-import org.apache.uima.jcas.JFSIndexRepository;
-import org.apache.uima.jcas.JCas;
-import org.apache.uima.jcas.tcas.Annotation;
-
-import edu.mayo.bmi.dictionary.DictionaryEngine;
-import edu.mayo.bmi.lookup.algorithms.FirstTokenPermutationImpl;
-import edu.mayo.bmi.lookup.algorithms.LookupAlgorithm;
-import edu.mayo.bmi.lookup.phrasebuilder.PhraseBuilder;
-import edu.mayo.bmi.lookup.phrasebuilder.VariantPhraseBuilderImpl;
-import edu.mayo.bmi.lookup.vo.LookupToken;
-import edu.mayo.bmi.uima.core.type.syntax.BaseToken;
-import edu.mayo.bmi.uima.core.type.syntax.ContractionToken;
-import edu.mayo.bmi.uima.core.type.syntax.NewlineToken;
-import edu.mayo.bmi.uima.core.type.syntax.PunctuationToken;
-import edu.mayo.bmi.uima.core.type.syntax.SymbolToken;
-import edu.mayo.bmi.uima.core.type.syntax.WordToken;
-import edu.mayo.bmi.uima.core.util.JCasUtil;
-
-/**
- * @author Mayo Clinic
- */
-public class FirstTokenPermLookupInitializerImpl implements LookupInitializer
-{
-	// LOG4J logger based on class name
-	private Logger iv_logger = Logger.getLogger(getClass().getName());
-
-	// properties for firstWordPermutation algorithm
-	private final String TEXT_MFS_PRP_KEY = "textMetaFields";
-	private final String MAX_P_LEVEL_PRP_KEY = "maxPermutationLevel";
-	private final String WINDOW_ANNOT_PRP_KEY = "windowAnnotations";
-	private final String EXC_TAGS_PRP_KEY = "exclusionTags"; // optional
-
-	private final String CANONICAL_VARIANT_ATTR = "canonicalATTR";
-
-	Properties iv_props;
-
-	// array of JCas window annotation type values
-	private int[] iv_annotTypeArr;
-
-	// set of exclusion POS tags (lower cased)
-	private Set iv_exclusionTagSet = null;
-
-	public FirstTokenPermLookupInitializerImpl(UimaContext aCtx,
-			Properties props) throws ClassNotFoundException,
-			IllegalAccessException, NoSuchFieldException
-	{
-		// TODO property validation could be done here
-		iv_props = props;
-
-		// optional context window annotations
-		String windowAnnots = iv_props.getProperty(WINDOW_ANNOT_PRP_KEY);
-		if (windowAnnots != null)
-		{
-			String[] windowAnnotArr = windowAnnots.split("\\|");
-			iv_annotTypeArr = new int[windowAnnotArr.length];
-			for (int i = 0; i < windowAnnotArr.length; i++)
-			{
-				iv_annotTypeArr[i] = JCasUtil.getType(windowAnnotArr[i]);
-			}
-		}
-
-		// optional exclusion POS tags
-		String tagStr = iv_props.getProperty(EXC_TAGS_PRP_KEY);
-		if (tagStr != null)
-		{
-			iv_exclusionTagSet = new HashSet();
-			String[] tagArr = tagStr.split(",");
-			for (int i = 0; i < tagArr.length; i++)
-			{
-				iv_exclusionTagSet.add(tagArr[i].toLowerCase());
-			}
-			iv_logger.info("Exclusion tagset loaded: " + iv_exclusionTagSet);
-		}
-	}
-
-	public LookupAlgorithm getLookupAlgorithm(DictionaryEngine dictEngine)
-			throws AnnotatorInitializationException
-	{
-		// variant support
-		String[] variantArr = { CANONICAL_VARIANT_ATTR };
-		PhraseBuilder pb = new VariantPhraseBuilderImpl(variantArr, true);
-
-		String textMetaFields = iv_props.getProperty(TEXT_MFS_PRP_KEY);
-		String[] textMetaFieldNameArr;
-		if(textMetaFields == null) 
-			textMetaFieldNameArr = new String[]{};
-		else
-			textMetaFieldNameArr = textMetaFields.split("\\|");
-        
-		
-		int maxPermutationLevel = Integer.parseInt(iv_props.getProperty(MAX_P_LEVEL_PRP_KEY));
-
-		return new FirstTokenPermutationImpl(dictEngine,
-				pb,
-				textMetaFieldNameArr,
-				maxPermutationLevel);
-	}
-
-	private boolean isTagExcluded(String tag)
-	{
-		if ((iv_exclusionTagSet == null) || (tag == null))
-		{
-			return false;
-		}
-
-		return iv_exclusionTagSet.contains(tag.toLowerCase());
-	}
-
-	public Iterator getLookupTokenIterator(JCas jcas)
-			throws AnnotatorInitializationException
-	{
-		List ltList = new ArrayList();
-
-		JFSIndexRepository indexes = jcas.getJFSIndexRepository();
-		Iterator btaItr = indexes.getAnnotationIndex(BaseToken.type).iterator();
-		while (btaItr.hasNext())
-		{
-			BaseToken bta = (BaseToken) btaItr.next();
-			if (!((bta instanceof NewlineToken)
-					|| (bta instanceof PunctuationToken)
-					|| (bta instanceof ContractionToken)
-					|| (bta instanceof SymbolToken)))
-			{
-				LookupToken lt = new LookupAnnotationToJCasAdapter(bta);
-
-				// POS exclusion logic for first word lookup
-				if (isTagExcluded(bta.getPartOfSpeech()))
-				{
-					lt.addStringAttribute(
-							FirstTokenPermutationImpl.LT_KEY_USE_FOR_LOOKUP,
-							"false");
-				}
-				else
-				{
-					lt.addStringAttribute(
-							FirstTokenPermutationImpl.LT_KEY_USE_FOR_LOOKUP,
-							"true");
-				}
-
-				if (bta instanceof WordToken)
-				{
-					WordToken wta = (WordToken) bta;
-					String canonicalForm = wta.getCanonicalForm();
-					if (canonicalForm != null)
-					{
-						lt.addStringAttribute(CANONICAL_VARIANT_ATTR, canonicalForm);
-					}
-				}
-
-				ltList.add(lt);
-			}
-		}
-		return ltList.iterator();
-	}
-
-	public Iterator getLookupWindowIterator(JCas jcas)
-			throws AnnotatorInitializationException
-	{
-		try
-		{
-			JFSIndexRepository indexes = jcas.getJFSIndexRepository();
-			String objClassName = iv_props.getProperty(WINDOW_ANNOT_PRP_KEY);
-			int windowType = JCasUtil.getType(objClassName);
-			return indexes.getAnnotationIndex(windowType).iterator();
-		}
-		catch (Exception e)
-		{
-			throw new AnnotatorInitializationException(e);
-		}
-	}
-
-	public Map getContextMap(JCas jcas, int windowBegin, int windowEnd)
-			throws AnnotatorInitializationException
-	{
-		if (iv_annotTypeArr != null)
-		{
-			List list = new ArrayList();
-
-			// algorithm depends on a window for permutations
-			JFSIndexRepository indexes = jcas.getJFSIndexRepository();
-			for (int i = 0; i < iv_annotTypeArr.length; i++)
-			{
-				Iterator itr = indexes.getAnnotationIndex(iv_annotTypeArr[i])
-						.iterator();
-				list.addAll(constrainToWindow(windowBegin, windowEnd, itr));
-			}
-
-			Map m = new HashMap();
-			m.put(FirstTokenPermutationImpl.CTX_KEY_WINDOW_ANNOTATIONS, list);
-			return m;
-		}
-		else
-		{
-			return new HashMap();
-		}
-	}
-
-	/**
-	 * Gets a list of LookupAnnotation objects within the specified window.
-	 * 
-	 * @param annotItr
-	 * @return
-	 */
-	private List constrainToWindow(int begin, int end, Iterator annotItr)
-	{
-		List list = new ArrayList();
-
-		while (annotItr.hasNext())
-		{
-			Annotation annot = (Annotation) annotItr.next();
-
-			// only consider if it's within the window
-			if ((annot.getBegin() >= begin) && (annot.getEnd() <= end))
-			{
-				list.add(new LookupAnnotationToJCasAdapter(annot));
-			}
-		}
-		return list;
-	}
-}
\ No newline at end of file
+import org.apache.uima.analysis_engine.annotator.AnnotatorInitializationException;
+import org.apache.uima.jcas.JFSIndexRepository;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.tcas.Annotation;
+
+import edu.mayo.bmi.dictionary.DictionaryEngine;
+import edu.mayo.bmi.lookup.algorithms.FirstTokenPermutationImpl;
+import edu.mayo.bmi.lookup.algorithms.LookupAlgorithm;
+import edu.mayo.bmi.lookup.phrasebuilder.PhraseBuilder;
+import edu.mayo.bmi.lookup.phrasebuilder.VariantPhraseBuilderImpl;
+import edu.mayo.bmi.lookup.vo.LookupToken;
+import edu.mayo.bmi.uima.core.type.syntax.BaseToken;
+import edu.mayo.bmi.uima.core.type.syntax.ContractionToken;
+import edu.mayo.bmi.uima.core.type.syntax.NewlineToken;
+import edu.mayo.bmi.uima.core.type.syntax.PunctuationToken;
+import edu.mayo.bmi.uima.core.type.syntax.SymbolToken;
+import edu.mayo.bmi.uima.core.type.syntax.WordToken;
+import edu.mayo.bmi.uima.core.util.JCasUtil;
+
+/**
+ * @author Mayo Clinic
+ */
+public class FirstTokenPermLookupInitializerImpl implements LookupInitializer
+{
+	// LOG4J logger based on class name
+	private Logger iv_logger = Logger.getLogger(getClass().getName());
+
+	// properties for firstWordPermutation algorithm
+	private final String TEXT_MFS_PRP_KEY = "textMetaFields";
+	private final String MAX_P_LEVEL_PRP_KEY = "maxPermutationLevel";
+	private final String WINDOW_ANNOT_PRP_KEY = "windowAnnotations";
+	private final String EXC_TAGS_PRP_KEY = "exclusionTags"; // optional
+
+	private final String CANONICAL_VARIANT_ATTR = "canonicalATTR";
+
+	Properties iv_props;
+
+	// array of JCas window annotation type values
+	private int[] iv_annotTypeArr;
+
+	// set of exclusion POS tags (lower cased)
+	private Set iv_exclusionTagSet = null;
+
+	public FirstTokenPermLookupInitializerImpl(UimaContext aCtx,
+			Properties props) throws ClassNotFoundException,
+			IllegalAccessException, NoSuchFieldException
+	{
+		// TODO property validation could be done here
+		iv_props = props;
+
+		// optional context window annotations
+		String windowAnnots = iv_props.getProperty(WINDOW_ANNOT_PRP_KEY);
+		if (windowAnnots != null)
+		{
+			String[] windowAnnotArr = windowAnnots.split("\\|");
+			iv_annotTypeArr = new int[windowAnnotArr.length];
+			for (int i = 0; i < windowAnnotArr.length; i++)
+			{
+				iv_annotTypeArr[i] = JCasUtil.getType(windowAnnotArr[i]);
+			}
+		}
+
+		// optional exclusion POS tags
+		String tagStr = iv_props.getProperty(EXC_TAGS_PRP_KEY);
+		if (tagStr != null)
+		{
+			iv_exclusionTagSet = new HashSet();
+			String[] tagArr = tagStr.split(",");
+			for (int i = 0; i < tagArr.length; i++)
+			{
+				iv_exclusionTagSet.add(tagArr[i].toLowerCase());
+			}
+			iv_logger.info("Exclusion tagset loaded: " + iv_exclusionTagSet);
+		}
+	}
+
+	public LookupAlgorithm getLookupAlgorithm(DictionaryEngine dictEngine)
+			throws AnnotatorInitializationException
+	{
+		// variant support
+		String[] variantArr = { CANONICAL_VARIANT_ATTR };
+		PhraseBuilder pb = new VariantPhraseBuilderImpl(variantArr, true);
+
+		String textMetaFields = iv_props.getProperty(TEXT_MFS_PRP_KEY);
+		String[] textMetaFieldNameArr;
+		if(textMetaFields == null) 
+			textMetaFieldNameArr = new String[]{};
+		else
+			textMetaFieldNameArr = textMetaFields.split("\\|");
+        
+		
+		int maxPermutationLevel = Integer.parseInt(iv_props.getProperty(MAX_P_LEVEL_PRP_KEY));
+
+		return new FirstTokenPermutationImpl(dictEngine,
+				pb,
+				textMetaFieldNameArr,
+				maxPermutationLevel);
+	}
+
+	private boolean isTagExcluded(String tag)
+	{
+		if ((iv_exclusionTagSet == null) || (tag == null))
+		{
+			return false;
+		}
+
+		return iv_exclusionTagSet.contains(tag.toLowerCase());
+	}
+
+	public Iterator getLookupTokenIterator(JCas jcas)
+			throws AnnotatorInitializationException
+	{
+		List ltList = new ArrayList();
+
+		JFSIndexRepository indexes = jcas.getJFSIndexRepository();
+		Iterator btaItr = indexes.getAnnotationIndex(BaseToken.type).iterator();
+		while (btaItr.hasNext())
+		{
+			BaseToken bta = (BaseToken) btaItr.next();
+			if (!((bta instanceof NewlineToken)
+					|| (bta instanceof PunctuationToken)
+					|| (bta instanceof ContractionToken)
+					|| (bta instanceof SymbolToken)))
+			{
+				LookupToken lt = new LookupAnnotationToJCasAdapter(bta);
+
+				// POS exclusion logic for first word lookup
+				if (isTagExcluded(bta.getPartOfSpeech()))
+				{
+					lt.addStringAttribute(
+							FirstTokenPermutationImpl.LT_KEY_USE_FOR_LOOKUP,
+							"false");
+				}
+				else
+				{
+					lt.addStringAttribute(
+							FirstTokenPermutationImpl.LT_KEY_USE_FOR_LOOKUP,
+							"true");
+				}
+
+				if (bta instanceof WordToken)
+				{
+					WordToken wta = (WordToken) bta;
+					String canonicalForm = wta.getCanonicalForm();
+					if (canonicalForm != null)
+					{
+						lt.addStringAttribute(CANONICAL_VARIANT_ATTR, canonicalForm);
+					}
+				}
+
+				ltList.add(lt);
+			}
+		}
+		return ltList.iterator();
+	}
+
+	public Iterator getLookupWindowIterator(JCas jcas)
+			throws AnnotatorInitializationException
+	{
+		try
+		{
+			JFSIndexRepository indexes = jcas.getJFSIndexRepository();
+			String objClassName = iv_props.getProperty(WINDOW_ANNOT_PRP_KEY);
+			int windowType = JCasUtil.getType(objClassName);
+			return indexes.getAnnotationIndex(windowType).iterator();
+		}
+		catch (Exception e)
+		{
+			throw new AnnotatorInitializationException(e);
+		}
+	}
+
+	public Map getContextMap(JCas jcas, int windowBegin, int windowEnd)
+			throws AnnotatorInitializationException
+	{
+		if (iv_annotTypeArr != null)
+		{
+			List list = new ArrayList();
+
+			// algorithm depends on a window for permutations
+			JFSIndexRepository indexes = jcas.getJFSIndexRepository();
+			for (int i = 0; i < iv_annotTypeArr.length; i++)
+			{
+				Iterator itr = indexes.getAnnotationIndex(iv_annotTypeArr[i])
+						.iterator();
+				list.addAll(constrainToWindow(windowBegin, windowEnd, itr));
+			}
+
+			Map m = new HashMap();
+			m.put(FirstTokenPermutationImpl.CTX_KEY_WINDOW_ANNOTATIONS, list);
+			return m;
+		}
+		else
+		{
+			return new HashMap();
+		}
+	}
+
+	/**
+	 * Gets a list of LookupAnnotation objects within the specified window.
+	 * 
+	 * @param annotItr
+	 * @return
+	 */
+	private List constrainToWindow(int begin, int end, Iterator annotItr)
+	{
+		List list = new ArrayList();
+
+		while (annotItr.hasNext())
+		{
+			Annotation annot = (Annotation) annotItr.next();
+
+			// only consider if it's within the window
+			if ((annot.getBegin() >= begin) && (annot.getEnd() <= end))
+			{
+				list.add(new LookupAnnotationToJCasAdapter(annot));
+			}
+		}
+		return list;
+	}
+}

Modified: incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/LookupAnnotationToJCasAdapter.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/uima/lookup/ae/LookupAnnotationToJCasAdapter.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/LookupAnnotationToJCasAdapter.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/LookupAnnotationToJCasAdapter.java Wed Oct 31 05:26:43 2012
@@ -1,18 +1,11 @@
 /*
- * Copyright: (c) 2009   Mayo Foundation for Medical Education and 
- * Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the
- * triple-shield Mayo logo are trademarks and service marks of MFMER.
- *
- * Except as contained in the copyright notice above, or as used to identify 
- * MFMER as the author of this software, the trade names, trademarks, service
- * marks, or product names of the copyright holder shall not be used in
- * advertising, promotion or otherwise in connection with this software without
- * prior written authorization of the copyright holder.
- * 
- * Licensed 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
- * 
+ * 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
@@ -21,58 +14,58 @@
  * See the License for the specific language governing permissions and 
  * limitations under the License. 
  */
-package edu.mayo.bmi.uima.lookup.ae;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.uima.jcas.tcas.Annotation;
-
-import edu.mayo.bmi.lookup.vo.LookupAnnotation;
-import edu.mayo.bmi.lookup.vo.LookupToken;
-
-/**
- * @author Mayo Clinic
- * 
- */
-public class LookupAnnotationToJCasAdapter implements LookupAnnotation, LookupToken
-{
-    private Map iv_attrMap = new HashMap();
-
-    private Annotation iv_jcasAnnotObj;
-
-    public LookupAnnotationToJCasAdapter(Annotation jcasAnnotObj)
-    {
-        iv_jcasAnnotObj = jcasAnnotObj;
-    }
-
-    public void addStringAttribute(String attrKey, String attrVal)
-    {
-        iv_attrMap.put(attrKey, attrVal);
-    }
-
-    public int getEndOffset()
-    {
-        return iv_jcasAnnotObj.getEnd();
-    }
-
-    public int getLength()
-    {
-        return getStartOffset() - getEndOffset();
-    }
-
-    public int getStartOffset()
-    {
-        return iv_jcasAnnotObj.getBegin();
-    }
-
-    public String getStringAttribute(String attrKey)
-    {
-        return (String) iv_attrMap.get(attrKey);
-    }
-
-    public String getText()
-    {
-        return iv_jcasAnnotObj.getCoveredText();
-    }
-}
+package edu.mayo.bmi.uima.lookup.ae;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.uima.jcas.tcas.Annotation;
+
+import edu.mayo.bmi.lookup.vo.LookupAnnotation;
+import edu.mayo.bmi.lookup.vo.LookupToken;
+
+/**
+ * @author Mayo Clinic
+ * 
+ */
+public class LookupAnnotationToJCasAdapter implements LookupAnnotation, LookupToken
+{
+    private Map iv_attrMap = new HashMap();
+
+    private Annotation iv_jcasAnnotObj;
+
+    public LookupAnnotationToJCasAdapter(Annotation jcasAnnotObj)
+    {
+        iv_jcasAnnotObj = jcasAnnotObj;
+    }
+
+    public void addStringAttribute(String attrKey, String attrVal)
+    {
+        iv_attrMap.put(attrKey, attrVal);
+    }
+
+    public int getEndOffset()
+    {
+        return iv_jcasAnnotObj.getEnd();
+    }
+
+    public int getLength()
+    {
+        return getStartOffset() - getEndOffset();
+    }
+
+    public int getStartOffset()
+    {
+        return iv_jcasAnnotObj.getBegin();
+    }
+
+    public String getStringAttribute(String attrKey)
+    {
+        return (String) iv_attrMap.get(attrKey);
+    }
+
+    public String getText()
+    {
+        return iv_jcasAnnotObj.getCoveredText();
+    }
+}

Modified: incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/LookupConsumer.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/uima/lookup/ae/LookupConsumer.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/LookupConsumer.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/LookupConsumer.java Wed Oct 31 05:26:43 2012
@@ -1,18 +1,11 @@
 /*
- * Copyright: (c) 2009   Mayo Foundation for Medical Education and 
- * Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the
- * triple-shield Mayo logo are trademarks and service marks of MFMER.
- *
- * Except as contained in the copyright notice above, or as used to identify 
- * MFMER as the author of this software, the trade names, trademarks, service
- * marks, or product names of the copyright holder shall not be used in
- * advertising, promotion or otherwise in connection with this software without
- * prior written authorization of the copyright holder.
- * 
- * Licensed 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
- * 
+ * 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
@@ -21,35 +14,35 @@
  * See the License for the specific language governing permissions and 
  * limitations under the License. 
  */
-package edu.mayo.bmi.uima.lookup.ae;
-
-import java.util.Iterator;
-
+package edu.mayo.bmi.uima.lookup.ae;
+
+import java.util.Iterator;
+
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
-import org.apache.uima.analysis_engine.annotator.AnnotatorProcessException;
-import org.apache.uima.jcas.JCas;
-
-/**
- * Defines how to consume the lookup hits produced by the LookupAnnotator.
- * 
- * NOTE: Constructor for implementation will be passed 2 arguments
- * 1.) AnnotatorContext for accessing external resources
- * 2.) Properties object for customization purposes.
- * 
- * @author Mayo Clinic
- */
-public interface LookupConsumer
-{
-	/**
-	 * Consumes the hits produced by the LookupAnnotator. This typically means
-	 * iterating over the hits and storing what's necessary to the JCas
-	 * @param jcas
-	 *            CAS for storing data
-	 * @param lookupHitItr
-	 *            Iterator over LookupHit objects. These objects contain data
-	 *            about the annotation span plus any associated metadata.
-	 * @throws AnnotatorProcessException
-	 */
-	public void consumeHits(JCas jcas, Iterator lookupHitItr)
-			throws AnalysisEngineProcessException;
-}
+import org.apache.uima.analysis_engine.annotator.AnnotatorProcessException;
+import org.apache.uima.jcas.JCas;
+
+/**
+ * Defines how to consume the lookup hits produced by the LookupAnnotator.
+ * 
+ * NOTE: Constructor for implementation will be passed 2 arguments
+ * 1.) AnnotatorContext for accessing external resources
+ * 2.) Properties object for customization purposes.
+ * 
+ * @author Mayo Clinic
+ */
+public interface LookupConsumer
+{
+	/**
+	 * Consumes the hits produced by the LookupAnnotator. This typically means
+	 * iterating over the hits and storing what's necessary to the JCas
+	 * @param jcas
+	 *            CAS for storing data
+	 * @param lookupHitItr
+	 *            Iterator over LookupHit objects. These objects contain data
+	 *            about the annotation span plus any associated metadata.
+	 * @throws AnnotatorProcessException
+	 */
+	public void consumeHits(JCas jcas, Iterator lookupHitItr)
+			throws AnalysisEngineProcessException;
+}

Modified: incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/LookupInitializer.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/uima/lookup/ae/LookupInitializer.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/LookupInitializer.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/uima/lookup/ae/LookupInitializer.java Wed Oct 31 05:26:43 2012
@@ -1,18 +1,11 @@
 /*
- * Copyright: (c) 2009   Mayo Foundation for Medical Education and 
- * Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the
- * triple-shield Mayo logo are trademarks and service marks of MFMER.
- *
- * Except as contained in the copyright notice above, or as used to identify 
- * MFMER as the author of this software, the trade names, trademarks, service
- * marks, or product names of the copyright holder shall not be used in
- * advertising, promotion or otherwise in connection with this software without
- * prior written authorization of the copyright holder.
- * 
- * Licensed 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
- * 
+ * 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
@@ -21,78 +14,78 @@
  * See the License for the specific language governing permissions and 
  * limitations under the License. 
  */
-package edu.mayo.bmi.uima.lookup.ae;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.uima.analysis_engine.annotator.AnnotatorInitializationException;
-import org.apache.uima.jcas.JCas;
-
-import edu.mayo.bmi.dictionary.DictionaryEngine;
-import edu.mayo.bmi.lookup.algorithms.LookupAlgorithm;
-
-/**
- * Defines how to initialize the LookupAnnotator.
- * 
- * NOTE: Constructor for implementation will be passed 2 arguments
- * 1.) AnnotatorContext for accessing external resources
- * 2.) Properties object for customization purposes.
- * 
- * @author Mayo Clinic
- */
-public interface LookupInitializer
-{
-    /**
-     * Gets an iteration of tokens that represent the finest grain used for a
-     * lookup operation. These tokens may be as simple as a single word or
-     * perhaps an entire phrase.
-     * 
-     * @param jcas
-     *            Use the JCas to pull out pre-existing feature structures to
-     *            build the LookupToken objects. Add attributes to the
-     *            LookupToken objects as you see fit.
-     * @return Iterator over LookupToken objects.
-     * @throws AnnotatorInitializationException
-     */
-    public Iterator getLookupTokenIterator(JCas jcas)
-            throws AnnotatorInitializationException;
-
-    /**
-     * Gets an iteration of windows. A window is used to scope which LookupToken
-     * objects are passed to the LookupAlgorithm.
-     * 
-     * @param jcas
-     *            Use the JCas to pull out pre-existing feature structures to
-     *            build LookupAnnotation objects.
-     * @return Iterator over org.apache.uima.jcas.tcas.Annotation objects, each
-     *         representing a window.
-     * @throws AnnotatorInitializationException
-     */
-    public Iterator getLookupWindowIterator(JCas jcas)
-            throws AnnotatorInitializationException;
-
-    /**
-     * Gets the LookupAlgorithm to be used to perform the lookup operations.
-     * Properties specified from the descriptor will be passed in to customize
-     * the behavior of the algorithm.
-     * 
-     * @param dictEngine
-     *            DictionaryEngine that will execute lookup operations.
-     * @return LookupAlgorithm that will be used for lookup operations.
-     * @throws AnnotatorInitializationException
-     */
-    public LookupAlgorithm getLookupAlgorithm(DictionaryEngine dictEngine)
-            throws AnnotatorInitializationException;
-
-    /**
-     * Gets context for the specified window.
-     * 
-     * @param jcas
-     * @param windowBegin
-     * @param windowEnd
-     * @return
-     */
-    public Map getContextMap(JCas jcas, int windowBegin, int windowEnd)
-            throws AnnotatorInitializationException;
-}
\ No newline at end of file
+package edu.mayo.bmi.uima.lookup.ae;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.uima.analysis_engine.annotator.AnnotatorInitializationException;
+import org.apache.uima.jcas.JCas;
+
+import edu.mayo.bmi.dictionary.DictionaryEngine;
+import edu.mayo.bmi.lookup.algorithms.LookupAlgorithm;
+
+/**
+ * Defines how to initialize the LookupAnnotator.
+ * 
+ * NOTE: Constructor for implementation will be passed 2 arguments
+ * 1.) AnnotatorContext for accessing external resources
+ * 2.) Properties object for customization purposes.
+ * 
+ * @author Mayo Clinic
+ */
+public interface LookupInitializer
+{
+    /**
+     * Gets an iteration of tokens that represent the finest grain used for a
+     * lookup operation. These tokens may be as simple as a single word or
+     * perhaps an entire phrase.
+     * 
+     * @param jcas
+     *            Use the JCas to pull out pre-existing feature structures to
+     *            build the LookupToken objects. Add attributes to the
+     *            LookupToken objects as you see fit.
+     * @return Iterator over LookupToken objects.
+     * @throws AnnotatorInitializationException
+     */
+    public Iterator getLookupTokenIterator(JCas jcas)
+            throws AnnotatorInitializationException;
+
+    /**
+     * Gets an iteration of windows. A window is used to scope which LookupToken
+     * objects are passed to the LookupAlgorithm.
+     * 
+     * @param jcas
+     *            Use the JCas to pull out pre-existing feature structures to
+     *            build LookupAnnotation objects.
+     * @return Iterator over org.apache.uima.jcas.tcas.Annotation objects, each
+     *         representing a window.
+     * @throws AnnotatorInitializationException
+     */
+    public Iterator getLookupWindowIterator(JCas jcas)
+            throws AnnotatorInitializationException;
+
+    /**
+     * Gets the LookupAlgorithm to be used to perform the lookup operations.
+     * Properties specified from the descriptor will be passed in to customize
+     * the behavior of the algorithm.
+     * 
+     * @param dictEngine
+     *            DictionaryEngine that will execute lookup operations.
+     * @return LookupAlgorithm that will be used for lookup operations.
+     * @throws AnnotatorInitializationException
+     */
+    public LookupAlgorithm getLookupAlgorithm(DictionaryEngine dictEngine)
+            throws AnnotatorInitializationException;
+
+    /**
+     * Gets context for the specified window.
+     * 
+     * @param jcas
+     * @param windowBegin
+     * @param windowEnd
+     * @return
+     */
+    public Map getContextMap(JCas jcas, int windowBegin, int windowEnd)
+            throws AnnotatorInitializationException;
+}