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 [15/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/core/src/edu/mayo/bmi/uima/core/cr/JdbcCollectionReader.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/cr/JdbcCollectionReader.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/cr/JdbcCollectionReader.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/cr/JdbcCollectionReader.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,431 +14,431 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package edu.mayo.bmi.uima.core.cr;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-import java.sql.Clob;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.apache.log4j.Logger;
-
-import org.apache.uima.cas.CAS;
-import org.apache.uima.collection.CollectionException;
-import org.apache.uima.collection.CollectionReader_ImplBase;
-import org.apache.uima.resource.ResourceInitializationException;
-import org.apache.uima.util.Progress;
-import org.apache.uima.util.ProgressImpl;
-
-import edu.mayo.bmi.uima.core.resource.FileResource;
-import edu.mayo.bmi.uima.core.resource.JdbcConnectionResource;
-import edu.mayo.bmi.uima.core.type.structured.DocumentID;
-
-/**
- * Collection Reader that pulls documents to be processed from a database.
- *
- * @author Mayo Clinic
- */
-public class JdbcCollectionReader extends CollectionReader_ImplBase
-{
-
- // LOG4J logger based on class name
- private Logger logger = Logger.getLogger(getClass().getName());
-
- /**
- * SQL statement to retrieve the document.
- */
- public static final String PARAM_SQL = "SqlStatement";
-
- /**
- * Name of column from resultset that contains the document text. Supported
- * column types are CHAR, VARCHAR, and CLOB.
- */
- public static final String PARAM_DOCTEXT_COL = "DocTextColName";
-
- /**
- * Name of external resource for database connection.
- */
- public static final String PARAM_DB_CONN_RESRC = "DbConnResrcName";
-
- /**
- * Optional parameter. Specifies column names that will be used to form a
- * document ID.
- */
- public static final String PARAM_DOCID_COLS = "DocIdColNames";
-
- /**
- * Optional parameter. Specifies delimiter used when document ID is built.
- */
- public static final String PARAM_DOCID_DELIMITER = "DocIdDelimiter";
-
- /**
- * Optional parameter. Name of external resource for prepared statement
- * value file. Each line of this file represents prepared statement values
- * that will be used to substitute for the "?" placeholders. TAB character
- * \t is used to delimit the values on a single line. The prepared statement
- * will be called once for each line in this file.
- */
- public static final String PARAM_VALUE_FILE_RESRC = "ValueFileResrcName";
-
- private PreparedStatement queryPrepStmt;
- private ResultSet rs;
-
- private String docTextColName;
- private int docColType;
- private String docColTypeName;
-
- // optional, will remain null if not set
- private String[] docIdColNames = null;
-
- // default is underscore
- private String docIdDelimiter = "_";
-
- private int totalRowCount = 0;
- private int currRowCount = 0;
-
- // optional, will remain null if not set
- // Array of List objects. Each List objects represents a list of prepared
- // stmt values.
- private List[] prepStmtValArr = null;
- private int prepStmtValArrIdx = 0;
- private boolean usePrepStmtVals = false;
-
- public void initialize() throws ResourceInitializationException
- {
- try
- {
- String sql = (String) getConfigParameterValue(PARAM_SQL);
- docTextColName = (String) getConfigParameterValue(PARAM_DOCTEXT_COL);
- String resrcName = (String) getConfigParameterValue(PARAM_DB_CONN_RESRC);
- JdbcConnectionResource resrc = (JdbcConnectionResource) getUimaContext().getResourceObject(resrcName);
-
- docIdColNames = (String[]) getConfigParameterValue(PARAM_DOCID_COLS);
- if (getConfigParameterValue(PARAM_DOCID_DELIMITER) != null)
- {
- docIdDelimiter = (String) getConfigParameterValue(PARAM_DOCID_DELIMITER);
- }
-
- Connection conn = resrc.getConnection();
- queryPrepStmt = conn.prepareStatement(sql);
-
- String fileResrcName = (String) getConfigParameterValue(PARAM_VALUE_FILE_RESRC);
- if ((fileResrcName != null) && (fileResrcName.trim().length() > 0))
- {
- FileResource fileResrc = (FileResource) getUimaContext().getResourceObject(fileResrcName);
- if (fileResrc != null)
- {
- loadValueFile(fileResrc.getFile());
- usePrepStmtVals = true;
- } else
- {
- throw new Exception("Failed to get " + fileResrcName
- + " from ResourceManager");
- }
- }
-
- totalRowCount = getRowCount(conn, sql);
- } catch (Exception e)
- {
- throw new ResourceInitializationException(e);
- }
- }
-
- /**
- * Loads the prepared statement value file.
- *
- * @param valueFile
- * @throws IOException
- */
- private void loadValueFile(File valueFile) throws IOException
- {
- List lineList = new ArrayList();
- BufferedReader br = new BufferedReader(new FileReader(valueFile));
- String line = br.readLine();
- while (line != null)
- {
- lineList.add(line);
- line = br.readLine();
- }
- br.close();
-
- prepStmtValArr = new List[lineList.size()];
- for (int i = 0; i < lineList.size(); i++)
- {
- String currLine = (String) lineList.get(i);
- List valList = new ArrayList();
- StringTokenizer st = new StringTokenizer(currLine, "\t");
- while (st.hasMoreTokens())
- {
- String token = st.nextToken().trim();
- valList.add(token);
- }
- prepStmtValArr[i] = valList;
- }
- logger.info("Loaded " + lineList.size() + " lines from value file: "
- + valueFile.getAbsolutePath());
- }
-
- /**
- * Slice up the query SQL and rebuild a SQL statement that gets a row count;
- *
- * @param querySql
- * @return
- */
- private int getRowCount(Connection conn, String querySql)
- throws SQLException
- {
- StringBuffer sb = new StringBuffer();
- sb.append("SELECT COUNT(*) ");
- int idx = querySql.indexOf("FROM");
- sb.append(querySql.subSequence(idx, querySql.length()));
- PreparedStatement cntStmt = conn.prepareStatement(sb.toString());
-
- if (usePrepStmtVals)
- {
- int totalCnt = 0;
- for (int i = 0; i < prepStmtValArr.length; i++)
- {
- List valList = prepStmtValArr[i];
- setPrepStmtValues(cntStmt, valList);
- ResultSet rs = cntStmt.executeQuery();
- rs.next();
- totalCnt += rs.getInt(1);
- }
- return totalCnt;
- } else
- {
- ResultSet rs = cntStmt.executeQuery();
- rs.next();
- return rs.getInt(1);
- }
- }
-
- /**
- * Helper method that sets the prepared statement values.
- *
- * @param prepStmt
- * @param valList
- */
- private void setPrepStmtValues(PreparedStatement prepStmt, List valList)
- throws SQLException
- {
- prepStmt.clearParameters();
- for (int i = 0; i < valList.size(); i++)
- {
- Object valObj = valList.get(i);
- prepStmt.setObject(i + 1, valObj);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.uima.collection.CollectionReader#getNext(org.apache.uima.cas.CAS)
- */
- public void getNext(CAS cas) throws IOException, CollectionException
- {
- currRowCount++;
- try
- {
- // pull doc text from resultset
- String document = null;
- if ((docColType == Types.CHAR)
- || (docColType == Types.VARCHAR))
- {
- document = rs.getString(docTextColName);
- } else if (docColType == Types.CLOB)
- {
- document = convertToString(rs.getClob(docTextColName));
- } else
- {
- throw new Exception("Unsupported document text column type: "
- + docColTypeName);
- }
-
- try
- {
- // if there's a CAS Initializer, call it
- if (getCasInitializer() != null)
- {
- Reader reader = new StringReader(document);
- getCasInitializer().initializeCas(reader, cas);
- } else
- {
- // No CAS Initiliazer, so set document text ourselves.
- // put document in CAS (assume CAS)
- cas.getJCas().setDocumentText(document);
- }
-
- DocumentID docIdAnnot = new DocumentID(cas
- .getJCas());
- docIdAnnot.setDocumentID(getDocumentID(rs));
- docIdAnnot.addToIndexes();
-
- logger.info("Reading document with ID="
- + docIdAnnot.getDocumentID());
- } catch (Exception e)
- {
- logger.error("CasInitializer failed to process document: ");
- logger.error(document);
- throw e;
- }
- } catch (Exception e)
- {
- throw new CollectionException(e);
- }
- }
-
- /**
- * Builds a document ID from one or more pieces of query data. If the query
- * data is not specified, the current row # is used.
- *
- * @param rs
- * @return
- */
- private String getDocumentID(ResultSet rs) throws SQLException
- {
- if (docIdColNames != null)
- {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < docIdColNames.length; i++)
- {
- String val = rs.getObject(docIdColNames[i]).toString();
- sb.append(val);
- if (i != (docIdColNames.length - 1))
- {
- sb.append(docIdDelimiter);
- }
- }
- return sb.toString();
- } else
- {
- // default is to return row num
- return String.valueOf(currRowCount);
- }
- }
-
- /**
- * Loads the clob data into a String object.
- *
- * @param clob
- * @return
- * @throws SQLException
- * @throws IOException
- */
- private String convertToString(Clob clob) throws SQLException, IOException
- {
- StringBuffer sb = new StringBuffer();
- BufferedReader br = new BufferedReader(clob.getCharacterStream());
- String line = br.readLine();
- while (line != null)
- {
- sb.append(line);
- sb.append('\n');
- line = br.readLine();
- }
- br.close();
- return sb.toString();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.uima.collection.base_cpm.BaseCollectionReader#hasNext()
- */
- public boolean hasNext() throws IOException, CollectionException
- {
- try
- {
-
- if (rs == null)
- {
- if (usePrepStmtVals)
- {
- List valList = prepStmtValArr[prepStmtValArrIdx];
- setPrepStmtValues(queryPrepStmt, valList);
- prepStmtValArrIdx++;
- }
-
- rs = queryPrepStmt.executeQuery();
-
- // TODO only needs to be done once
- ResultSetMetaData rsMetaData = rs.getMetaData();
- int colIdx = rs.findColumn(docTextColName);
- docColType = rsMetaData.getColumnType(colIdx);
- docColTypeName = rsMetaData.getColumnTypeName(1);
- }
-
- boolean hasAnotherRow = rs.next();
- if (hasAnotherRow == false)
- {
- // it's important to close ResultSets as they can accumlate
- // in the JVM heap. Too many open result sets can inadvertently
- // cause the DB conn to be closed by the server.
- rs.close();
- }
-
- if (usePrepStmtVals)
- {
- if ((hasAnotherRow == false)
- && (prepStmtValArrIdx < prepStmtValArr.length))
- {
- // the results for the previous prepared statement execution
- // have been exhausted, so the statement needs to be
- // executed with the next set of values
-
- // reset the rs instance variable to NULL
- rs = null;
- // re-invoke the hasNext() method so the prepared
- // statement gets executed again with the next set of values
- return this.hasNext();
- }
- }
-
- return hasAnotherRow;
- } catch (Exception e)
- {
- throw new CollectionException(e);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.uima.collection.base_cpm.BaseCollectionReader#getProgress()
- */
- public Progress[] getProgress()
- {
- Progress p = new ProgressImpl(currRowCount, totalRowCount,
- Progress.ENTITIES);
- return new Progress[] { p };
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.uima.collection.base_cpm.BaseCollectionReader#close()
- */
- public void close() throws IOException
- {
- try
- {
- queryPrepStmt.close();
- } catch (Exception e)
- {
- throw new IOException(e.getMessage());
- }
- }
-}
\ No newline at end of file
+package edu.mayo.bmi.uima.core.cr;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.apache.log4j.Logger;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.collection.CollectionException;
+import org.apache.uima.collection.CollectionReader_ImplBase;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.apache.uima.util.Progress;
+import org.apache.uima.util.ProgressImpl;
+
+import edu.mayo.bmi.uima.core.resource.FileResource;
+import edu.mayo.bmi.uima.core.resource.JdbcConnectionResource;
+import edu.mayo.bmi.uima.core.type.structured.DocumentID;
+
+/**
+ * Collection Reader that pulls documents to be processed from a database.
+ *
+ * @author Mayo Clinic
+ */
+public class JdbcCollectionReader extends CollectionReader_ImplBase
+{
+
+ // LOG4J logger based on class name
+ private Logger logger = Logger.getLogger(getClass().getName());
+
+ /**
+ * SQL statement to retrieve the document.
+ */
+ public static final String PARAM_SQL = "SqlStatement";
+
+ /**
+ * Name of column from resultset that contains the document text. Supported
+ * column types are CHAR, VARCHAR, and CLOB.
+ */
+ public static final String PARAM_DOCTEXT_COL = "DocTextColName";
+
+ /**
+ * Name of external resource for database connection.
+ */
+ public static final String PARAM_DB_CONN_RESRC = "DbConnResrcName";
+
+ /**
+ * Optional parameter. Specifies column names that will be used to form a
+ * document ID.
+ */
+ public static final String PARAM_DOCID_COLS = "DocIdColNames";
+
+ /**
+ * Optional parameter. Specifies delimiter used when document ID is built.
+ */
+ public static final String PARAM_DOCID_DELIMITER = "DocIdDelimiter";
+
+ /**
+ * Optional parameter. Name of external resource for prepared statement
+ * value file. Each line of this file represents prepared statement values
+ * that will be used to substitute for the "?" placeholders. TAB character
+ * \t is used to delimit the values on a single line. The prepared statement
+ * will be called once for each line in this file.
+ */
+ public static final String PARAM_VALUE_FILE_RESRC = "ValueFileResrcName";
+
+ private PreparedStatement queryPrepStmt;
+ private ResultSet rs;
+
+ private String docTextColName;
+ private int docColType;
+ private String docColTypeName;
+
+ // optional, will remain null if not set
+ private String[] docIdColNames = null;
+
+ // default is underscore
+ private String docIdDelimiter = "_";
+
+ private int totalRowCount = 0;
+ private int currRowCount = 0;
+
+ // optional, will remain null if not set
+ // Array of List objects. Each List objects represents a list of prepared
+ // stmt values.
+ private List[] prepStmtValArr = null;
+ private int prepStmtValArrIdx = 0;
+ private boolean usePrepStmtVals = false;
+
+ public void initialize() throws ResourceInitializationException
+ {
+ try
+ {
+ String sql = (String) getConfigParameterValue(PARAM_SQL);
+ docTextColName = (String) getConfigParameterValue(PARAM_DOCTEXT_COL);
+ String resrcName = (String) getConfigParameterValue(PARAM_DB_CONN_RESRC);
+ JdbcConnectionResource resrc = (JdbcConnectionResource) getUimaContext().getResourceObject(resrcName);
+
+ docIdColNames = (String[]) getConfigParameterValue(PARAM_DOCID_COLS);
+ if (getConfigParameterValue(PARAM_DOCID_DELIMITER) != null)
+ {
+ docIdDelimiter = (String) getConfigParameterValue(PARAM_DOCID_DELIMITER);
+ }
+
+ Connection conn = resrc.getConnection();
+ queryPrepStmt = conn.prepareStatement(sql);
+
+ String fileResrcName = (String) getConfigParameterValue(PARAM_VALUE_FILE_RESRC);
+ if ((fileResrcName != null) && (fileResrcName.trim().length() > 0))
+ {
+ FileResource fileResrc = (FileResource) getUimaContext().getResourceObject(fileResrcName);
+ if (fileResrc != null)
+ {
+ loadValueFile(fileResrc.getFile());
+ usePrepStmtVals = true;
+ } else
+ {
+ throw new Exception("Failed to get " + fileResrcName
+ + " from ResourceManager");
+ }
+ }
+
+ totalRowCount = getRowCount(conn, sql);
+ } catch (Exception e)
+ {
+ throw new ResourceInitializationException(e);
+ }
+ }
+
+ /**
+ * Loads the prepared statement value file.
+ *
+ * @param valueFile
+ * @throws IOException
+ */
+ private void loadValueFile(File valueFile) throws IOException
+ {
+ List lineList = new ArrayList();
+ BufferedReader br = new BufferedReader(new FileReader(valueFile));
+ String line = br.readLine();
+ while (line != null)
+ {
+ lineList.add(line);
+ line = br.readLine();
+ }
+ br.close();
+
+ prepStmtValArr = new List[lineList.size()];
+ for (int i = 0; i < lineList.size(); i++)
+ {
+ String currLine = (String) lineList.get(i);
+ List valList = new ArrayList();
+ StringTokenizer st = new StringTokenizer(currLine, "\t");
+ while (st.hasMoreTokens())
+ {
+ String token = st.nextToken().trim();
+ valList.add(token);
+ }
+ prepStmtValArr[i] = valList;
+ }
+ logger.info("Loaded " + lineList.size() + " lines from value file: "
+ + valueFile.getAbsolutePath());
+ }
+
+ /**
+ * Slice up the query SQL and rebuild a SQL statement that gets a row count;
+ *
+ * @param querySql
+ * @return
+ */
+ private int getRowCount(Connection conn, String querySql)
+ throws SQLException
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append("SELECT COUNT(*) ");
+ int idx = querySql.indexOf("FROM");
+ sb.append(querySql.subSequence(idx, querySql.length()));
+ PreparedStatement cntStmt = conn.prepareStatement(sb.toString());
+
+ if (usePrepStmtVals)
+ {
+ int totalCnt = 0;
+ for (int i = 0; i < prepStmtValArr.length; i++)
+ {
+ List valList = prepStmtValArr[i];
+ setPrepStmtValues(cntStmt, valList);
+ ResultSet rs = cntStmt.executeQuery();
+ rs.next();
+ totalCnt += rs.getInt(1);
+ }
+ return totalCnt;
+ } else
+ {
+ ResultSet rs = cntStmt.executeQuery();
+ rs.next();
+ return rs.getInt(1);
+ }
+ }
+
+ /**
+ * Helper method that sets the prepared statement values.
+ *
+ * @param prepStmt
+ * @param valList
+ */
+ private void setPrepStmtValues(PreparedStatement prepStmt, List valList)
+ throws SQLException
+ {
+ prepStmt.clearParameters();
+ for (int i = 0; i < valList.size(); i++)
+ {
+ Object valObj = valList.get(i);
+ prepStmt.setObject(i + 1, valObj);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.collection.CollectionReader#getNext(org.apache.uima.cas.CAS)
+ */
+ public void getNext(CAS cas) throws IOException, CollectionException
+ {
+ currRowCount++;
+ try
+ {
+ // pull doc text from resultset
+ String document = null;
+ if ((docColType == Types.CHAR)
+ || (docColType == Types.VARCHAR))
+ {
+ document = rs.getString(docTextColName);
+ } else if (docColType == Types.CLOB)
+ {
+ document = convertToString(rs.getClob(docTextColName));
+ } else
+ {
+ throw new Exception("Unsupported document text column type: "
+ + docColTypeName);
+ }
+
+ try
+ {
+ // if there's a CAS Initializer, call it
+ if (getCasInitializer() != null)
+ {
+ Reader reader = new StringReader(document);
+ getCasInitializer().initializeCas(reader, cas);
+ } else
+ {
+ // No CAS Initiliazer, so set document text ourselves.
+ // put document in CAS (assume CAS)
+ cas.getJCas().setDocumentText(document);
+ }
+
+ DocumentID docIdAnnot = new DocumentID(cas
+ .getJCas());
+ docIdAnnot.setDocumentID(getDocumentID(rs));
+ docIdAnnot.addToIndexes();
+
+ logger.info("Reading document with ID="
+ + docIdAnnot.getDocumentID());
+ } catch (Exception e)
+ {
+ logger.error("CasInitializer failed to process document: ");
+ logger.error(document);
+ throw e;
+ }
+ } catch (Exception e)
+ {
+ throw new CollectionException(e);
+ }
+ }
+
+ /**
+ * Builds a document ID from one or more pieces of query data. If the query
+ * data is not specified, the current row # is used.
+ *
+ * @param rs
+ * @return
+ */
+ private String getDocumentID(ResultSet rs) throws SQLException
+ {
+ if (docIdColNames != null)
+ {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < docIdColNames.length; i++)
+ {
+ String val = rs.getObject(docIdColNames[i]).toString();
+ sb.append(val);
+ if (i != (docIdColNames.length - 1))
+ {
+ sb.append(docIdDelimiter);
+ }
+ }
+ return sb.toString();
+ } else
+ {
+ // default is to return row num
+ return String.valueOf(currRowCount);
+ }
+ }
+
+ /**
+ * Loads the clob data into a String object.
+ *
+ * @param clob
+ * @return
+ * @throws SQLException
+ * @throws IOException
+ */
+ private String convertToString(Clob clob) throws SQLException, IOException
+ {
+ StringBuffer sb = new StringBuffer();
+ BufferedReader br = new BufferedReader(clob.getCharacterStream());
+ String line = br.readLine();
+ while (line != null)
+ {
+ sb.append(line);
+ sb.append('\n');
+ line = br.readLine();
+ }
+ br.close();
+ return sb.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.collection.base_cpm.BaseCollectionReader#hasNext()
+ */
+ public boolean hasNext() throws IOException, CollectionException
+ {
+ try
+ {
+
+ if (rs == null)
+ {
+ if (usePrepStmtVals)
+ {
+ List valList = prepStmtValArr[prepStmtValArrIdx];
+ setPrepStmtValues(queryPrepStmt, valList);
+ prepStmtValArrIdx++;
+ }
+
+ rs = queryPrepStmt.executeQuery();
+
+ // TODO only needs to be done once
+ ResultSetMetaData rsMetaData = rs.getMetaData();
+ int colIdx = rs.findColumn(docTextColName);
+ docColType = rsMetaData.getColumnType(colIdx);
+ docColTypeName = rsMetaData.getColumnTypeName(1);
+ }
+
+ boolean hasAnotherRow = rs.next();
+ if (hasAnotherRow == false)
+ {
+ // it's important to close ResultSets as they can accumlate
+ // in the JVM heap. Too many open result sets can inadvertently
+ // cause the DB conn to be closed by the server.
+ rs.close();
+ }
+
+ if (usePrepStmtVals)
+ {
+ if ((hasAnotherRow == false)
+ && (prepStmtValArrIdx < prepStmtValArr.length))
+ {
+ // the results for the previous prepared statement execution
+ // have been exhausted, so the statement needs to be
+ // executed with the next set of values
+
+ // reset the rs instance variable to NULL
+ rs = null;
+ // re-invoke the hasNext() method so the prepared
+ // statement gets executed again with the next set of values
+ return this.hasNext();
+ }
+ }
+
+ return hasAnotherRow;
+ } catch (Exception e)
+ {
+ throw new CollectionException(e);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.collection.base_cpm.BaseCollectionReader#getProgress()
+ */
+ public Progress[] getProgress()
+ {
+ Progress p = new ProgressImpl(currRowCount, totalRowCount,
+ Progress.ENTITIES);
+ return new Progress[] { p };
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.uima.collection.base_cpm.BaseCollectionReader#close()
+ */
+ public void close() throws IOException
+ {
+ try
+ {
+ queryPrepStmt.close();
+ } catch (Exception e)
+ {
+ throw new IOException(e.getMessage());
+ }
+ }
+}
Modified: incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/cr/LinesFromFileCollectionReader.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/cr/LinesFromFileCollectionReader.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/cr/LinesFromFileCollectionReader.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/cr/LinesFromFileCollectionReader.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,215 +14,215 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package edu.mayo.bmi.uima.core.cr;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.uima.cas.CAS;
-import org.apache.uima.cas.CASException;
-import org.apache.uima.collection.CollectionException;
-import org.apache.uima.collection.CollectionReader_ImplBase;
-import org.apache.uima.jcas.JCas;
-//import org.apache.uima.jcas.tcas.DocumentAnnotation;
-import org.apache.uima.resource.ResourceInitializationException;
-import org.apache.uima.util.Progress;
-import org.apache.uima.util.ProgressImpl;
-
-import edu.mayo.bmi.uima.core.type.structured.DocumentID;
-
-/**
- *
- * The original code was copied from org.apache.uima.examples.cpe.FileSystemCollectionReader
- * and modified for Mayo use.
- *
- * This collection reader facilitates reading "documents" from a single file. Each
- * line in the document will be considered an entity to be analyzed by the CPE. That
- * is each line will be treated as a "document" and will have its own CAS.
- *
- * Extremely large files will require large memory resources as each line is read into
- * memory upon initialization. This was done to simplify implementation.
- *
- * @author Philip V. Ogren
- *
- */
-
-public class LinesFromFileCollectionReader extends CollectionReader_ImplBase {
-
- /**
- * This parameter will be used the descriptor file to specify the location of the
- * file that will be run through this collection reader.
- */
- public static final String PARAM_INPUT_FILE_NAME = "InputFileName";
- /**
- * Optional parameter specifies a comment string. Any line that begins with the string
- * will be ignored and not be added as a "document" to the CPE.
- */
- public static final String PARAM_COMMENT_STRING = "CommentString";
- /**
- * Optional parameter determines whether a blank line will be processed as a document or
- * will be ignored. The default will be set to 'true'.
- */
- public static final String PARAM_IGNORE_BLANK_LINES = "IgnoreBlankLines";
-
- /**
- * Name of optional configuration parameter that contains the language of
- * the documents in the input directory. If specified this information will
- * be added to the CAS.
- */
- public static final String PARAM_LANGUAGE = "Language";
-
- /**
- * Name of optional configuration parameter that specifies a character (or string) that delimits
- * the id of the document from the text of the document. For example, if the parameter is
- * set to '|' then the following line from a file:
- * <code>1234|this is some text</code>
- * would have an id of 1234 and text <code>this is some text</code>.
- * If this parameter is not set, then
- * the id of a document will be its line number in the file.
- */
-
- public static final String PARAM_ID_DELIMETER = "IdDelimeter";
-
- List iv_linesFromFile;
- int iv_currentIndex = 0;
- String iv_language;
- String iv_delimeter;
-
- private Logger iv_logger = Logger.getLogger(getClass().getName());
-
- public void initialize() throws ResourceInitializationException
- {
- BufferedReader fileReader = null;
- try
- {
- String fileLocation = (String) getConfigParameterValue(PARAM_INPUT_FILE_NAME);
- String commentSeq = (String)getConfigParameterValue(PARAM_COMMENT_STRING);
- iv_language = (String)getConfigParameterValue(PARAM_LANGUAGE);
- Boolean paramValue = (Boolean)getConfigParameterValue(PARAM_IGNORE_BLANK_LINES);
- boolean ignoreBlankLines = true;
- if(paramValue != null)
- {
- ignoreBlankLines = paramValue.booleanValue();
- }
- iv_delimeter = (String)getConfigParameterValue(PARAM_ID_DELIMETER);
-
- iv_linesFromFile = new ArrayList();
- fileReader = new BufferedReader(new FileReader(fileLocation));
- String line;
- while((line = fileReader.readLine()) != null)
- {
- if(commentSeq != null)
- {
- if(line.startsWith(commentSeq)) continue;
- }
- if(ignoreBlankLines && line.trim().length() == 0) continue;
- iv_linesFromFile.add(line);
- }
- }
- catch(IOException fnfe)
- {
- throw new ResourceInitializationException(fnfe);
- }
- finally
- {
- if(fileReader != null)
- try { fileReader.close(); } catch(IOException ioe) {}
- }
- }
-
- public void getNext(CAS cas) throws IOException, CollectionException
- {
- JCas jcas;
- try
- {
- jcas = cas.getJCas();
-
- String line = (String) iv_linesFromFile.get(iv_currentIndex);
- int lineNumber = iv_currentIndex + 1;
- String id;
- String text;
- if(iv_delimeter != null)
- {
- int delimeterLoc = line.indexOf(iv_delimeter);
- if(delimeterLoc <= 0)
- throw new CollectionException(new Exception("Line in file number "+lineNumber+" is not well formatted. " +
- "\nIt should have the format:" +
- "\n<doc_id>"+iv_delimeter+"<doc_text>"));
- id = line.substring(0,delimeterLoc);
- text = line.substring(delimeterLoc+iv_delimeter.length());
- }
- else
- {
- id = Integer.toString(lineNumber); //id will one more than its index into iv_linesFromFile (iv_currentIndex has already been incremented)
- text = line;
- }
-
-
- iv_logger.debug("id="+id);
- iv_logger.debug("text="+text);
-
- //if there's a CAS Initializer, call it
- if (getCasInitializer() != null)
- {
- Reader reader = new StringReader(text);
- getCasInitializer().initializeCas(reader, cas);
- reader.close();
- }
- else //No CAS Initiliazer, so read file and set document text ourselves
- {
- jcas.setDocumentText(text);
- }
-
- //set language if it was explicitly specified as a configuration parameter
- if (iv_language != null)
- {
-// ((DocumentAnnotation)jcas.getDocumentAnnotationFs()).setLanguage(iv_language);
- }
-
-
- DocumentID documentIDAnnotation = new DocumentID(jcas);
- documentIDAnnotation.setDocumentID(id);
- documentIDAnnotation.addToIndexes();
-
- }
- catch (CASException e)
- {
- throw new CollectionException(e);
- }
- finally
- {
- iv_currentIndex++;
- }
-
- }
-
- public boolean hasNext() throws IOException, CollectionException
- {
- return iv_currentIndex < iv_linesFromFile.size();
- }
-
- public Progress[] getProgress() {
- return new Progress[]{
- new ProgressImpl(iv_currentIndex, iv_linesFromFile.size(),Progress.ENTITIES)};
- }
-
- /**
- * Gets the total number of documents that will be returned by this
- * collection reader.
- * @return the number of documents in the collection
- */
- public int getNumberOfDocuments()
- {
- return iv_linesFromFile.size();
- }
-
- public void close() throws IOException {}
-}
+package edu.mayo.bmi.uima.core.cr;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.CASException;
+import org.apache.uima.collection.CollectionException;
+import org.apache.uima.collection.CollectionReader_ImplBase;
+import org.apache.uima.jcas.JCas;
+//import org.apache.uima.jcas.tcas.DocumentAnnotation;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.apache.uima.util.Progress;
+import org.apache.uima.util.ProgressImpl;
+
+import edu.mayo.bmi.uima.core.type.structured.DocumentID;
+
+/**
+ *
+ * The original code was copied from org.apache.uima.examples.cpe.FileSystemCollectionReader
+ * and modified for Mayo use.
+ *
+ * This collection reader facilitates reading "documents" from a single file. Each
+ * line in the document will be considered an entity to be analyzed by the CPE. That
+ * is each line will be treated as a "document" and will have its own CAS.
+ *
+ * Extremely large files will require large memory resources as each line is read into
+ * memory upon initialization. This was done to simplify implementation.
+ *
+ * @author Philip V. Ogren
+ *
+ */
+
+public class LinesFromFileCollectionReader extends CollectionReader_ImplBase {
+
+ /**
+ * This parameter will be used the descriptor file to specify the location of the
+ * file that will be run through this collection reader.
+ */
+ public static final String PARAM_INPUT_FILE_NAME = "InputFileName";
+ /**
+ * Optional parameter specifies a comment string. Any line that begins with the string
+ * will be ignored and not be added as a "document" to the CPE.
+ */
+ public static final String PARAM_COMMENT_STRING = "CommentString";
+ /**
+ * Optional parameter determines whether a blank line will be processed as a document or
+ * will be ignored. The default will be set to 'true'.
+ */
+ public static final String PARAM_IGNORE_BLANK_LINES = "IgnoreBlankLines";
+
+ /**
+ * Name of optional configuration parameter that contains the language of
+ * the documents in the input directory. If specified this information will
+ * be added to the CAS.
+ */
+ public static final String PARAM_LANGUAGE = "Language";
+
+ /**
+ * Name of optional configuration parameter that specifies a character (or string) that delimits
+ * the id of the document from the text of the document. For example, if the parameter is
+ * set to '|' then the following line from a file:
+ * <code>1234|this is some text</code>
+ * would have an id of 1234 and text <code>this is some text</code>.
+ * If this parameter is not set, then
+ * the id of a document will be its line number in the file.
+ */
+
+ public static final String PARAM_ID_DELIMETER = "IdDelimeter";
+
+ List iv_linesFromFile;
+ int iv_currentIndex = 0;
+ String iv_language;
+ String iv_delimeter;
+
+ private Logger iv_logger = Logger.getLogger(getClass().getName());
+
+ public void initialize() throws ResourceInitializationException
+ {
+ BufferedReader fileReader = null;
+ try
+ {
+ String fileLocation = (String) getConfigParameterValue(PARAM_INPUT_FILE_NAME);
+ String commentSeq = (String)getConfigParameterValue(PARAM_COMMENT_STRING);
+ iv_language = (String)getConfigParameterValue(PARAM_LANGUAGE);
+ Boolean paramValue = (Boolean)getConfigParameterValue(PARAM_IGNORE_BLANK_LINES);
+ boolean ignoreBlankLines = true;
+ if(paramValue != null)
+ {
+ ignoreBlankLines = paramValue.booleanValue();
+ }
+ iv_delimeter = (String)getConfigParameterValue(PARAM_ID_DELIMETER);
+
+ iv_linesFromFile = new ArrayList();
+ fileReader = new BufferedReader(new FileReader(fileLocation));
+ String line;
+ while((line = fileReader.readLine()) != null)
+ {
+ if(commentSeq != null)
+ {
+ if(line.startsWith(commentSeq)) continue;
+ }
+ if(ignoreBlankLines && line.trim().length() == 0) continue;
+ iv_linesFromFile.add(line);
+ }
+ }
+ catch(IOException fnfe)
+ {
+ throw new ResourceInitializationException(fnfe);
+ }
+ finally
+ {
+ if(fileReader != null)
+ try { fileReader.close(); } catch(IOException ioe) {}
+ }
+ }
+
+ public void getNext(CAS cas) throws IOException, CollectionException
+ {
+ JCas jcas;
+ try
+ {
+ jcas = cas.getJCas();
+
+ String line = (String) iv_linesFromFile.get(iv_currentIndex);
+ int lineNumber = iv_currentIndex + 1;
+ String id;
+ String text;
+ if(iv_delimeter != null)
+ {
+ int delimeterLoc = line.indexOf(iv_delimeter);
+ if(delimeterLoc <= 0)
+ throw new CollectionException(new Exception("Line in file number "+lineNumber+" is not well formatted. " +
+ "\nIt should have the format:" +
+ "\n<doc_id>"+iv_delimeter+"<doc_text>"));
+ id = line.substring(0,delimeterLoc);
+ text = line.substring(delimeterLoc+iv_delimeter.length());
+ }
+ else
+ {
+ id = Integer.toString(lineNumber); //id will one more than its index into iv_linesFromFile (iv_currentIndex has already been incremented)
+ text = line;
+ }
+
+
+ iv_logger.debug("id="+id);
+ iv_logger.debug("text="+text);
+
+ //if there's a CAS Initializer, call it
+ if (getCasInitializer() != null)
+ {
+ Reader reader = new StringReader(text);
+ getCasInitializer().initializeCas(reader, cas);
+ reader.close();
+ }
+ else //No CAS Initiliazer, so read file and set document text ourselves
+ {
+ jcas.setDocumentText(text);
+ }
+
+ //set language if it was explicitly specified as a configuration parameter
+ if (iv_language != null)
+ {
+// ((DocumentAnnotation)jcas.getDocumentAnnotationFs()).setLanguage(iv_language);
+ }
+
+
+ DocumentID documentIDAnnotation = new DocumentID(jcas);
+ documentIDAnnotation.setDocumentID(id);
+ documentIDAnnotation.addToIndexes();
+
+ }
+ catch (CASException e)
+ {
+ throw new CollectionException(e);
+ }
+ finally
+ {
+ iv_currentIndex++;
+ }
+
+ }
+
+ public boolean hasNext() throws IOException, CollectionException
+ {
+ return iv_currentIndex < iv_linesFromFile.size();
+ }
+
+ public Progress[] getProgress() {
+ return new Progress[]{
+ new ProgressImpl(iv_currentIndex, iv_linesFromFile.size(),Progress.ENTITIES)};
+ }
+
+ /**
+ * Gets the total number of documents that will be returned by this
+ * collection reader.
+ * @return the number of documents in the collection
+ */
+ public int getNumberOfDocuments()
+ {
+ return iv_linesFromFile.size();
+ }
+
+ public void close() throws IOException {}
+}
Modified: incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/BaseTokenAdapter.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/BaseTokenAdapter.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/BaseTokenAdapter.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/BaseTokenAdapter.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.core.fsm.adapters;
-
-import org.apache.uima.jcas.tcas.Annotation;
-
-import edu.mayo.bmi.fsm.token.BaseToken;
-
-/**
- * Adapts JCas token annotation to interface expected by the Context Dependent
- * Tokenizer.
- *
- * @author Mayo Clinic
- *
- */
-public class BaseTokenAdapter implements BaseToken
-{
- private Annotation iv_annot;
-
- public BaseTokenAdapter(Annotation annot)
- {
- iv_annot = annot;
- }
-
- public int getStartOffset()
- {
- return iv_annot.getBegin();
- }
-
- public int getEndOffset()
- {
- return iv_annot.getEnd();
- }
-}
+package edu.mayo.bmi.uima.core.fsm.adapters;
+
+import org.apache.uima.jcas.tcas.Annotation;
+
+import edu.mayo.bmi.fsm.token.BaseToken;
+
+/**
+ * Adapts JCas token annotation to interface expected by the Context Dependent
+ * Tokenizer.
+ *
+ * @author Mayo Clinic
+ *
+ */
+public class BaseTokenAdapter implements BaseToken
+{
+ private Annotation iv_annot;
+
+ public BaseTokenAdapter(Annotation annot)
+ {
+ iv_annot = annot;
+ }
+
+ public int getStartOffset()
+ {
+ return iv_annot.getBegin();
+ }
+
+ public int getEndOffset()
+ {
+ return iv_annot.getEnd();
+ }
+}
Modified: incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/CharacterTokenAdapter.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/CharacterTokenAdapter.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/CharacterTokenAdapter.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/CharacterTokenAdapter.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,31 +14,31 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package edu.mayo.bmi.uima.core.fsm.adapters;
-
-import edu.mayo.bmi.fsm.token.CharacterToken;
-import edu.mayo.bmi.uima.core.type.syntax.BaseToken;
-
-/**
- * Adapts JCas token annotation to interface expected by the Context Dependent
- * Tokenizer.
- *
- * @author Mayo Clinic
- *
- */
-public class CharacterTokenAdapter extends BaseTokenAdapter implements
- CharacterToken
-{
- private char iv_char;
-
- public CharacterTokenAdapter(BaseToken bta)
- {
- super(bta);
- iv_char = bta.getCoveredText().charAt(0);
- }
-
- public char getChar()
- {
- return iv_char;
- }
-}
+package edu.mayo.bmi.uima.core.fsm.adapters;
+
+import edu.mayo.bmi.fsm.token.CharacterToken;
+import edu.mayo.bmi.uima.core.type.syntax.BaseToken;
+
+/**
+ * Adapts JCas token annotation to interface expected by the Context Dependent
+ * Tokenizer.
+ *
+ * @author Mayo Clinic
+ *
+ */
+public class CharacterTokenAdapter extends BaseTokenAdapter implements
+ CharacterToken
+{
+ private char iv_char;
+
+ public CharacterTokenAdapter(BaseToken bta)
+ {
+ super(bta);
+ iv_char = bta.getCoveredText().charAt(0);
+ }
+
+ public char getChar()
+ {
+ return iv_char;
+ }
+}
Modified: incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/ContractionTokenAdapter.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/ContractionTokenAdapter.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/ContractionTokenAdapter.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/ContractionTokenAdapter.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,22 +14,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package edu.mayo.bmi.uima.core.fsm.adapters;
-
-import edu.mayo.bmi.fsm.token.ContractionToken;
-
-/**
- * Adapts JCas token annotation to interface expected by the Context Dependent
- * Tokenizer.
- *
- * @author Mayo Clinic
- *
- */
-public class ContractionTokenAdapter extends BaseTokenAdapter implements
- ContractionToken
-{
- public ContractionTokenAdapter(edu.mayo.bmi.uima.core.type.syntax.ContractionToken cta)
- {
- super(cta);
- }
-}
+package edu.mayo.bmi.uima.core.fsm.adapters;
+
+import edu.mayo.bmi.fsm.token.ContractionToken;
+
+/**
+ * Adapts JCas token annotation to interface expected by the Context Dependent
+ * Tokenizer.
+ *
+ * @author Mayo Clinic
+ *
+ */
+public class ContractionTokenAdapter extends BaseTokenAdapter implements
+ ContractionToken
+{
+ public ContractionTokenAdapter(edu.mayo.bmi.uima.core.type.syntax.ContractionToken cta)
+ {
+ super(cta);
+ }
+}
Modified: incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/DecimalTokenAdapter.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/DecimalTokenAdapter.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/DecimalTokenAdapter.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/DecimalTokenAdapter.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,32 +14,32 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package edu.mayo.bmi.uima.core.fsm.adapters;
-
-import edu.mayo.bmi.fsm.token.DecimalToken;
-import edu.mayo.bmi.uima.core.type.syntax.NumToken;
-
-/**
- * Adapts JCas token annotation to interface expected by the Context Dependent
- * Tokenizer.
- *
- * @author Mayo Clinic
- *
- */
-public class DecimalTokenAdapter extends NumberTokenAdapter implements
- DecimalToken
-{
- private double iv_val;
-
- public DecimalTokenAdapter(NumToken nta)
- {
- super(nta);
-
- iv_val = Double.parseDouble(removeCommas(nta.getCoveredText()));
- }
-
- public double getValue()
- {
- return iv_val;
- }
-}
+package edu.mayo.bmi.uima.core.fsm.adapters;
+
+import edu.mayo.bmi.fsm.token.DecimalToken;
+import edu.mayo.bmi.uima.core.type.syntax.NumToken;
+
+/**
+ * Adapts JCas token annotation to interface expected by the Context Dependent
+ * Tokenizer.
+ *
+ * @author Mayo Clinic
+ *
+ */
+public class DecimalTokenAdapter extends NumberTokenAdapter implements
+ DecimalToken
+{
+ private double iv_val;
+
+ public DecimalTokenAdapter(NumToken nta)
+ {
+ super(nta);
+
+ iv_val = Double.parseDouble(removeCommas(nta.getCoveredText()));
+ }
+
+ public double getValue()
+ {
+ return iv_val;
+ }
+}
Modified: incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/IntegerTokenAdapter.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/IntegerTokenAdapter.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/IntegerTokenAdapter.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/IntegerTokenAdapter.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,30 +14,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package edu.mayo.bmi.uima.core.fsm.adapters;
-
-import edu.mayo.bmi.fsm.token.IntegerToken;
-import edu.mayo.bmi.uima.core.type.syntax.NumToken;
-
-/**
- * Adapts JCas token annotation to interface expected by the Context Dependent
- * Tokenizer.
- *
- * @author Mayo Clinic
- *
- */
-public class IntegerTokenAdapter extends NumberTokenAdapter implements
- IntegerToken
-{
- private long iv_val;
+package edu.mayo.bmi.uima.core.fsm.adapters;
+
+import edu.mayo.bmi.fsm.token.IntegerToken;
+import edu.mayo.bmi.uima.core.type.syntax.NumToken;
+
+/**
+ * Adapts JCas token annotation to interface expected by the Context Dependent
+ * Tokenizer.
+ *
+ * @author Mayo Clinic
+ *
+ */
+public class IntegerTokenAdapter extends NumberTokenAdapter implements
+ IntegerToken
+{
+ private long iv_val;
private double iv_double;
static String negativeSign = "-";
-
- public IntegerTokenAdapter(NumToken nta)
- {
- super(nta);
-
+
+ public IntegerTokenAdapter(NumToken nta)
+ {
+ super(nta);
+
if (nta.getCoveredText().length() > 0) {
String numAsString = removeCommas(nta.getCoveredText());
@@ -72,11 +65,11 @@ public class IntegerTokenAdapter extends
iv_val = 0;
iv_double = 0;
}
- }
-
- public long getValue()
- {
- return iv_val;
+ }
+
+ public long getValue()
+ {
+ return iv_val;
}
/* If a string of numbers is too long to be represented by a long, then
@@ -87,5 +80,5 @@ public class IntegerTokenAdapter extends
return iv_double;
}
-
-}
+
+}
Modified: incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/NewlineTokenAdapter.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/NewlineTokenAdapter.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/NewlineTokenAdapter.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/NewlineTokenAdapter.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,23 +14,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package edu.mayo.bmi.uima.core.fsm.adapters;
-
-import edu.mayo.bmi.fsm.token.EolToken;
-import edu.mayo.bmi.uima.core.type.syntax.NewlineToken;
-
-/**
- * Adapts JCas token annotation to interface expected by the Context Dependent
- * Tokenizer.
- *
- * @author Mayo Clinic
- *
- */
-public class NewlineTokenAdapter extends CharacterTokenAdapter implements
- EolToken
-{
- public NewlineTokenAdapter(NewlineToken nta)
- {
- super(nta);
- }
-}
+package edu.mayo.bmi.uima.core.fsm.adapters;
+
+import edu.mayo.bmi.fsm.token.EolToken;
+import edu.mayo.bmi.uima.core.type.syntax.NewlineToken;
+
+/**
+ * Adapts JCas token annotation to interface expected by the Context Dependent
+ * Tokenizer.
+ *
+ * @author Mayo Clinic
+ *
+ */
+public class NewlineTokenAdapter extends CharacterTokenAdapter implements
+ EolToken
+{
+ public NewlineTokenAdapter(NewlineToken nta)
+ {
+ super(nta);
+ }
+}
Modified: incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/NumberTokenAdapter.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/NumberTokenAdapter.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/NumberTokenAdapter.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/NumberTokenAdapter.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,49 +14,49 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package edu.mayo.bmi.uima.core.fsm.adapters;
-
-import edu.mayo.bmi.fsm.token.NumberToken;
-import edu.mayo.bmi.uima.core.type.syntax.NumToken;
-
-/**
- * Adapts JCas token annotation to interface expected by the Context Dependent
- * Tokenizer.
- *
- * @author Mayo Clinic
- *
- */
-public class NumberTokenAdapter extends BaseTokenAdapter implements NumberToken
-{
- private boolean iv_isPositive = true;
-
- public NumberTokenAdapter(NumToken nta)
- {
- super(nta);
-
- if (nta.getCoveredText().length() > 0 && nta.getCoveredText().charAt(0) == '-')
- {
- iv_isPositive = false;
- }
- }
-
- public boolean getPositive()
- {
- return iv_isPositive;
- }
-
- protected String removeCommas(String str)
- {
- StringBuffer sb = new StringBuffer(str);
- for (int i = 0; i < sb.length(); i++)
- {
- char currentChar = sb.charAt(i);
- if (currentChar == ',')
- {
- sb.deleteCharAt(i);
- i--;
- }
- }
- return sb.toString();
- }
-}
+package edu.mayo.bmi.uima.core.fsm.adapters;
+
+import edu.mayo.bmi.fsm.token.NumberToken;
+import edu.mayo.bmi.uima.core.type.syntax.NumToken;
+
+/**
+ * Adapts JCas token annotation to interface expected by the Context Dependent
+ * Tokenizer.
+ *
+ * @author Mayo Clinic
+ *
+ */
+public class NumberTokenAdapter extends BaseTokenAdapter implements NumberToken
+{
+ private boolean iv_isPositive = true;
+
+ public NumberTokenAdapter(NumToken nta)
+ {
+ super(nta);
+
+ if (nta.getCoveredText().length() > 0 && nta.getCoveredText().charAt(0) == '-')
+ {
+ iv_isPositive = false;
+ }
+ }
+
+ public boolean getPositive()
+ {
+ return iv_isPositive;
+ }
+
+ protected String removeCommas(String str)
+ {
+ StringBuffer sb = new StringBuffer(str);
+ for (int i = 0; i < sb.length(); i++)
+ {
+ char currentChar = sb.charAt(i);
+ if (currentChar == ',')
+ {
+ sb.deleteCharAt(i);
+ i--;
+ }
+ }
+ return sb.toString();
+ }
+}
Modified: incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/PunctuationTokenAdapter.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/PunctuationTokenAdapter.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/PunctuationTokenAdapter.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/PunctuationTokenAdapter.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,22 +14,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package edu.mayo.bmi.uima.core.fsm.adapters;
-
-import edu.mayo.bmi.fsm.token.PunctuationToken;
-
-/**
- * Adapts JCas token annotation to interface expected by the Context Dependent
- * Tokenizer.
- *
- * @author Mayo Clinic
- *
- */
-public class PunctuationTokenAdapter extends CharacterTokenAdapter implements
- PunctuationToken
-{
- public PunctuationTokenAdapter(edu.mayo.bmi.uima.core.type.syntax.PunctuationToken pta)
- {
- super(pta);
- }
-}
+package edu.mayo.bmi.uima.core.fsm.adapters;
+
+import edu.mayo.bmi.fsm.token.PunctuationToken;
+
+/**
+ * Adapts JCas token annotation to interface expected by the Context Dependent
+ * Tokenizer.
+ *
+ * @author Mayo Clinic
+ *
+ */
+public class PunctuationTokenAdapter extends CharacterTokenAdapter implements
+ PunctuationToken
+{
+ public PunctuationTokenAdapter(edu.mayo.bmi.uima.core.type.syntax.PunctuationToken pta)
+ {
+ super(pta);
+ }
+}
Modified: incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/SymbolTokenAdapter.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/SymbolTokenAdapter.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/SymbolTokenAdapter.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/SymbolTokenAdapter.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,22 +14,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package edu.mayo.bmi.uima.core.fsm.adapters;
-
-import edu.mayo.bmi.fsm.token.SymbolToken;
-
-/**
- * Adapts JCas token annotation to interface expected by the Context Dependent
- * Tokenizer.
- *
- * @author Mayo Clinic
- *
- */
-public class SymbolTokenAdapter extends CharacterTokenAdapter implements
- SymbolToken
-{
- public SymbolTokenAdapter(edu.mayo.bmi.uima.core.type.syntax.SymbolToken sta)
- {
- super(sta);
- }
-}
+package edu.mayo.bmi.uima.core.fsm.adapters;
+
+import edu.mayo.bmi.fsm.token.SymbolToken;
+
+/**
+ * Adapts JCas token annotation to interface expected by the Context Dependent
+ * Tokenizer.
+ *
+ * @author Mayo Clinic
+ *
+ */
+public class SymbolTokenAdapter extends CharacterTokenAdapter implements
+ SymbolToken
+{
+ public SymbolTokenAdapter(edu.mayo.bmi.uima.core.type.syntax.SymbolToken sta)
+ {
+ super(sta);
+ }
+}
Modified: incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/TextTokenAdapter.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/TextTokenAdapter.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/TextTokenAdapter.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/TextTokenAdapter.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,32 +14,32 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package edu.mayo.bmi.uima.core.fsm.adapters;
-
-import org.apache.uima.jcas.tcas.Annotation;
-
-import edu.mayo.bmi.fsm.token.TextToken;
-
-/**
- * Adapts JCas token annotation to interface expected by the Context Dependent
- * Tokenizer.
- *
- * @author Mayo Clinic
- *
- */
-public class TextTokenAdapter extends BaseTokenAdapter implements TextToken
-{
- private Annotation iv_annot;
-
- public TextTokenAdapter(Annotation annot)
- {
- super(annot);
-
- iv_annot = annot;
- }
-
- public String getText()
- {
- return iv_annot.getCoveredText();
- }
-}
+package edu.mayo.bmi.uima.core.fsm.adapters;
+
+import org.apache.uima.jcas.tcas.Annotation;
+
+import edu.mayo.bmi.fsm.token.TextToken;
+
+/**
+ * Adapts JCas token annotation to interface expected by the Context Dependent
+ * Tokenizer.
+ *
+ * @author Mayo Clinic
+ *
+ */
+public class TextTokenAdapter extends BaseTokenAdapter implements TextToken
+{
+ private Annotation iv_annot;
+
+ public TextTokenAdapter(Annotation annot)
+ {
+ super(annot);
+
+ iv_annot = annot;
+ }
+
+ public String getText()
+ {
+ return iv_annot.getCoveredText();
+ }
+}
Modified: incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/WordTokenAdapter.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/WordTokenAdapter.java?rev=1403989&r1=1403988&r2=1403989&view=diff
==============================================================================
--- incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/WordTokenAdapter.java (original)
+++ incubator/ctakes/branches/SHARPn-cTAKES/core/src/edu/mayo/bmi/uima/core/fsm/adapters/WordTokenAdapter.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,59 +14,59 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package edu.mayo.bmi.uima.core.fsm.adapters;
-
-import edu.mayo.bmi.fsm.token.WordToken;
-import edu.mayo.bmi.uima.core.ae.TokenizerAnnotator;
-
-/**
- * Adapts JCas token annotation to interface expected by the Context Dependent
- * Tokenizer.
- *
- * @author Mayo Clinic
- *
- */
-public class WordTokenAdapter extends TextTokenAdapter implements WordToken
-{
- private edu.mayo.bmi.uima.core.type.syntax.WordToken iv_wta;
-
- public WordTokenAdapter(edu.mayo.bmi.uima.core.type.syntax.WordToken wta)
- {
- super(wta);
- iv_wta = wta;
- }
-
- public byte getCaps()
- {
- int caps = iv_wta.getCapitalization();
- switch (caps)
- {
- case TokenizerAnnotator.TOKEN_CAP_ALL:
- return WordToken.CAPS_ALL;
- case TokenizerAnnotator.TOKEN_CAP_FIRST_ONLY:
- return WordToken.CAPS_FIRST_ONLY;
- case TokenizerAnnotator.TOKEN_CAP_MIXED:
- return WordToken.CAPS_MIXED;
- case TokenizerAnnotator.TOKEN_CAP_NONE:
- return WordToken.CAPS_NONE;
- default:
- return WordToken.CAPS_UNKNOWN;
- }
- }
-
- public byte getNumPosition()
- {
- int numPos = iv_wta.getNumPosition();
- switch (numPos)
- {
- case TokenizerAnnotator.TOKEN_NUM_POS_FIRST:
- return WordToken.NUM_FIRST;
- case TokenizerAnnotator.TOKEN_NUM_POS_LAST:
- return WordToken.NUM_LAST;
- case TokenizerAnnotator.TOKEN_NUM_POS_MIDDLE:
- return WordToken.NUM_MIDDLE;
- default:
- return WordToken.NUM_NONE;
- }
- }
-}
+package edu.mayo.bmi.uima.core.fsm.adapters;
+
+import edu.mayo.bmi.fsm.token.WordToken;
+import edu.mayo.bmi.uima.core.ae.TokenizerAnnotator;
+
+/**
+ * Adapts JCas token annotation to interface expected by the Context Dependent
+ * Tokenizer.
+ *
+ * @author Mayo Clinic
+ *
+ */
+public class WordTokenAdapter extends TextTokenAdapter implements WordToken
+{
+ private edu.mayo.bmi.uima.core.type.syntax.WordToken iv_wta;
+
+ public WordTokenAdapter(edu.mayo.bmi.uima.core.type.syntax.WordToken wta)
+ {
+ super(wta);
+ iv_wta = wta;
+ }
+
+ public byte getCaps()
+ {
+ int caps = iv_wta.getCapitalization();
+ switch (caps)
+ {
+ case TokenizerAnnotator.TOKEN_CAP_ALL:
+ return WordToken.CAPS_ALL;
+ case TokenizerAnnotator.TOKEN_CAP_FIRST_ONLY:
+ return WordToken.CAPS_FIRST_ONLY;
+ case TokenizerAnnotator.TOKEN_CAP_MIXED:
+ return WordToken.CAPS_MIXED;
+ case TokenizerAnnotator.TOKEN_CAP_NONE:
+ return WordToken.CAPS_NONE;
+ default:
+ return WordToken.CAPS_UNKNOWN;
+ }
+ }
+
+ public byte getNumPosition()
+ {
+ int numPos = iv_wta.getNumPosition();
+ switch (numPos)
+ {
+ case TokenizerAnnotator.TOKEN_NUM_POS_FIRST:
+ return WordToken.NUM_FIRST;
+ case TokenizerAnnotator.TOKEN_NUM_POS_LAST:
+ return WordToken.NUM_LAST;
+ case TokenizerAnnotator.TOKEN_NUM_POS_MIDDLE:
+ return WordToken.NUM_MIDDLE;
+ default:
+ return WordToken.NUM_NONE;
+ }
+ }
+}