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 [20/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/dictionary/lucene/LuceneDictionaryImpl.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/dictionary/lucene/LuceneDictionaryImpl.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/lucene/LuceneDictionaryImpl.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/lucene/LuceneDictionaryImpl.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,47 +14,47 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package edu.mayo.bmi.dictionary.lucene;
-
-import java.io.IOException;
+package edu.mayo.bmi.dictionary.lucene;
+
+import java.io.IOException;
import java.util.BitSet;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
import org.apache.log4j.Logger;
import org.apache.lucene.analysis.KeywordAnalyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.index.Term;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.index.Term;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Query;
+import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
-import org.apache.lucene.search.Searcher;
-import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.Searcher;
+import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.WildcardQuery;
import org.apache.lucene.util.Version;
-
-import edu.mayo.bmi.dictionary.BaseDictionaryImpl;
-import edu.mayo.bmi.dictionary.Dictionary;
-import edu.mayo.bmi.dictionary.DictionaryException;
-import edu.mayo.bmi.dictionary.MetaDataHit;
-
-/**
- *
- * @author Mayo Clinic
- */
-public class LuceneDictionaryImpl extends BaseDictionaryImpl implements Dictionary
-{
- private Searcher iv_searcher;
+
+import edu.mayo.bmi.dictionary.BaseDictionaryImpl;
+import edu.mayo.bmi.dictionary.Dictionary;
+import edu.mayo.bmi.dictionary.DictionaryException;
+import edu.mayo.bmi.dictionary.MetaDataHit;
+
+/**
+ *
+ * @author Mayo Clinic
+ */
+public class LuceneDictionaryImpl extends BaseDictionaryImpl implements Dictionary
+{
+ private Searcher iv_searcher;
private String iv_lookupFieldName;
//ohnlp-Bugs-3296301 limits the search results to fixed 100 records.
private int iv_maxHits;
// LOG4J logger based on class name
private Logger iv_logger = Logger.getLogger(getClass().getName());
-
+
/**
*
* Constructor
@@ -74,26 +67,26 @@ public class LuceneDictionaryImpl extend
// TODO Only take perfect matches?
}
- /**
- *
- * Constructor
- *
- */
- public LuceneDictionaryImpl(Searcher searcher, String lookupFieldName, int maxListHits)
- {
- iv_searcher = searcher;
+ /**
+ *
+ * Constructor
+ *
+ */
+ public LuceneDictionaryImpl(Searcher searcher, String lookupFieldName, int maxListHits)
+ {
+ iv_searcher = searcher;
iv_lookupFieldName = lookupFieldName;
- // Added 'maxListHits'
- iv_maxHits = maxListHits;
- // TODO Only take perfect matches?
- }
-
- public Collection getEntries(String str) throws DictionaryException
- {
+ // Added 'maxListHits'
+ iv_maxHits = maxListHits;
+ // TODO Only take perfect matches?
+ }
+
+ public Collection getEntries(String str) throws DictionaryException
+ {
Set metaDataHitSet = new HashSet();
-
- try
- {
+
+ try
+ {
Query q = null;
TopDocs topDoc = null;
if (str.indexOf('-') == -1) {
@@ -112,8 +105,8 @@ public class LuceneDictionaryImpl extend
if (iv_maxHits==0) {
iv_maxHits=Integer.MAX_VALUE;
iv_logger.warn("iv_maxHits was 0, using Integer.MAX_VALUE instead");
- }
-
+ }
+
ScoreDoc[] hits = topDoc.scoreDocs;
if (hits.length == iv_maxHits) {
iv_logger.warn("'iv_maxHits' equals the list length returned by the lucene query (" + hits.length+").");
@@ -126,35 +119,35 @@ public class LuceneDictionaryImpl extend
metaDataHitSet.add(mdh);
}
- return metaDataHitSet;
- }
- catch (IOException ioe)
- {
- throw new DictionaryException(ioe);
- }
- }
-
- public boolean contains(String str) throws DictionaryException
- {
- try
- {
- Query q = new TermQuery(new Term(iv_lookupFieldName, str));
-
- TopDocs topDoc = iv_searcher.search(q, iv_maxHits);
- ScoreDoc[] hits = topDoc.scoreDocs;
- if ((hits != null) && (hits.length > 0))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- catch (IOException ioe)
- {
- throw new DictionaryException(ioe);
+ return metaDataHitSet;
+ }
+ catch (IOException ioe)
+ {
+ throw new DictionaryException(ioe);
+ }
+ }
+
+ public boolean contains(String str) throws DictionaryException
+ {
+ try
+ {
+ Query q = new TermQuery(new Term(iv_lookupFieldName, str));
+
+ TopDocs topDoc = iv_searcher.search(q, iv_maxHits);
+ ScoreDoc[] hits = topDoc.scoreDocs;
+ if ((hits != null) && (hits.length > 0))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ catch (IOException ioe)
+ {
+ throw new DictionaryException(ioe);
}
- }
-}
+ }
+}
Modified: incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/lucene/LuceneDocumentMetaDataHitImpl.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/dictionary/lucene/LuceneDocumentMetaDataHitImpl.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/lucene/LuceneDocumentMetaDataHitImpl.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/lucene/LuceneDocumentMetaDataHitImpl.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,62 +14,62 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package edu.mayo.bmi.dictionary.lucene;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashSet;
+package edu.mayo.bmi.dictionary.lucene;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
import java.util.List;
import java.util.ListIterator;
-import java.util.Set;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
+import java.util.Set;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
import org.apache.lucene.document.Fieldable;
-
-import edu.mayo.bmi.dictionary.BaseMetaDataHitImpl;
-import edu.mayo.bmi.dictionary.MetaDataHit;
-
-/**
- *
- * @author Mayo Clinic
- */
-public class LuceneDocumentMetaDataHitImpl extends BaseMetaDataHitImpl
- implements MetaDataHit
-{
- private Document iv_doc;
- private Set iv_nameSet = new HashSet();
- private Collection iv_valCol = new ArrayList();
-
- public LuceneDocumentMetaDataHitImpl(Document luceneDoc)
- {
- iv_doc = luceneDoc;
-
+
+import edu.mayo.bmi.dictionary.BaseMetaDataHitImpl;
+import edu.mayo.bmi.dictionary.MetaDataHit;
+
+/**
+ *
+ * @author Mayo Clinic
+ */
+public class LuceneDocumentMetaDataHitImpl extends BaseMetaDataHitImpl
+ implements MetaDataHit
+{
+ private Document iv_doc;
+ private Set iv_nameSet = new HashSet();
+ private Collection iv_valCol = new ArrayList();
+
+ public LuceneDocumentMetaDataHitImpl(Document luceneDoc)
+ {
+ iv_doc = luceneDoc;
+
List<Fieldable> fieldEnumList = iv_doc.getFields();
- ListIterator<Fieldable> fieldEnum = fieldEnumList.listIterator();
- while (fieldEnum.hasNext())
- {
- Field f = (Field) fieldEnum.next();
-
- iv_nameSet.add(f.name());
- iv_valCol.add(f.stringValue());
- }
- }
-
- public String getMetaFieldValue(String metaFieldName)
- {
- return iv_doc.get(metaFieldName);
- }
-
- public Set getMetaFieldNames()
- {
- return iv_nameSet;
- }
-
- public Collection getMetaFieldValues()
- {
- return iv_valCol;
- }
-}
\ No newline at end of file
+ ListIterator<Fieldable> fieldEnum = fieldEnumList.listIterator();
+ while (fieldEnum.hasNext())
+ {
+ Field f = (Field) fieldEnum.next();
+
+ iv_nameSet.add(f.name());
+ iv_valCol.add(f.stringValue());
+ }
+ }
+
+ public String getMetaFieldValue(String metaFieldName)
+ {
+ return iv_doc.get(metaFieldName);
+ }
+
+ public Set getMetaFieldNames()
+ {
+ return iv_nameSet;
+ }
+
+ public Collection getMetaFieldValues()
+ {
+ return iv_valCol;
+ }
+}
Modified: incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/strtable/FieldConstraint.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/dictionary/strtable/FieldConstraint.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/strtable/FieldConstraint.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/strtable/FieldConstraint.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.dictionary.strtable;
-
-/**
- * Defines when a row should NOT be added to a StringTable object. If a field
- * has a given value that meets criteria that has been implemented, then this
- * row will not be added.
- *
- * @author Mayo Clinic
- */
-public interface FieldConstraint
-{
- public boolean isConstrained(String fieldName, String fieldValue);
-}
\ No newline at end of file
+package edu.mayo.bmi.dictionary.strtable;
+
+/**
+ * Defines when a row should NOT be added to a StringTable object. If a field
+ * has a given value that meets criteria that has been implemented, then this
+ * row will not be added.
+ *
+ * @author Mayo Clinic
+ */
+public interface FieldConstraint
+{
+ public boolean isConstrained(String fieldName, String fieldValue);
+}
Modified: incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/strtable/FieldConstraintImpl.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/dictionary/strtable/FieldConstraintImpl.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/strtable/FieldConstraintImpl.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/strtable/FieldConstraintImpl.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,86 +14,86 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * Created on May 20, 2005
- *
- */
-package edu.mayo.bmi.dictionary.strtable;
-
-/**
- * @author Mayo Clinic
- *
- */
-public class FieldConstraintImpl implements FieldConstraint
-{
- public static final int EQ_OP = 0;
- public static final int LT_OP = 1;
- public static final int LTEQ_OP = 2;
- public static final int GT_OP = 3;
- public static final int GTEQ_OP = 4;
-
- private String iv_fieldName;
- private Object iv_fieldValue;
- private int iv_op;
- private Class iv_fieldValueClass;
-
- public FieldConstraintImpl(String fieldName, int op, String fieldValue,
- Class fieldValueClass)
- {
- iv_fieldName = fieldName;
- iv_op = op;
- iv_fieldValueClass = fieldValueClass;
- iv_fieldValue = convertFieldValue(fieldValue);
- }
-
- public boolean isConstrained(String fieldName, String fieldValue)
- {
- if (iv_fieldName.equals(fieldName))
- {
- Object curfieldValueObj = convertFieldValue(fieldValue);
-
- Comparable c1 = (Comparable) iv_fieldValue;
- Comparable c2 = (Comparable) curfieldValueObj;
-
- int comparison = c2.compareTo(c1);
-
- if ((comparison == 0)
- && ((iv_op == EQ_OP) || (iv_op == LTEQ_OP) || (iv_op == GTEQ_OP)))
- {
- return true;
- }
- else if ((comparison < 0)
- && ((iv_op == LT_OP) || (iv_op == LTEQ_OP)))
- {
- return true;
- }
- else if ((comparison > 0)
- && ((iv_op == GT_OP) || (iv_op == GTEQ_OP)))
- {
- return true;
- }
- }
-
- return false;
- }
-
- private Object convertFieldValue(String str)
- {
- if (iv_fieldValueClass.equals(Integer.class))
- {
- return new Integer(str);
- }
- else if (iv_fieldValueClass.equals(Float.class))
- {
- return new Float(str);
- }
- else if (iv_fieldValueClass.equals(Double.class))
- {
- return new Double(str);
- }
- else
- {
- return str;
- }
- }
-}
\ No newline at end of file
+/*
+ * Created on May 20, 2005
+ *
+ */
+package edu.mayo.bmi.dictionary.strtable;
+
+/**
+ * @author Mayo Clinic
+ *
+ */
+public class FieldConstraintImpl implements FieldConstraint
+{
+ public static final int EQ_OP = 0;
+ public static final int LT_OP = 1;
+ public static final int LTEQ_OP = 2;
+ public static final int GT_OP = 3;
+ public static final int GTEQ_OP = 4;
+
+ private String iv_fieldName;
+ private Object iv_fieldValue;
+ private int iv_op;
+ private Class iv_fieldValueClass;
+
+ public FieldConstraintImpl(String fieldName, int op, String fieldValue,
+ Class fieldValueClass)
+ {
+ iv_fieldName = fieldName;
+ iv_op = op;
+ iv_fieldValueClass = fieldValueClass;
+ iv_fieldValue = convertFieldValue(fieldValue);
+ }
+
+ public boolean isConstrained(String fieldName, String fieldValue)
+ {
+ if (iv_fieldName.equals(fieldName))
+ {
+ Object curfieldValueObj = convertFieldValue(fieldValue);
+
+ Comparable c1 = (Comparable) iv_fieldValue;
+ Comparable c2 = (Comparable) curfieldValueObj;
+
+ int comparison = c2.compareTo(c1);
+
+ if ((comparison == 0)
+ && ((iv_op == EQ_OP) || (iv_op == LTEQ_OP) || (iv_op == GTEQ_OP)))
+ {
+ return true;
+ }
+ else if ((comparison < 0)
+ && ((iv_op == LT_OP) || (iv_op == LTEQ_OP)))
+ {
+ return true;
+ }
+ else if ((comparison > 0)
+ && ((iv_op == GT_OP) || (iv_op == GTEQ_OP)))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private Object convertFieldValue(String str)
+ {
+ if (iv_fieldValueClass.equals(Integer.class))
+ {
+ return new Integer(str);
+ }
+ else if (iv_fieldValueClass.equals(Float.class))
+ {
+ return new Float(str);
+ }
+ else if (iv_fieldValueClass.equals(Double.class))
+ {
+ return new Double(str);
+ }
+ else
+ {
+ return str;
+ }
+ }
+}
Modified: incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/strtable/StringTable.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/dictionary/strtable/StringTable.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/strtable/StringTable.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/strtable/StringTable.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,90 +14,90 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package edu.mayo.bmi.dictionary.strtable;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- *
- * @author Mayo Clinic
- */
-public class StringTable
-{
- // key = indexed field name (String), value = VALUE MAP
- private Map iv_nameMap = new HashMap();
-
- // ROW MAP
- // key = indexed field value (String), value = set of StringTableRows
-
- public StringTable(String[] indexedFieldNames)
- {
- for (int i = 0; i < indexedFieldNames.length; i++)
- {
- iv_nameMap.put(indexedFieldNames[i], new HashMap());
- }
- }
-
- public void addRow(StringTableRow strTableRow)
- {
- Iterator indexedFieldNameItr = iv_nameMap.keySet().iterator();
- while (indexedFieldNameItr.hasNext())
- {
- String indexedFieldName = (String) indexedFieldNameItr.next();
- Map valueMap = (Map) iv_nameMap.get(indexedFieldName);
-
- String indexedFieldValue =
- strTableRow.getFieldValue(indexedFieldName);
- Set rowSet = (Set) valueMap.get(indexedFieldValue);
- if (rowSet == null)
- {
- rowSet = new HashSet();
- }
- rowSet.add(strTableRow);
-
- valueMap.put(indexedFieldValue, rowSet);
- }
- }
-
- public StringTableRow[] getRows(String indexedFieldName, String fieldVal)
- {
- Map valueMap = (Map) iv_nameMap.get(indexedFieldName);
- Set rowSet = (Set) valueMap.get(fieldVal);
- if (rowSet != null)
- {
- return (StringTableRow[]) rowSet.toArray(
- new StringTableRow[rowSet.size()]);
- }
- else
- {
- return new StringTableRow[0];
- }
- }
-
- public StringTableRow[] getAllRows()
- {
- Collection col = new HashSet();
- Iterator valueMapItr = iv_nameMap.values().iterator();
- while (valueMapItr.hasNext())
- {
- Map valueMap = (Map)valueMapItr.next();
- Iterator valueItr = valueMap.values().iterator();
- while (valueItr.hasNext())
- {
- Set rowSet = (Set)valueItr.next();
- if (rowSet.size() > 0)
- {
- col.addAll(rowSet);
- }
- }
- }
-
- return (StringTableRow[]) col.toArray(
- new StringTableRow[col.size()]);
- }
-}
+package edu.mayo.bmi.dictionary.strtable;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ *
+ * @author Mayo Clinic
+ */
+public class StringTable
+{
+ // key = indexed field name (String), value = VALUE MAP
+ private Map iv_nameMap = new HashMap();
+
+ // ROW MAP
+ // key = indexed field value (String), value = set of StringTableRows
+
+ public StringTable(String[] indexedFieldNames)
+ {
+ for (int i = 0; i < indexedFieldNames.length; i++)
+ {
+ iv_nameMap.put(indexedFieldNames[i], new HashMap());
+ }
+ }
+
+ public void addRow(StringTableRow strTableRow)
+ {
+ Iterator indexedFieldNameItr = iv_nameMap.keySet().iterator();
+ while (indexedFieldNameItr.hasNext())
+ {
+ String indexedFieldName = (String) indexedFieldNameItr.next();
+ Map valueMap = (Map) iv_nameMap.get(indexedFieldName);
+
+ String indexedFieldValue =
+ strTableRow.getFieldValue(indexedFieldName);
+ Set rowSet = (Set) valueMap.get(indexedFieldValue);
+ if (rowSet == null)
+ {
+ rowSet = new HashSet();
+ }
+ rowSet.add(strTableRow);
+
+ valueMap.put(indexedFieldValue, rowSet);
+ }
+ }
+
+ public StringTableRow[] getRows(String indexedFieldName, String fieldVal)
+ {
+ Map valueMap = (Map) iv_nameMap.get(indexedFieldName);
+ Set rowSet = (Set) valueMap.get(fieldVal);
+ if (rowSet != null)
+ {
+ return (StringTableRow[]) rowSet.toArray(
+ new StringTableRow[rowSet.size()]);
+ }
+ else
+ {
+ return new StringTableRow[0];
+ }
+ }
+
+ public StringTableRow[] getAllRows()
+ {
+ Collection col = new HashSet();
+ Iterator valueMapItr = iv_nameMap.values().iterator();
+ while (valueMapItr.hasNext())
+ {
+ Map valueMap = (Map)valueMapItr.next();
+ Iterator valueItr = valueMap.values().iterator();
+ while (valueItr.hasNext())
+ {
+ Set rowSet = (Set)valueItr.next();
+ if (rowSet.size() > 0)
+ {
+ col.addAll(rowSet);
+ }
+ }
+ }
+
+ return (StringTableRow[]) col.toArray(
+ new StringTableRow[col.size()]);
+ }
+}
Modified: incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/strtable/StringTableDictionaryImpl.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/dictionary/strtable/StringTableDictionaryImpl.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/strtable/StringTableDictionaryImpl.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/strtable/StringTableDictionaryImpl.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.
*/
-package edu.mayo.bmi.dictionary.strtable;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import edu.mayo.bmi.dictionary.BaseDictionaryImpl;
-import edu.mayo.bmi.dictionary.Dictionary;
-import edu.mayo.bmi.dictionary.DictionaryException;
-import edu.mayo.bmi.dictionary.MetaDataHit;
-
-/**
- *
- * @author Mayo Clinic
- */
-public class StringTableDictionaryImpl
- extends BaseDictionaryImpl
- implements Dictionary
-{
- private StringTable iv_strTable;
- private String iv_lookupFieldName;
-
- public StringTableDictionaryImpl(
- StringTable strTable,
- String lookupFieldName)
- {
- iv_strTable = strTable;
- iv_lookupFieldName = lookupFieldName;
- }
-
- public boolean contains(String text) throws DictionaryException
- {
- if (iv_strTable.getRows(iv_lookupFieldName, text).length > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
- public Collection getEntries(String str) throws DictionaryException
- {
- Set metaDataHitSet = new HashSet();
- StringTableRow[] strTableRows =
- iv_strTable.getRows(iv_lookupFieldName, str);
- for (int i = 0; i < strTableRows.length; i++)
- {
- MetaDataHit mdh =
- new StringTableRowMetaDataHitImpl(strTableRows[i]);
- metaDataHitSet.add(mdh);
- }
-
- return metaDataHitSet;
- }
-
-}
+package edu.mayo.bmi.dictionary.strtable;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import edu.mayo.bmi.dictionary.BaseDictionaryImpl;
+import edu.mayo.bmi.dictionary.Dictionary;
+import edu.mayo.bmi.dictionary.DictionaryException;
+import edu.mayo.bmi.dictionary.MetaDataHit;
+
+/**
+ *
+ * @author Mayo Clinic
+ */
+public class StringTableDictionaryImpl
+ extends BaseDictionaryImpl
+ implements Dictionary
+{
+ private StringTable iv_strTable;
+ private String iv_lookupFieldName;
+
+ public StringTableDictionaryImpl(
+ StringTable strTable,
+ String lookupFieldName)
+ {
+ iv_strTable = strTable;
+ iv_lookupFieldName = lookupFieldName;
+ }
+
+ public boolean contains(String text) throws DictionaryException
+ {
+ if (iv_strTable.getRows(iv_lookupFieldName, text).length > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public Collection getEntries(String str) throws DictionaryException
+ {
+ Set metaDataHitSet = new HashSet();
+ StringTableRow[] strTableRows =
+ iv_strTable.getRows(iv_lookupFieldName, str);
+ for (int i = 0; i < strTableRows.length; i++)
+ {
+ MetaDataHit mdh =
+ new StringTableRowMetaDataHitImpl(strTableRows[i]);
+ metaDataHitSet.add(mdh);
+ }
+
+ return metaDataHitSet;
+ }
+
+}
Modified: incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/strtable/StringTableFactory.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/dictionary/strtable/StringTableFactory.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/strtable/StringTableFactory.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/strtable/StringTableFactory.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,132 +14,132 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package edu.mayo.bmi.dictionary.strtable;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.util.StringTokenizer;
-
-/**
- *
- * @author Mayo Clinic
- */
-public class StringTableFactory
-{
- /**
- * Reads from a character stream. Each line is treated as row in the
- * StringTable.
- *
- * @param charReader
- * @param delimiter
- * @return
- * @throws IOException
- */
- public static StringTable build(
- Reader charReader,
- String delimiter,
- String indexedFieldName,
- boolean ignoreCase) throws IOException
- {
- return build(charReader, delimiter, indexedFieldName, null, ignoreCase);
- }
-
- /**
- * Reads from a character stream. Each line is treated as row in the
- * StringTable.
- *
- * @param charReader
- * @param delimiter
- * @return
- * @throws IOException
- */
- public static StringTable build(
- Reader charReader,
- String delimiter,
- String indexedFieldName,
- FieldConstraint constraint,
- boolean ignoreCase) throws IOException
- {
- String[] indexedFieldNames = new String[1];
- indexedFieldNames[0] = indexedFieldName;
- return build(
- charReader,
- delimiter,
- indexedFieldNames,
- constraint,
- ignoreCase);
- }
-
- /**
- * Reads from a character stream. Each line is treated as row in the
- * StringTable.
- *
- * @param charReader
- * @param delimiter
- * @return
- * @throws IOException
- */
- public static StringTable build(
- Reader charReader,
- String delimiter,
- String[] indexedFieldNames,
- boolean ignoreCase) throws IOException
- {
- return build(charReader, delimiter, indexedFieldNames, null, ignoreCase);
- }
-
- /**
- * Reads from a character stream. Each line is treated as row in the
- * StringTable.
- *
- * @param charReader
- * @param delimiter
- * @return
- * @throws IOException
- */
- public static StringTable build(
- Reader charReader,
- String delimiter,
- String[] indexedFieldNames,
- FieldConstraint constraint,
- boolean ignoreCase) throws IOException
- {
- StringTable strTable = new StringTable(indexedFieldNames);
- BufferedReader br = new BufferedReader(charReader);
- String line = br.readLine();
- while (line != null)
- {
- StringTableRow strTableRow = new StringTableRow();
- StringTokenizer st = new StringTokenizer(line, delimiter);
- int fieldCnt = 0;
- boolean isConstrained = false;
- while (st.hasMoreTokens())
- {
- String fieldName = String.valueOf(fieldCnt);
- String fieldValue = st.nextToken();
- if (ignoreCase)
- {
- fieldValue = fieldValue.toLowerCase();
- }
- strTableRow.addField(fieldName, fieldValue);
- fieldCnt++;
-
- if ((constraint != null)
- && constraint.isConstrained(fieldName, fieldValue))
- {
- isConstrained = true;
- }
- }
-
- if (!isConstrained)
- {
- strTable.addRow(strTableRow);
- }
- line = br.readLine();
- }
- br.close();
-
- return strTable;
- }
-}
\ No newline at end of file
+package edu.mayo.bmi.dictionary.strtable;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.StringTokenizer;
+
+/**
+ *
+ * @author Mayo Clinic
+ */
+public class StringTableFactory
+{
+ /**
+ * Reads from a character stream. Each line is treated as row in the
+ * StringTable.
+ *
+ * @param charReader
+ * @param delimiter
+ * @return
+ * @throws IOException
+ */
+ public static StringTable build(
+ Reader charReader,
+ String delimiter,
+ String indexedFieldName,
+ boolean ignoreCase) throws IOException
+ {
+ return build(charReader, delimiter, indexedFieldName, null, ignoreCase);
+ }
+
+ /**
+ * Reads from a character stream. Each line is treated as row in the
+ * StringTable.
+ *
+ * @param charReader
+ * @param delimiter
+ * @return
+ * @throws IOException
+ */
+ public static StringTable build(
+ Reader charReader,
+ String delimiter,
+ String indexedFieldName,
+ FieldConstraint constraint,
+ boolean ignoreCase) throws IOException
+ {
+ String[] indexedFieldNames = new String[1];
+ indexedFieldNames[0] = indexedFieldName;
+ return build(
+ charReader,
+ delimiter,
+ indexedFieldNames,
+ constraint,
+ ignoreCase);
+ }
+
+ /**
+ * Reads from a character stream. Each line is treated as row in the
+ * StringTable.
+ *
+ * @param charReader
+ * @param delimiter
+ * @return
+ * @throws IOException
+ */
+ public static StringTable build(
+ Reader charReader,
+ String delimiter,
+ String[] indexedFieldNames,
+ boolean ignoreCase) throws IOException
+ {
+ return build(charReader, delimiter, indexedFieldNames, null, ignoreCase);
+ }
+
+ /**
+ * Reads from a character stream. Each line is treated as row in the
+ * StringTable.
+ *
+ * @param charReader
+ * @param delimiter
+ * @return
+ * @throws IOException
+ */
+ public static StringTable build(
+ Reader charReader,
+ String delimiter,
+ String[] indexedFieldNames,
+ FieldConstraint constraint,
+ boolean ignoreCase) throws IOException
+ {
+ StringTable strTable = new StringTable(indexedFieldNames);
+ BufferedReader br = new BufferedReader(charReader);
+ String line = br.readLine();
+ while (line != null)
+ {
+ StringTableRow strTableRow = new StringTableRow();
+ StringTokenizer st = new StringTokenizer(line, delimiter);
+ int fieldCnt = 0;
+ boolean isConstrained = false;
+ while (st.hasMoreTokens())
+ {
+ String fieldName = String.valueOf(fieldCnt);
+ String fieldValue = st.nextToken();
+ if (ignoreCase)
+ {
+ fieldValue = fieldValue.toLowerCase();
+ }
+ strTableRow.addField(fieldName, fieldValue);
+ fieldCnt++;
+
+ if ((constraint != null)
+ && constraint.isConstrained(fieldName, fieldValue))
+ {
+ isConstrained = true;
+ }
+ }
+
+ if (!isConstrained)
+ {
+ strTable.addRow(strTableRow);
+ }
+ line = br.readLine();
+ }
+ br.close();
+
+ return strTable;
+ }
+}
Modified: incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/strtable/StringTableRow.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/dictionary/strtable/StringTableRow.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/strtable/StringTableRow.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/strtable/StringTableRow.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,38 +14,38 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package edu.mayo.bmi.dictionary.strtable;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- *
- * @author Mayo Clinic
- */
-public class StringTableRow
-{
- private Map iv_fieldMap = new HashMap();
-
- public Set getNames()
- {
- return iv_fieldMap.keySet();
- }
-
- public Collection getValues()
- {
- return iv_fieldMap.values();
- }
-
- public void addField(String fieldName, String fieldValue)
- {
- iv_fieldMap.put(fieldName, fieldValue);
- }
-
- public String getFieldValue(String fieldName)
- {
- return (String) iv_fieldMap.get(fieldName);
- }
-}
+package edu.mayo.bmi.dictionary.strtable;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ *
+ * @author Mayo Clinic
+ */
+public class StringTableRow
+{
+ private Map iv_fieldMap = new HashMap();
+
+ public Set getNames()
+ {
+ return iv_fieldMap.keySet();
+ }
+
+ public Collection getValues()
+ {
+ return iv_fieldMap.values();
+ }
+
+ public void addField(String fieldName, String fieldValue)
+ {
+ iv_fieldMap.put(fieldName, fieldValue);
+ }
+
+ public String getFieldValue(String fieldName)
+ {
+ return (String) iv_fieldMap.get(fieldName);
+ }
+}
Modified: incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/strtable/StringTableRowMetaDataHitImpl.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/dictionary/strtable/StringTableRowMetaDataHitImpl.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/strtable/StringTableRowMetaDataHitImpl.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/dictionary/strtable/StringTableRowMetaDataHitImpl.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,40 +14,40 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package edu.mayo.bmi.dictionary.strtable;
-
-import java.util.Collection;
-import java.util.Set;
-
-import edu.mayo.bmi.dictionary.BaseMetaDataHitImpl;
-import edu.mayo.bmi.dictionary.MetaDataHit;
-
-/**
- *
- * @author Mayo Clinic
- */
-public class StringTableRowMetaDataHitImpl extends BaseMetaDataHitImpl
- implements MetaDataHit
-{
- private StringTableRow iv_strTableRow;
-
- public StringTableRowMetaDataHitImpl(StringTableRow strTableRow)
- {
- iv_strTableRow = strTableRow;
- }
-
- public String getMetaFieldValue(String metaFieldName)
- {
- return iv_strTableRow.getFieldValue(metaFieldName);
- }
-
- public Set getMetaFieldNames()
- {
- return iv_strTableRow.getNames();
- }
-
- public Collection getMetaFieldValues()
- {
- return iv_strTableRow.getValues();
- }
-}
\ No newline at end of file
+package edu.mayo.bmi.dictionary.strtable;
+
+import java.util.Collection;
+import java.util.Set;
+
+import edu.mayo.bmi.dictionary.BaseMetaDataHitImpl;
+import edu.mayo.bmi.dictionary.MetaDataHit;
+
+/**
+ *
+ * @author Mayo Clinic
+ */
+public class StringTableRowMetaDataHitImpl extends BaseMetaDataHitImpl
+ implements MetaDataHit
+{
+ private StringTableRow iv_strTableRow;
+
+ public StringTableRowMetaDataHitImpl(StringTableRow strTableRow)
+ {
+ iv_strTableRow = strTableRow;
+ }
+
+ public String getMetaFieldValue(String metaFieldName)
+ {
+ return iv_strTableRow.getFieldValue(metaFieldName);
+ }
+
+ public Set getMetaFieldNames()
+ {
+ return iv_strTableRow.getNames();
+ }
+
+ public Collection getMetaFieldValues()
+ {
+ return iv_strTableRow.getValues();
+ }
+}
Modified: incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/lookup/algorithms/DirectPassThroughImpl.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/dictionary%20lookup/src/edu/mayo/bmi/lookup/algorithms/DirectPassThroughImpl.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/lookup/algorithms/DirectPassThroughImpl.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/dictionary lookup/src/edu/mayo/bmi/lookup/algorithms/DirectPassThroughImpl.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,82 +14,82 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package edu.mayo.bmi.lookup.algorithms;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import edu.mayo.bmi.dictionary.DictionaryEngine;
-import edu.mayo.bmi.dictionary.MetaDataHit;
-import edu.mayo.bmi.lookup.phrasebuilder.PhraseBuilder;
-import edu.mayo.bmi.lookup.vo.LookupHit;
-import edu.mayo.bmi.lookup.vo.LookupToken;
-
-/**
- * Each individual LookupToken is referenced against a Dictionary.
- *
- * @author Mayo Clinic
- */
-public class DirectPassThroughImpl implements LookupAlgorithm
-{
- private DictionaryEngine iv_dictEngine;
- private PhraseBuilder iv_phrBuilder;
-
- /**
- * Constructor
- * @param dictEngine
- * @param phraseBuilder
- */
- public DirectPassThroughImpl(DictionaryEngine dictEngine,
- PhraseBuilder phraseBuilder)
- {
- iv_dictEngine = dictEngine;
- iv_phrBuilder = phraseBuilder;
- }
-
- public Collection lookup(List ltList, Map ctxMap) throws Exception
- {
- List lhList = new ArrayList();
- for (int tokenIdx = 0; tokenIdx < ltList.size(); tokenIdx++)
- {
- LookupToken lt = (LookupToken) ltList.get(tokenIdx);
-
- List singleLtList = new ArrayList();
- singleLtList.add(lt);
-
- String[] strArr = iv_phrBuilder.getPhrases(singleLtList);
- Collection mdhCol = getHits(strArr);
-
- if ((mdhCol != null) && (mdhCol.size() > 0))
- {
- Iterator mdhMatchItr = mdhCol.iterator();
- while (mdhMatchItr.hasNext())
- {
- MetaDataHit mdh = (MetaDataHit) mdhMatchItr.next();
- LookupHit lh = new LookupHit(mdh, lt.getStartOffset(), lt
- .getEndOffset());
- lhList.add(lh);
- }
- }
- }
- return lhList;
- }
-
- private Collection getHits(String[] phrases) throws Exception
- {
- Collection mdhCol = new ArrayList();
- for (int i = 0; i < phrases.length; i++)
- {
- Collection curMdhCol = iv_dictEngine.metaLookup(phrases[i]);
- if (curMdhCol.size() > 0)
- {
- mdhCol.addAll(curMdhCol);
- }
- }
- return mdhCol;
- }
-
-}
\ No newline at end of file
+package edu.mayo.bmi.lookup.algorithms;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import edu.mayo.bmi.dictionary.DictionaryEngine;
+import edu.mayo.bmi.dictionary.MetaDataHit;
+import edu.mayo.bmi.lookup.phrasebuilder.PhraseBuilder;
+import edu.mayo.bmi.lookup.vo.LookupHit;
+import edu.mayo.bmi.lookup.vo.LookupToken;
+
+/**
+ * Each individual LookupToken is referenced against a Dictionary.
+ *
+ * @author Mayo Clinic
+ */
+public class DirectPassThroughImpl implements LookupAlgorithm
+{
+ private DictionaryEngine iv_dictEngine;
+ private PhraseBuilder iv_phrBuilder;
+
+ /**
+ * Constructor
+ * @param dictEngine
+ * @param phraseBuilder
+ */
+ public DirectPassThroughImpl(DictionaryEngine dictEngine,
+ PhraseBuilder phraseBuilder)
+ {
+ iv_dictEngine = dictEngine;
+ iv_phrBuilder = phraseBuilder;
+ }
+
+ public Collection lookup(List ltList, Map ctxMap) throws Exception
+ {
+ List lhList = new ArrayList();
+ for (int tokenIdx = 0; tokenIdx < ltList.size(); tokenIdx++)
+ {
+ LookupToken lt = (LookupToken) ltList.get(tokenIdx);
+
+ List singleLtList = new ArrayList();
+ singleLtList.add(lt);
+
+ String[] strArr = iv_phrBuilder.getPhrases(singleLtList);
+ Collection mdhCol = getHits(strArr);
+
+ if ((mdhCol != null) && (mdhCol.size() > 0))
+ {
+ Iterator mdhMatchItr = mdhCol.iterator();
+ while (mdhMatchItr.hasNext())
+ {
+ MetaDataHit mdh = (MetaDataHit) mdhMatchItr.next();
+ LookupHit lh = new LookupHit(mdh, lt.getStartOffset(), lt
+ .getEndOffset());
+ lhList.add(lh);
+ }
+ }
+ }
+ return lhList;
+ }
+
+ private Collection getHits(String[] phrases) throws Exception
+ {
+ Collection mdhCol = new ArrayList();
+ for (int i = 0; i < phrases.length; i++)
+ {
+ Collection curMdhCol = iv_dictEngine.metaLookup(phrases[i]);
+ if (curMdhCol.size() > 0)
+ {
+ mdhCol.addAll(curMdhCol);
+ }
+ }
+ return mdhCol;
+ }
+
+}