ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vjapa...@apache.org
Subject svn commit: r1551254 [6/26] - in /ctakes/branches/ytex: ctakes-ytex-res/ ctakes-ytex-res/.settings/ ctakes-ytex-res/src/ ctakes-ytex-res/src/main/ ctakes-ytex-res/src/main/resources/ ctakes-ytex-res/src/main/resources/org/ ctakes-ytex-res/src/main/reso...
Date Mon, 16 Dec 2013 16:30:40 GMT
Added: ctakes/branches/ytex/ctakes-ytex-uima/src/main/java/org/apache/ctakes/ytex/tools/docanalyzer/DBAnnotationViewerDialog.java
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex-uima/src/main/java/org/apache/ctakes/ytex/tools/docanalyzer/DBAnnotationViewerDialog.java?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex-uima/src/main/java/org/apache/ctakes/ytex/tools/docanalyzer/DBAnnotationViewerDialog.java (added)
+++ ctakes/branches/ytex/ctakes-ytex-uima/src/main/java/org/apache/ctakes/ytex/tools/docanalyzer/DBAnnotationViewerDialog.java Mon Dec 16 16:30:30 2013
@@ -0,0 +1,739 @@
+package org.apache.ctakes.ytex.tools.docanalyzer;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.swing.BorderFactory;
+import javax.swing.BoxLayout;
+import javax.swing.ButtonGroup;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JTextField;
+import javax.swing.ListCellRenderer;
+import javax.swing.SpringLayout;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.uima.UIMAException;
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.UIMARuntimeException;
+import org.apache.uima.analysis_engine.AnalysisEngineDescription;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.TypeSystem;
+import org.apache.uima.internal.util.BrowserUtil;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.apache.uima.tools.docanalyzer.PrefsMediator;
+import org.apache.uima.tools.images.Images;
+import org.apache.uima.tools.stylemap.ColorParser;
+import org.apache.uima.tools.stylemap.StyleMapEditor;
+import org.apache.uima.tools.stylemap.StyleMapEntry;
+import org.apache.uima.tools.util.gui.Caption;
+import org.apache.uima.tools.util.gui.SpringUtilities;
+import org.apache.uima.tools.util.htmlview.AnnotationViewGenerator;
+import org.apache.uima.tools.viewer.CasAnnotationViewer;
+import org.apache.uima.util.CasCreationUtils;
+import org.apache.uima.util.CasToInlineXml;
+import org.apache.uima.util.FileUtils;
+import org.apache.uima.util.InvalidXMLException;
+import org.apache.uima.util.XMLInputSource;
+import org.apache.uima.util.XmlCasDeserializer;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.SAXException;
+
+/**
+ * Dialog that loads analyzed documents stored in XMI or XCAS format and allows them to be viewed
+ * using the Java-based CAS viewer or a web browser, in either an HTML/Javascript format or in the
+ * inline XML format.
+ * 
+ * copied from AnnotationViewerDialog.
+ * Modified to load CAS from database.
+ * 
+ */
+public class DBAnnotationViewerDialog extends JDialog implements ActionListener {
+
+  private static final long serialVersionUID = -7259891069111863433L;
+
+  private File tempDir = createTempDir();
+
+  protected AnnotationViewGenerator annotationViewGenerator; // JMP
+
+  private StyleMapEditor styleMapEditor;
+
+  private PrefsMediator med1;
+
+  private File styleMapFile;
+
+//  JList analyzedResultsList;
+
+  String inputDirPath = null;
+
+  TypeSystem typeSystem = null;
+
+  String[] typesToDisplay = null;
+
+  JRadioButton javaViewerRB = null;
+
+  JRadioButton javaViewerUCRB = null;
+
+  JRadioButton htmlRB = null;
+
+  JRadioButton xmlRB = null;
+  
+  JTextField documentIDField = null; 
+
+  private CAS cas;
+
+  private boolean processedStyleMap = false;
+  
+  private String defaultCasViewName = CAS.NAME_DEFAULT_SOFA;
+
+  /**
+   * Create an AnnotationViewer Dialog
+   * 
+   * @param aParentFrame
+   *          frame containing this panel
+   * @param aTitle
+   *          title to display for the dialog
+   * @param aInputDir
+   *          directory containing input files (in XCAS foramt) to read
+   * @param aStyleMapFile
+   *          filename of style map to be used to view files in HTML
+   * @param aPerformanceStats
+   *          string representaiton of performance statistics, optional.
+   * @param aTypeSystem
+   *          the CAS Type System to which the XCAS files must conform.
+   * @param aTypesToDisplay
+   *          array of types that should be highlighted in the viewer. This can be set to the output
+   *          types of the Analysis Engine. A value of null means to display all types.
+   */
+  public DBAnnotationViewerDialog(JFrame aParentFrame, String aDialogTitle, PrefsMediator med,
+          File aStyleMapFile, String aPerformanceStats, TypeSystem aTypeSystem,
+          final String[] aTypesToDisplay, String interactiveTempFN, boolean javaViewerRBisSelected,
+          boolean javaViewerUCRBisSelected, boolean xmlRBisSelected, CAS cas) {
+    super(aParentFrame, aDialogTitle);
+    // create the AnnotationViewGenerator (for HTML view generation)
+    this.med1 = med;
+    this.cas = cas;
+    annotationViewGenerator = new AnnotationViewGenerator(tempDir);
+
+    launchThatViewer(med.getOutputDir(), interactiveTempFN, aTypeSystem, aTypesToDisplay,
+            javaViewerRBisSelected, javaViewerUCRBisSelected, xmlRBisSelected, aStyleMapFile,
+            tempDir);
+  }
+
+  public DBAnnotationViewerDialog(JFrame aParentFrame, String aDialogTitle, PrefsMediator med,
+          File aStyleMapFile, String aPerformanceStats, TypeSystem aTypeSystem,
+          final String[] aTypesToDisplay, boolean generatedStyleMap, CAS cas) {
+
+    super(aParentFrame, aDialogTitle);
+    this.med1 = med;
+    this.cas = cas;
+
+    styleMapFile = aStyleMapFile;
+    final String performanceStats = aPerformanceStats;
+    typeSystem = aTypeSystem;
+    typesToDisplay = aTypesToDisplay;
+
+    // create the AnnotationViewGenerator (for HTML view generation)
+    annotationViewGenerator = new AnnotationViewGenerator(tempDir);
+
+    // create StyleMapEditor dialog
+    styleMapEditor = new StyleMapEditor(aParentFrame, cas);
+    JPanel resultsTitlePanel = new JPanel();
+    resultsTitlePanel.setLayout(new BoxLayout(resultsTitlePanel, BoxLayout.Y_AXIS));
+
+//    resultsTitlePanel.add(new JLabel("These are the Analyzed Documents."));
+//    resultsTitlePanel.add(new JLabel("Select viewer type and double-click file to open."));
+    
+    JLabel documentIDLabel = new JLabel("Document ID:");
+    JButton viewDocumentButton = new JButton("View");
+    this.documentIDField = new JTextField(10);
+    JPanel documentIDPanel = new JPanel();
+    documentIDPanel.add(documentIDLabel);
+    documentIDPanel.add(documentIDField);
+    documentIDPanel.add(viewDocumentButton);
+
+//    // create an jlist to list the the analyzed documents
+//    inputDirPath = med.getOutputDir();
+//    File dir = new File(inputDirPath);
+//    // Select documents via filter. JMP
+//    FilenameFilter iFilter = new InteractiveFilter();
+//    String[] documents = dir.list(iFilter);
+//    //create an empty array to display
+//    if(documents == null) {
+//       documents = new String[] {};
+//    }
+//    analyzedResultsList = new JList(documents);
+    
+    /*
+     * File[] documents = dir.listFiles(); Vector docVector = new Vector(); for (int i = 0; i <
+     * documents.length; i++) { if (documents[i].isFile()) { docVector.add(documents[i].getName()); } }
+     * final JList analyzedResultsList = new JList(docVector);
+     */
+//    JScrollPane scrollPane = new JScrollPane();
+//    scrollPane.getViewport().add(analyzedResultsList, null);
+
+    JPanel southernPanel = new JPanel();
+    southernPanel.setLayout(new BoxLayout(southernPanel, BoxLayout.Y_AXIS));
+
+    JPanel controlsPanel = new JPanel();
+    controlsPanel.setLayout(new SpringLayout());
+
+    Caption displayFormatLabel = new Caption("Results Display Format:");
+    controlsPanel.add(displayFormatLabel);
+
+    JPanel displayFormatPanel = new JPanel();
+    displayFormatPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
+    displayFormatPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
+    javaViewerRB = new JRadioButton("Java Viewer");
+    javaViewerUCRB = new JRadioButton("JV user colors");
+    htmlRB = new JRadioButton("HTML");
+    xmlRB = new JRadioButton("XML");
+
+    ButtonGroup displayFormatButtonGroup = new ButtonGroup();
+    displayFormatButtonGroup.add(javaViewerRB);
+    displayFormatButtonGroup.add(javaViewerUCRB);
+    displayFormatButtonGroup.add(htmlRB);
+    displayFormatButtonGroup.add(xmlRB);
+
+    // select the appropraite viewer button according to user's prefs
+    javaViewerRB.setSelected(true); // default, overriden below
+    if ("Java Viewer".equals(med.getViewType())) {
+      javaViewerRB.setSelected(true);
+    } else if ("JV User Colors".equals(med.getViewType())) {
+      javaViewerUCRB.setSelected(true);
+    } else if ("HTML".equals(med.getViewType())) {
+      htmlRB.setSelected(true);
+    } else if ("XML".equals(med.getViewType())) {
+      xmlRB.setSelected(true);
+    }
+
+    displayFormatPanel.add(javaViewerRB);
+    displayFormatPanel.add(javaViewerUCRB);
+    displayFormatPanel.add(htmlRB);
+    displayFormatPanel.add(xmlRB);
+
+    controlsPanel.add(displayFormatPanel);
+
+    SpringUtilities.makeCompactGrid(controlsPanel, 1, 2, // rows, cols
+            4, 4, // initX, initY
+            0, 0); // xPad, yPad
+
+    JButton editStyleMapButton = new JButton("Edit Style Map");
+
+    // event for the editStyleMapButton button
+    editStyleMapButton.addActionListener(this);
+
+    southernPanel.add(controlsPanel);
+
+    // southernPanel.add( new JSeparator() );
+
+    JPanel buttonsPanel = new JPanel();
+    buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
+
+    // APL: edit style map feature disabled for SDK
+    buttonsPanel.add(editStyleMapButton);
+
+    if (performanceStats != null) {
+      JButton perfStatsButton = new JButton("Performance Stats");
+      perfStatsButton.addActionListener(new ActionListener() {
+        public void actionPerformed(ActionEvent ae) {
+          JOptionPane.showMessageDialog((Component) ae.getSource(), performanceStats, null,
+                  JOptionPane.PLAIN_MESSAGE);
+        }
+      });
+      buttonsPanel.add(perfStatsButton);
+    }
+
+    JButton closeButton = new JButton("Close");
+    buttonsPanel.add(closeButton);
+
+    southernPanel.add(buttonsPanel);
+
+    // add jlist and panel container to Dialog
+    getContentPane().add(resultsTitlePanel, BorderLayout.NORTH);
+//    getContentPane().add(scrollPane, BorderLayout.CENTER);
+    getContentPane().add(documentIDPanel, BorderLayout.CENTER);
+    getContentPane().add(southernPanel, BorderLayout.SOUTH);
+
+    // event for the closeButton button
+    closeButton.addActionListener(new ActionListener() {
+      public void actionPerformed(ActionEvent ae) {
+        DBAnnotationViewerDialog.this.setVisible(false);
+      }
+    });
+
+    // event for analyzedResultsDialog window closing
+    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+    setLF(); // set default look and feel
+//    analyzedResultsList.setCellRenderer(new MyListCellRenderer());
+
+//    // doubleclicking on document shows the annotated result
+//    MouseListener mouseListener = new ListMouseAdapter();
+    // styleMapFile, analyzedResultsList,
+    // inputDirPath,typeSystem , typesToDisplay ,
+    // javaViewerRB , javaViewerUCRB ,xmlRB ,
+    // viewerDirectory , this);
+
+//    // add mouse Listener to the list
+//    analyzedResultsList.addMouseListener(mouseListener);
+
+  }
+
+  // unwound from small anonymous inner class
+  public void actionPerformed(ActionEvent arg0) {
+    // read style map XML file if it exists
+    String styleMapXml = null;
+    AnalysisEngineDescription selectedAE = null;
+    try {
+      if (styleMapFile.exists()) {
+        styleMapXml = FileUtils.file2String(styleMapFile);
+      }
+
+      // have user select AE if they haven't done so already
+      if (selectedAE == null) {
+        selectedAE = promptForAE();
+      }
+      if (selectedAE != null) {
+        styleMapEditor.setAnalysisEngine(selectedAE);
+        // launch StyleMapEditor GUI
+        String newStyleMap = styleMapEditor.launchEditor(selectedAE.getAnalysisEngineMetaData(),
+                styleMapXml, cas);
+
+        if (newStyleMap != null) {
+          // write new file using AE+StyleMap convention
+          styleMapFile = med1.getStylemapFile();
+          // write new style map to disk
+          FileWriter writer = new FileWriter(styleMapFile);
+          writer.write(newStyleMap);
+          writer.close();
+          // process generated style map
+          annotationViewGenerator.processStyleMap(styleMapFile);
+        }
+      }
+    } catch (Exception e) {
+      displayError(e);
+    }
+  }
+
+  /**
+   * Filter to not show the two interactive-mode directories in the file list
+   */
+  static class InteractiveFilter implements FilenameFilter {
+    public boolean accept(File dir, String name) {
+      if (name.equals("interactive_temp"))
+        return false;
+      if (name.equals("interactive_out"))
+        return false;
+      return true;
+    }
+  }
+
+  /**
+   * Gets the name of the CAS View that will be displayed first in 
+   * the annotation viewer.
+   */
+  public String getDefaultCasViewName() {
+    return defaultCasViewName;
+  }
+
+  /**
+   * Sets the name of the CAS View that will be displayed first in 
+   * the annotation viewer.  It not set, defaults to {@link CAS#NAME_DEFAULT_SOFA}.
+   */
+  public void setDefaultCasViewName(String defaultCasViewName) {
+    this.defaultCasViewName = defaultCasViewName;
+  }
+  
+  // Common code to launch viewer for both the Run (file-based) and
+  // Interactive modes
+  // JMP
+
+  public void launchThatViewer(String inputDirPath, String fileName, TypeSystem typeSystem,
+          final String[] aTypesToDisplay, boolean javaViewerRBisSelected,
+          boolean javaViewerUCRBisSelected, boolean xmlRBisSelected, File styleMapFile,
+          File viewerDirectory) {
+    try {
+
+      File xcasFile = new File(inputDirPath, fileName);
+      // create a new CAS
+      CAS cas = CasCreationUtils.createCas(Collections.EMPTY_LIST, typeSystem, UIMAFramework
+              .getDefaultPerformanceTuningProperties());
+      // deserialize XCAS into CAS
+      FileInputStream xcasInStream = null;
+      try {
+        xcasInStream = new FileInputStream(xcasFile);
+        XmlCasDeserializer.deserialize(xcasInStream, cas, true);
+      } finally {
+        if (xcasInStream != null)
+          xcasInStream.close();
+      }
+      
+      //get the specified view
+      cas = cas.getView(this.defaultCasViewName);
+
+      // launch appropriate viewer
+      if (javaViewerRBisSelected || javaViewerUCRBisSelected) { // JMP
+        // record preference for next time
+        med1.setViewType(javaViewerRBisSelected ? "Java Viewer" : "JV User Colors");
+
+        // create tree viewer component
+        CasAnnotationViewer viewer = new CasAnnotationViewer();
+        viewer.setDisplayedTypes(aTypesToDisplay);
+        if (javaViewerUCRBisSelected)
+          getColorsForTypesFromFile(viewer, styleMapFile);
+        else
+          viewer.setHiddenTypes(new String[] { "uima.cpm.FileLocation" });
+        // launch viewer in a new dialog
+        viewer.setCAS(cas);
+        JDialog dialog = new JDialog(DBAnnotationViewerDialog.this, "Annotation Results for "
+                + fileName + " in " + inputDirPath); // JMP
+        dialog.getContentPane().add(viewer);
+        dialog.setSize(850, 630);
+        dialog.pack();
+        dialog.show();
+      } else {
+        CAS defaultView = cas.getView(CAS.NAME_DEFAULT_SOFA);
+        if (defaultView.getDocumentText() == null) {
+          displayError("The HTML and XML Viewers can only view the default text document, which was not found in this CAS.");
+          return;
+        }
+        // generate inline XML
+        File inlineXmlFile = new File(viewerDirectory, "inline.xml");
+        String xmlAnnotations = new CasToInlineXml().generateXML(defaultView);
+        FileOutputStream outStream = new FileOutputStream(inlineXmlFile);
+        outStream.write(xmlAnnotations.getBytes("UTF-8"));
+        outStream.close();
+
+        if (xmlRBisSelected) // JMP passed in
+        {
+          // record preference for next time
+          med1.setViewType("XML");
+
+          BrowserUtil.openUrlInDefaultBrowser(inlineXmlFile.getAbsolutePath());
+        } else
+        // HTML view
+        {
+          med1.setViewType("HTML");
+          // generate HTML view
+          // first process style map if not done already
+          if (!processedStyleMap) {
+            if (!styleMapFile.exists()) {
+              annotationViewGenerator.autoGenerateStyleMapFile(
+                      promptForAE().getAnalysisEngineMetaData(), styleMapFile);
+            }
+            annotationViewGenerator.processStyleMap(styleMapFile);
+            processedStyleMap = true;
+          }
+          annotationViewGenerator.processDocument(inlineXmlFile);
+          File genFile = new File(viewerDirectory, "index.html");
+          // open in browser
+          BrowserUtil.openUrlInDefaultBrowser(genFile.getAbsolutePath());
+        }
+      }
+
+      // end LTV here
+
+    } catch (Exception ex) {
+      displayError(ex);
+    }
+  }
+
+
+  /**
+   * Assumes node has a text field and extracts its value. JMP
+   */
+  static public String getTextValue(Node node) {
+    Node first = node.getFirstChild();
+    if (first != null) {
+      Text text = (Text) node.getFirstChild();
+      return text.getNodeValue().trim();
+    } else
+      return null;
+  }
+
+  /**
+   * Gets the first child with a given name. JMP
+   */
+  static public Node getFirstChildByName(Node node, String name) {
+    NodeList children = node.getChildNodes();
+    for (int c = 0; c < children.getLength(); ++c) {
+      Node n = children.item(c);
+      if (n.getNodeName().equals(name))
+        return n;
+    }
+    return null;
+  }
+
+  /**
+   * Reads in annotation-color associations from stylemap file. JMP Also reads checked value if
+   * present.
+   */
+
+  public void getColorsForTypesFromFile(CasAnnotationViewer viewer, File aStyleMapFile) {
+    List colorList = new ArrayList();
+    ArrayList typeList = new ArrayList();
+    ArrayList notCheckedList = new ArrayList();
+    ArrayList hiddenList = new ArrayList();
+    hiddenList.add("uima.cpm.FileLocation");
+
+    if (aStyleMapFile.exists()) {
+
+      FileInputStream stream = null;
+      Document parse = null;
+      try {
+        stream = new FileInputStream(aStyleMapFile);
+        DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+        parse = db.parse(stream);
+      } catch (FileNotFoundException e) {
+        throw new UIMARuntimeException(e);
+      } catch (ParserConfigurationException e) {
+        throw new UIMARuntimeException(e);
+      } catch (FactoryConfigurationError e) {
+        throw new UIMARuntimeException(e);
+      } catch (SAXException e) {
+        throw new UIMARuntimeException(e);
+      } catch (IOException e) {
+        throw new UIMARuntimeException(e);
+      }
+      Node node0 = parse.getDocumentElement();
+      // Node node1 = getFirstChildByName(parse.getDocumentElement(),
+      // "styleMap");
+      // String node1Name = node1.getNodeName();
+
+      NodeList nodeList = node0.getChildNodes();
+      ColorParser cParser = new ColorParser();
+      for (int i = 0; i < nodeList.getLength(); i++) {
+        Node node = nodeList.item(i);
+        String nodeName = node.getNodeName();
+        if (nodeName.equals("rule")) {
+          NodeList childrenList = node.getChildNodes();
+          String type = "";
+          String label = "";
+          StyleMapEntry sme = null;
+          String colorText = "";
+          for (int j = 0; j < childrenList.getLength(); j++) {
+            Node child = childrenList.item(j);
+            String childName = child.getNodeName();
+            if (childName.equals("pattern")) {
+              type = getTextValue(child);
+            }
+            if (childName.equals("label")) {
+              label = getTextValue(child);
+            }
+            if (childName.equals("style")) {
+              colorText = getTextValue(child);
+            }
+
+          }
+          sme = cParser.parseAndAssignColors(type, label, label, colorText);
+          if (!sme.getChecked()) {
+            notCheckedList.add(sme.getAnnotationTypeName());
+          }
+          if (!sme.getHidden()) {
+            colorList.add(sme.getBackground());
+            typeList.add(sme.getAnnotationTypeName());
+          } else {
+            hiddenList.add(sme.getAnnotationTypeName());
+          }
+
+        }
+      }
+
+      if (stream != null)
+        try {
+          stream.close();
+        } catch (IOException e) {
+          e.printStackTrace();
+        }
+      viewer.assignColorsFromList(colorList, typeList);
+      viewer.assignCheckedFromList(notCheckedList);
+      String[] hiddenArr = new String[hiddenList.size()];
+      hiddenList.toArray(hiddenArr);
+      viewer.setHiddenTypes(hiddenArr);
+    }
+
+  }
+
+  /**
+   * Displays an error message to the user.
+   * 
+   * @param aErrorString
+   *          error message to display
+   */
+  public void displayError(String aErrorString) {
+    // word-wrap long mesages
+    StringBuffer buf = new StringBuffer(aErrorString.length());
+    final int CHARS_PER_LINE = 80;
+    int charCount = 0;
+    StringTokenizer tokenizer = new StringTokenizer(aErrorString, " \n", true);
+
+    while (tokenizer.hasMoreTokens()) {
+      String tok = tokenizer.nextToken();
+
+      if (tok.equals("\n")) {
+        buf.append("\n");
+        charCount = 0;
+      } else if ((charCount > 0) && ((charCount + tok.length()) > CHARS_PER_LINE)) {
+        buf.append("\n").append(tok);
+        charCount = tok.length();
+      } else {
+        buf.append(tok);
+        charCount += tok.length();
+      }
+    }
+
+    JOptionPane.showMessageDialog(DBAnnotationViewerDialog.this, buf.toString(), "Error",
+            JOptionPane.ERROR_MESSAGE);
+  }
+
+  /**
+   * Displays an error message to the user.
+   * 
+   * @param aThrowable
+   *          Throwable whose message is to be displayed.
+   */
+  public void displayError(Throwable aThrowable) {
+    aThrowable.printStackTrace();
+
+    String message = aThrowable.toString();
+
+    // For UIMAExceptions or UIMARuntimeExceptions, add cause info.
+    // We have to go through this nonsense to support Java 1.3.
+    // In 1.4 all exceptions can have a cause, so this wouldn't involve
+    // all of this typecasting.
+    while ((aThrowable instanceof UIMAException) || (aThrowable instanceof UIMARuntimeException)) {
+      if (aThrowable instanceof UIMAException) {
+        aThrowable = ((UIMAException) aThrowable).getCause();
+      } else if (aThrowable instanceof UIMARuntimeException) {
+        aThrowable = ((UIMARuntimeException) aThrowable).getCause();
+      }
+
+      if (aThrowable != null) {
+        message += ("\nCausedBy: " + aThrowable.toString());
+      }
+    }
+
+    displayError(message);
+  }
+
+  /**
+   * If the current AE filename is not know ask for it. Then parse the selected file and return the
+   * AnalysisEngineDescription object.
+   * 
+   * @return the selected AnalysisEngineDescription, null if the user cancelled
+   */
+  protected AnalysisEngineDescription promptForAE() throws IOException, InvalidXMLException,
+          ResourceInitializationException {
+    if (med1.getTAEfile() != null) {
+      File taeFile = new File(med1.getTAEfile());
+      XMLInputSource in = new XMLInputSource(taeFile);
+      AnalysisEngineDescription aed = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(
+              in);
+      return aed;
+    } else {
+      String taeDir = med1.getTAEfile();
+      JFileChooser chooser = new JFileChooser(taeDir);
+      chooser.setDialogTitle("Select the Analysis Engine that Generated this Output");
+      chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+      int returnVal = chooser.showOpenDialog(this);
+      if (returnVal == JFileChooser.APPROVE_OPTION) {
+        XMLInputSource in = new XMLInputSource(chooser.getSelectedFile());
+        return UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in);
+      } else {
+        return null;
+      }
+    }
+  }
+
+  /** set default look and feel */
+  private static void setLF() {
+    // Force SwingApp to come up in the System L&F
+    String laf = UIManager.getSystemLookAndFeelClassName();
+    try {
+      UIManager.setLookAndFeel(laf);
+    } catch (UnsupportedLookAndFeelException exc) {
+      System.err.println("Warning: UnsupportedLookAndFeel: " + laf);
+    } catch (Exception exc) {
+      System.err.println("Error loading " + laf + ": " + exc);
+    }
+  }
+  
+  private File createTempDir() {
+    File temp = new File(System.getProperty("java.io.tmpdir"), System.getProperty("user.name"));
+    temp.mkdir();
+    return temp;
+  }
+
+  // create and call the list cell renderer to set the selected color and
+  // image icon
+  static class MyListCellRenderer extends JLabel implements ListCellRenderer {
+    private static final long serialVersionUID = 7231915634689270693L;
+
+    public MyListCellRenderer() {
+      setOpaque(true);
+    }
+
+    public Component getListCellRendererComponent(JList analyzedResultsList, Object value,
+            int index, boolean isSelected, boolean cellHasFocus) {
+      ImageIcon xmlIcon = Images.getImageIcon(Images.XML_DOC);
+      setIcon(xmlIcon);
+      setText(value.toString());
+      setBackground(isSelected ? Color.orange : Color.white);
+      setForeground(isSelected ? Color.black : Color.black);
+      return this;
+    }
+  }
+
+//  class ListMouseAdapter extends MouseAdapter {
+//
+//    public void mouseClicked(MouseEvent e) {
+//      try {
+//        if (e.getClickCount() == 2) {
+//          String fileName = ((String) analyzedResultsList.getSelectedValue());
+//          if (fileName != null) {
+//            analyzedResultsList.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+//            // Start LTV here
+//            launchThatViewer(inputDirPath, fileName, typeSystem, typesToDisplay, javaViewerRB
+//                    .isSelected(), javaViewerUCRB.isSelected(), xmlRB.isSelected(), styleMapFile,
+//                    tempDir);
+//
+//            analyzedResultsList.setCursor(Cursor.getDefaultCursor());
+//          }
+//        }
+//      } catch (Exception ex) {
+//        displayError(ex);
+//      }
+//    }
+//  }
+}

Added: ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/DBCollectionReaderTest.java
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/DBCollectionReaderTest.java?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/DBCollectionReaderTest.java (added)
+++ ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/DBCollectionReaderTest.java Mon Dec 16 16:30:30 2013
@@ -0,0 +1,36 @@
+package org.apache.ctakes.ytex.uima;
+
+import java.io.IOException;
+
+import org.apache.ctakes.ytex.dao.DBUtil;
+import org.apache.ctakes.ytex.uima.types.DocKey;
+import org.apache.uima.UIMAException;
+import org.apache.uima.jcas.JCas;
+import org.junit.Assert;
+import org.junit.Test;
+import org.uimafit.factory.JCasFactory;
+
+public class DBCollectionReaderTest {
+
+	@Test
+	public void testGetNext() throws UIMAException, IOException {
+
+		JCas jCas = JCasFactory
+				.createJCasFromPath("src/main/resources/org/apache/ctakes/ytex/types/TypeSystem.xml");
+		DBCollectionReader reader = new DBCollectionReader();
+		reader.initDB(null, null);
+		reader.queryGetDocument = String
+				.format("select note_text from %sfracture_demo where note_id = :instance_id",
+						DBUtil.getYTEXTablePrefix());
+		reader.queryGetDocumentKeys = String.format(
+				"select note_id instance_id from %sfracture_demo",
+				DBUtil.getYTEXTablePrefix());
+		reader.loadDocumentIds();
+		reader.getNext(jCas);
+		Assert.assertNotNull(jCas.getDocumentText());
+		Assert.assertTrue(jCas.getAnnotationIndex(DocKey.type).iterator()
+				.hasNext());
+
+	}
+
+}

Added: ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/DBConsumerTest.java
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/DBConsumerTest.java?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/DBConsumerTest.java (added)
+++ ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/DBConsumerTest.java Mon Dec 16 16:30:30 2013
@@ -0,0 +1,152 @@
+package org.apache.ctakes.ytex.uima.annotators;
+
+import java.io.File;
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Properties;
+
+import javax.sql.DataSource;
+
+import org.apache.commons.dbcp.BasicDataSource;
+import org.apache.ctakes.ytex.uima.ApplicationContextHolder;
+import org.apache.ctakes.ytex.uima.types.DocKey;
+import org.apache.ctakes.ytex.uima.types.KeyValuePair;
+import org.apache.uima.UIMAException;
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.cas.FSArray;
+import org.apache.uima.util.InvalidXMLException;
+import org.apache.uima.util.XMLInputSource;
+import org.apache.uima.util.XMLParser;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.uimafit.factory.AggregateBuilder;
+
+import com.google.common.base.Strings;
+
+/**
+ * TODO get rid of hard-coded path to Types.xml - load from classpath
+ * 
+ * @author vgarla
+ * 
+ */
+public class DBConsumerTest {
+
+	/**
+	 * hsql will not write data unless the connection is explicitly closed. for
+	 * debugging issues helpful to look at data; therefore uncomment this
+	 * method. however, this will cause issues with other tests as they run in
+	 * the same classloader, and the pool will be closed. most elegant solution
+	 * would be for spring to close the connections on shutdown.
+	 * 
+	 * alternatively, fork tests.
+	 */
+	@AfterClass
+	public static void cleanup() {
+
+		// ApplicationContext ctx = ApplicationContextHolder
+		// .getApplicationContext();
+		// DataSource ds = ctx.getBean(DataSource.class);
+		// try {
+		// ((BasicDataSource)ds).close();
+		// } catch (Exception e) {
+		// e.printStackTrace();
+		// }
+	}
+
+	// @Test
+	// public void testGetCols() throws SQLException {
+	// ApplicationContext ctx = ApplicationContextHolder
+	// .getApplicationContext();
+	// DataSource ds = ctx.getBean(DataSource.class);
+	// Connection conn = ds.getConnection();
+	// DatabaseMetaData dmd = conn.getMetaData();
+	// // get columns for corresponding table
+	// // mssql - add schema prefix
+	// // oracle - convert table name to upper case
+	// ResultSet rs = dmd.getColumns(
+	// null,
+	// "PUBLIC",
+	// "ANNO_TOKEN",
+	// null);
+	// while(rs.next()) {
+	// String colName = rs.getString("COLUMN_NAME");
+	// System.out.println(colName);
+	// }
+	// rs.close();
+	// conn.close();
+	// }
+
+	/**
+	 * Verify that date parsing with a manually created date works
+	 * 
+	 * @throws UIMAException
+	 * @throws Exception
+	 */
+	@Test
+	public void testProcessAndSaveDoc() throws UIMAException, IOException {
+		// JCas jCas =
+		// JCasFactory.createJCasFromPath("src/main/resources/org/apache/ctakes/ytex/types/TypeSystem.xml");
+		String text = "Title: US Abdomen\n\nDr. Doolitle asked patient\nto take a deep breath\nand exhale slowly.  Patient coughed.  Prescribed acetominophen";
+		AggregateBuilder builder = new AggregateBuilder();
+		addDescriptor(builder, "desc/analysis_engine/SegmentRegexAnnotator.xml");
+		addDescriptor(builder,
+				"desc/analysis_engine/SentenceDetectorAnnotator.xml");
+		addDescriptor(builder,
+				"../ctakes-core/desc/analysis_engine/TokenizerAnnotator.xml");
+		addDescriptor(builder, "desc/analysis_engine/DBConsumer.xml");
+		AnalysisEngine engine = builder.createAggregate();
+		JCas jCas = engine.newJCas();
+		jCas.setDocumentText(text);
+		// create a docKey so we can find the doc
+		long key = System.currentTimeMillis();
+		DocKey docKey = new DocKey(jCas);
+		KeyValuePair kvp = new KeyValuePair(jCas);
+		kvp.setKey("instance_id");
+		kvp.setValueLong(key);
+		FSArray fsa = new FSArray(jCas, 1);
+		fsa.set(0, kvp);
+		docKey.setKeyValuePairs(fsa);
+		docKey.addToIndexes();
+		// run the analysis engine
+		engine.process(jCas);
+		ApplicationContext ctx = ApplicationContextHolder
+				.getApplicationContext();
+		DataSource ds = ctx.getBean(DataSource.class);
+		Properties ytexProperties = (Properties) ctx.getBean("ytexProperties");
+		String schema = ytexProperties.getProperty("db.schema");
+		String schemaPrefix = Strings.isNullOrEmpty(schema) ? "" : schema + ".";
+		JdbcTemplate jt = new JdbcTemplate(ds);
+		String query = String.format(
+				"select count(*) from %sdocument where instance_id=%s",
+				schemaPrefix, key);
+		Assert.assertTrue(query, jt.queryForInt(query) == 1);
+		query = String
+				.format("select count(*) from %sdocument d inner join %sanno_base ab on ab.document_id = d.document_id inner join %sanno_segment s on s.anno_base_id = ab.anno_base_id where d.instance_id=%s",
+						schemaPrefix, schemaPrefix, schemaPrefix, key);
+		Assert.assertTrue(query, jt.queryForInt(query) == 1);
+		query = String
+				.format("select count(*) from %sdocument d inner join %sanno_base ab on ab.document_id = d.document_id inner join %sanno_sentence s on s.anno_base_id = ab.anno_base_id where d.instance_id=%s",
+						schemaPrefix, schemaPrefix, schemaPrefix, key);
+		Assert.assertTrue(query, jt.queryForInt(query) > 1);
+		query = String
+				.format("select count(*) from %sdocument d inner join %sanno_base ab on ab.document_id = d.document_id inner join %sanno_token s on s.anno_base_id = ab.anno_base_id where d.instance_id=%s",
+						schemaPrefix, schemaPrefix, schemaPrefix, key);
+		Assert.assertTrue(query, jt.queryForInt(query) > 1);
+	}
+
+	private void addDescriptor(AggregateBuilder builder, String path)
+			throws IOException, InvalidXMLException {
+		File fileCtakes = new File(path);
+		XMLParser parser = UIMAFramework.getXMLParser();
+		XMLInputSource source = new XMLInputSource(fileCtakes);
+		builder.add(parser.parseAnalysisEngineDescription(source));
+	}
+}

Added: ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/DateAnnotatorTest.java
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/DateAnnotatorTest.java?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/DateAnnotatorTest.java (added)
+++ ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/DateAnnotatorTest.java Mon Dec 16 16:30:30 2013
@@ -0,0 +1,42 @@
+package org.apache.ctakes.ytex.uima.annotators;
+
+import org.apache.ctakes.typesystem.type.textsem.DateAnnotation;
+import org.apache.uima.UIMAException;
+import org.apache.uima.cas.text.AnnotationIndex;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.tcas.Annotation;
+import org.junit.Assert;
+import org.junit.Test;
+import org.uimafit.factory.JCasFactory;
+
+/**
+ * TODO get rid of hard-coded path to Types.xml - load from classpath
+ * @author vgarla
+ *
+ */
+public class DateAnnotatorTest {
+
+	/**
+	 * Verify that date parsing with a manually created date works
+	 * @throws UIMAException
+	 */
+	@Test
+	public void testParseDate() throws UIMAException {
+	    JCas jCas = JCasFactory.createJCasFromPath("src/main/resources/org/apache/ctakes/ytex/types/TypeSystem.xml");
+	    String date = (new java.util.Date()).toString();
+	    jCas.setDocumentText(date);
+	    DateAnnotation ctakesDate = new DateAnnotation(jCas);
+	    ctakesDate.setBegin(0);
+	    ctakesDate.setEnd(date.length());
+	    ctakesDate.addToIndexes();
+	    DateAnnotator dateAnnotator = new DateAnnotator();
+	    dateAnnotator.dateType = org.apache.ctakes.ytex.uima.types.Date.class.getName();
+	    dateAnnotator.process(jCas);
+	    AnnotationIndex<Annotation> ytexDates = jCas.getAnnotationIndex(org.apache.ctakes.ytex.uima.types.Date.type);
+	    Assert.assertTrue(ytexDates.iterator().hasNext());
+	    String dateParsed = ((org.apache.ctakes.ytex.uima.types.Date)ytexDates.iterator().next()).getDate();
+	    Assert.assertNotNull(dateParsed);
+	    System.out.println(dateParsed);
+	}
+
+}

Added: ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/DictionaryLookupAnnotatorTest.java
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/DictionaryLookupAnnotatorTest.java?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/DictionaryLookupAnnotatorTest.java (added)
+++ ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/DictionaryLookupAnnotatorTest.java Mon Dec 16 16:30:30 2013
@@ -0,0 +1,120 @@
+package org.apache.ctakes.ytex.uima.annotators;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.apache.ctakes.typesystem.type.syntax.Chunk;
+import org.apache.ctakes.typesystem.type.syntax.WordToken;
+import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
+import org.apache.ctakes.typesystem.type.textspan.LookupWindowAnnotation;
+import org.apache.uima.UIMAException;
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.cas.text.AnnotationIndex;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.tcas.Annotation;
+import org.apache.uima.util.InvalidXMLException;
+import org.apache.uima.util.XMLInputSource;
+import org.apache.uima.util.XMLParser;
+import org.junit.Assert;
+import org.junit.Test;
+import org.uimafit.factory.AggregateBuilder;
+import org.uimafit.factory.JCasFactory;
+
+/**
+ * TODO get rid of hard-coded path to Types.xml - load from classpath
+ * 
+ * @author vgarla
+ * 
+ */
+public class DictionaryLookupAnnotatorTest {
+
+	@Test
+	public void testDictionaryLookupSimple() throws UIMAException, IOException {
+	    JCas jCas = JCasFactory.createJCasFromPath("src/main/resources/org/apache/ctakes/ytex/types/TypeSystem.xml");
+		String text = "acetaminophen";
+	    jCas.setDocumentText(text);
+	    WordToken tok = new WordToken(jCas);
+	    tok.setBegin(0);
+	    tok.setEnd(text.length());
+	    tok.addToIndexes();
+	    LookupWindowAnnotation lwa = new LookupWindowAnnotation(jCas);
+	    lwa.setBegin(0);
+	    lwa.setEnd(text.length());
+	    lwa.addToIndexes();
+		AggregateBuilder builder = new AggregateBuilder();
+		addDescriptor(builder,
+				"desc/analysis_engine/DictionaryLookupAnnotator.xml");
+		AnalysisEngine engine = builder.createAggregate();
+		engine.process(jCas);
+		Assert.assertTrue(printAnnos(jCas, IdentifiedAnnotation.type) > 0);
+	}
+	/**
+	 * integration test
+	 * 
+	 * @throws UIMAException
+	 * @throws Exception
+	 */
+	@Test
+	public void testDictionaryLookupIntegrated() throws UIMAException, IOException {
+		// JCas jCas =
+		// JCasFactory.createJCasFromPath("src/main/resources/org/apache/ctakes/ytex/types/TypeSystem.xml");
+		String text = "Dr. Doolitle asked patient\nto take a deep breath\nand exhale slowly.  Patient coughed and complained of abdominal pain.  Patient was administered acetaminophen.";
+		AggregateBuilder builder = new AggregateBuilder();
+		addDescriptor(builder,
+				"desc/analysis_engine/AggregatePlaintextUMLSProcessor.xml");
+		// addDescriptor(builder,
+		// "desc/analysis_engine/SentenceDetectorAnnotator.xml");
+		// addDescriptor(builder,
+		// "../ctakes-core/desc/analysis_engine/TokenizerAnnotator.xml");
+		// addDescriptor(builder,
+		// "../ctakes-context-tokenizer/desc/analysis_engine/ContextDependentTokenizerAnnotator.xml");
+		// addDescriptor(builder,
+		// "../ctakes-pos-tagger/desc/POSTagger.xml");
+		// addDescriptor(builder,
+		// "../ctakes-chunker/desc/Chunker.xml");
+		// addDescriptor(builder,
+		// "../ctakes-chunker/desc/AdjustNounPhraseToIncludeFollowingNP.xml");
+		// addDescriptor(builder,
+		// "../ctakes-chunker/desc/AdjustNounPhraseToIncludeFollowingPPNP.xml");
+		// addDescriptor(builder,
+		// "../ctakes-clinical-pipeline/desc/analysis_engine/LookupWindowAnnotator.xml");
+		// addDescriptor(builder,
+		// "desc/analysis_engine/DictionaryLookupAnnotator.xml");
+		AnalysisEngine engine = builder.createAggregate();
+		JCas jCas = engine.newJCas();
+		jCas.setDocumentText(text);
+//		Segment s = new Segment(jCas);
+//		s.setBegin(0);
+//		s.setEnd(text.length());
+//		s.setId("DEFAULT");
+//		s.addToIndexes();
+		// run the analysis engine
+		engine.process(jCas);
+		Assert.assertTrue(printAnnos(jCas, Chunk.type) > 0);
+		Assert.assertTrue(printAnnos(jCas, LookupWindowAnnotation.type) > 0);
+		Assert.assertTrue(printAnnos(jCas, IdentifiedAnnotation.type) > 0);
+	}
+
+	private int printAnnos(JCas jCas, int type) {
+		AnnotationIndex<Annotation> sentences = jCas.getAnnotationIndex(type);
+		Iterator<Annotation> iter = sentences.iterator();
+		int sentCount = 0;
+		while (iter.hasNext()) {
+			Annotation sent = (Annotation) iter.next();
+			System.out.println(sent.getClass().getSimpleName() + " ["
+					+ sent.getCoveredText() + "]");
+			sentCount++;
+		}
+		return sentCount;
+	}
+
+	private void addDescriptor(AggregateBuilder builder, String path)
+			throws IOException, InvalidXMLException {
+		File fileCtakes = new File(path);
+		XMLParser parser = UIMAFramework.getXMLParser();
+		XMLInputSource source = new XMLInputSource(fileCtakes);
+		builder.add(parser.parseAnalysisEngineDescription(source));
+	}
+}

Added: ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/NamedEntityRegexTest.java
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/NamedEntityRegexTest.java?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/NamedEntityRegexTest.java (added)
+++ ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/NamedEntityRegexTest.java Mon Dec 16 16:30:30 2013
@@ -0,0 +1,59 @@
+package org.apache.ctakes.ytex.uima.annotators;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.apache.ctakes.typesystem.type.textsem.EntityMention;
+import org.apache.ctakes.typesystem.type.textspan.Segment;
+import org.apache.ctakes.ytex.uima.model.NamedEntityRegex;
+import org.apache.uima.UIMAException;
+import org.apache.uima.cas.text.AnnotationIndex;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.tcas.Annotation;
+import org.junit.Assert;
+import org.junit.Test;
+import org.uimafit.factory.JCasFactory;
+
+/**
+ * TODO get rid of hard-coded path to Types.xml - load from classpath
+ * @author vgarla
+ *
+ */
+public class NamedEntityRegexTest {
+
+	/**
+	 * Verify that date parsing with a manually created date works
+	 * @throws UIMAException
+	 * @throws Exception 
+	 */
+	@Test
+	public void testRegex() throws UIMAException, IOException {
+		NamedEntityRegexAnnotator ner = new NamedEntityRegexAnnotator();
+		NamedEntityRegex nerex = new NamedEntityRegex();
+		nerex.setCode("C00TEST");
+		nerex.setContext("DEFAULT");
+		nerex.setRegex("(?i)COUGH");
+		ner.initRegexMap(Arrays.asList(nerex));
+		
+	    JCas jCas = JCasFactory.createJCasFromPath("src/main/resources/org/apache/ctakes/ytex/types/TypeSystem.xml");
+	    String text = "Dr. Doolitle asked patient\nto take a deep breath\nand exhale slowly.  Patient coughed.";
+	    jCas.setDocumentText(text);
+	    Segment s = new Segment(jCas);
+	    s.setBegin(0);
+	    s.setEnd(text.length());
+	    s.setId("DEFAULT");
+	    s.addToIndexes();
+	    ner.process(jCas);
+	    // run the analysis engine
+	    AnnotationIndex<Annotation> mentions = jCas.getAnnotationIndex(EntityMention.type);
+		Iterator<Annotation> iter =mentions.iterator();
+		int emCount = 0;
+		while(iter.hasNext()) {
+			EntityMention em = (EntityMention)iter.next();
+			System.out.println("[" + em.getCoveredText() + "]");
+			emCount ++;
+		}
+		Assert.assertTrue(emCount == 1);
+	}
+}

Added: ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/SegmentRegexTest.java
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/SegmentRegexTest.java?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/SegmentRegexTest.java (added)
+++ ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/SegmentRegexTest.java Mon Dec 16 16:30:30 2013
@@ -0,0 +1,72 @@
+package org.apache.ctakes.ytex.uima.annotators;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.ctakes.typesystem.type.textsem.EntityMention;
+import org.apache.ctakes.typesystem.type.textspan.Segment;
+import org.apache.ctakes.ytex.uima.model.NamedEntityRegex;
+import org.apache.ctakes.ytex.uima.model.SegmentRegex;
+import org.apache.uima.UIMAException;
+import org.apache.uima.cas.text.AnnotationIndex;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.tcas.Annotation;
+import org.junit.Assert;
+import org.junit.Test;
+import org.uimafit.factory.JCasFactory;
+
+/**
+ * TODO get rid of hard-coded path to Types.xml - load from classpath
+ * 
+ * @author vgarla
+ * 
+ */
+public class SegmentRegexTest {
+
+	/**
+	 * Verify that date parsing with a manually created date works
+	 * 
+	 * @throws UIMAException
+	 * @throws Exception
+	 */
+	@Test
+	public void testRegex() throws UIMAException, IOException {
+		SegmentRegexAnnotator ner = new SegmentRegexAnnotator();
+		SegmentRegex segTitle = new SegmentRegex();
+		segTitle.setRegex("(?i)title:\\s*(.*)\\n");
+		segTitle.setLimitToRegex(true);
+		segTitle.setSegmentID("TITLE");
+		segTitle.setSegmentRegexID(1);
+		SegmentRegex segHistory = new SegmentRegex();
+		segHistory.setRegex("(?i)history:");
+		segHistory.setLimitToRegex(false);
+		segHistory.setSegmentID("HISTORY");
+		segHistory.setSegmentRegexID(2);
+		ner.initRegexMap(Arrays.asList(segTitle, segHistory));
+
+		JCas jCas = JCasFactory
+				.createJCasFromPath("src/main/resources/org/apache/ctakes/ytex/types/TypeSystem.xml");
+		String text = "Title: US Left Upper Quadrant\nDr. Doolitle asked patient\nto take a deep breath\nand exhale slowly.  \nHistory: Patient coughed.";
+		jCas.setDocumentText(text);
+		ner.process(jCas);
+		// run the analysis engine
+		AnnotationIndex<Annotation> mentions = jCas
+				.getAnnotationIndex(Segment.type);
+		Iterator<Annotation> iter = mentions.iterator();
+		Set<String> uniqueSegments = new HashSet<String>();
+		int emCount = 0;
+		while (iter.hasNext()) {
+			Segment em = (Segment) iter.next();
+			uniqueSegments.add(em.getId());
+			System.out.println(em.getId() + " [" + em.getCoveredText() + "]");
+			emCount++;
+		}
+		// should be 4 segments - default/title/default/history
+		Assert.assertTrue(emCount == 4);
+		// should be 3 unique segments
+		Assert.assertTrue(uniqueSegments.size() == 3);
+	}
+}

Added: ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/SenseDisambiguatorAnnotatorTest.java
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/SenseDisambiguatorAnnotatorTest.java?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/SenseDisambiguatorAnnotatorTest.java (added)
+++ ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/SenseDisambiguatorAnnotatorTest.java Mon Dec 16 16:30:30 2013
@@ -0,0 +1,124 @@
+package org.apache.ctakes.ytex.uima.annotators;
+
+import java.util.Collections;
+import java.util.List;
+
+import javax.sql.DataSource;
+
+import org.apache.ctakes.typesystem.type.refsem.OntologyConcept;
+import org.apache.ctakes.typesystem.type.textsem.EntityMention;
+import org.apache.ctakes.ytex.kernel.dao.ConceptDao;
+import org.apache.ctakes.ytex.kernel.model.ConceptGraph;
+import org.apache.ctakes.ytex.kernel.wsd.WordSenseDisambiguator;
+import org.apache.ctakes.ytex.uima.ApplicationContextHolder;
+import org.apache.uima.UIMAException;
+import org.apache.uima.cas.text.AnnotationIndex;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.cas.FSArray;
+import org.apache.uima.jcas.tcas.Annotation;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.access.ContextSingletonBeanFactoryLocator;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.uimafit.factory.JCasFactory;
+
+import com.google.common.collect.Lists;
+
+public class SenseDisambiguatorAnnotatorTest {
+	ConceptDao conceptDao;
+	ApplicationContext appCtx;
+
+	@Before
+	public void setUp() throws Exception {
+		appCtx = (ApplicationContext) ContextSingletonBeanFactoryLocator
+				.getInstance("classpath*:org/apache/ctakes/ytex/kernelBeanRefContext.xml")
+				.useBeanFactory("kernelApplicationContext").getFactory();
+		conceptDao = appCtx.getBean(ConceptDao.class);
+		JdbcTemplate jdbcTemplate = new JdbcTemplate();
+		jdbcTemplate.setDataSource(appCtx.getBean(DataSource.class));
+		jdbcTemplate.execute("drop table if exists test_concepts");
+		jdbcTemplate
+				.execute("create table test_concepts(parent varchar(20), child varchar(20))");
+		jdbcTemplate
+				.execute("insert into test_concepts values ('root', 'animal')");
+		jdbcTemplate
+				.execute("insert into test_concepts values ('animal', 'vertebrate')");
+		jdbcTemplate
+				.execute("insert into test_concepts values ('vertebrate', 'cat')");
+		jdbcTemplate
+				.execute("insert into test_concepts values ('vertebrate', 'dog')");
+		jdbcTemplate
+				.execute("insert into test_concepts values ('root', 'bacteria')");
+		jdbcTemplate
+				.execute("insert into test_concepts values ('bacteria', 'e coli')");
+		conceptDao.createConceptGraph("test",
+				"select child, parent from test_concepts", true,
+				Collections.EMPTY_SET);
+		ConceptGraph cg = conceptDao.getConceptGraph("test");
+		Assert.assertNotNull(cg);
+		((ConfigurableApplicationContext) appCtx).close();
+	}
+
+	/**
+	 * 3 concepts, middle one with 2 cuis.  Middle concept should be disambiguated
+	 * @throws UIMAException
+	 */
+	@Test
+	public void testDisambiguate() throws UIMAException {
+		System.setProperty("ytex.conceptGraphName", "test");
+		System.setProperty("ytex.conceptPreload", "false");
+		System.setProperty("ytex.conceptSetName", "");
+		JCas jCas = JCasFactory
+				.createJCasFromPath("src/main/resources/org/apache/ctakes/ytex/types/TypeSystem.xml");
+		String text = "concept1 concept2 concept3";
+		jCas.setDocumentText(text);
+		EntityMention em1 = new EntityMention(jCas);
+		em1.setBegin(0);
+		em1.setEnd(8);
+		setConcepts(jCas, em1, new String[] { "dog" });
+		em1.addToIndexes();
+
+		EntityMention em2 = new EntityMention(jCas);
+		em2.setBegin(9);
+		em2.setEnd(17);
+		setConcepts(jCas, em2, new String[] { "e coli", "animal" });
+		em2.addToIndexes();
+		
+		EntityMention em3 = new EntityMention(jCas);
+		em3.setBegin(18);
+		em3.setEnd(26);
+		setConcepts(jCas, em3, new String[] { "cat" });
+		em3.addToIndexes();
+		
+		SenseDisambiguatorAnnotator sda = new SenseDisambiguatorAnnotator();
+		sda.wsd = ApplicationContextHolder.getSimApplicationContext().getBean(
+				WordSenseDisambiguator.class);
+		sda.process(jCas);
+		AnnotationIndex<Annotation> annoIdx = jCas.getAnnotationIndex(EntityMention.type);
+		List<Annotation> annoList = Lists.newArrayList(annoIdx);
+		EntityMention emD = (EntityMention)annoList.get(1);
+		FSArray fsa = emD.getOntologyConceptArr();
+		for(int i = 0; i < fsa.size(); i++) {
+			OntologyConcept oc = (OntologyConcept)fsa.get(i);
+			if("animal".equals(oc.getCode())) {
+				Assert.assertTrue(oc.getDisambiguated());
+			} else {
+				Assert.assertFalse(oc.getDisambiguated());
+			}
+		}
+	}
+
+	private void setConcepts(JCas jCas, EntityMention em1, String[] concepts) {
+		FSArray em1oc = new FSArray(jCas, concepts.length);
+		for (int i = 0; i < concepts.length; i++) {
+			OntologyConcept oc1 = new OntologyConcept(jCas);
+			oc1.setCode(concepts[i]);
+			em1oc.set(i, oc1);
+		}
+		em1.setOntologyConceptArr(em1oc);
+	}
+
+}

Added: ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/SentenceDetectorTest.java
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/SentenceDetectorTest.java?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/SentenceDetectorTest.java (added)
+++ ctakes/branches/ytex/ctakes-ytex-uima/src/test/java/org/apache/ctakes/ytex/uima/annotators/SentenceDetectorTest.java Mon Dec 16 16:30:30 2013
@@ -0,0 +1,67 @@
+package org.apache.ctakes.ytex.uima.annotators;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.apache.ctakes.typesystem.type.textspan.Segment;
+import org.apache.ctakes.typesystem.type.textspan.Sentence;
+import org.apache.uima.UIMAException;
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.cas.text.AnnotationIndex;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.tcas.Annotation;
+import org.apache.uima.util.XMLInputSource;
+import org.apache.uima.util.XMLParser;
+import org.junit.Assert;
+import org.junit.Test;
+import org.uimafit.factory.AggregateBuilder;
+
+/**
+ * TODO get rid of hard-coded path to Types.xml - load from classpath
+ * @author vgarla
+ *
+ */
+public class SentenceDetectorTest {
+
+	/**
+	 * Verify that date parsing with a manually created date works
+	 * @throws UIMAException
+	 * @throws Exception 
+	 */
+	@Test
+	public void testSentenceDetection() throws UIMAException, IOException {
+//	    JCas jCas = JCasFactory.createJCasFromPath("src/main/resources/org/apache/ctakes/ytex/types/TypeSystem.xml");
+	    String text = "Dr. Doolitle asked patient\nto take a deep breath\nand exhale slowly.  Patient coughed.";
+	    AggregateBuilder builder = new AggregateBuilder();
+	    File directoryCtakes = new File("../ctakes-core/desc/analysis_engine");
+	    File fileCtakes = new File(directoryCtakes, "TokenizerAnnotator.xml");
+	    XMLParser parser = UIMAFramework.getXMLParser();
+	    XMLInputSource source = new XMLInputSource(fileCtakes);
+	    builder.add(parser.parseAnalysisEngineDescription(source));
+	    File directory = new File("desc/analysis_engine");
+	    File file = new File(directory, "SentenceDetectorAnnotator.xml");
+	    source = new XMLInputSource(file);
+	    builder.add(parser.parseAnalysisEngineDescription(source));
+	    AnalysisEngine engine = builder.createAggregate();
+	    JCas jCas = engine.newJCas();
+	    jCas.setDocumentText(text);
+	    Segment s = new Segment(jCas);
+	    s.setBegin(0);
+	    s.setEnd(text.length());
+	    s.setId("DEFAULT");
+	    s.addToIndexes();
+	    // run the analysis engine
+	    engine.process(jCas);
+	    AnnotationIndex<Annotation> sentences = jCas.getAnnotationIndex(Sentence.type);
+		Iterator<Annotation> iter =sentences.iterator();
+		int sentCount = 0;
+		while(iter.hasNext()) {
+			Sentence sent = (Sentence)iter.next();
+			System.out.println("[" + sent.getCoveredText() + "]");
+			sentCount ++;
+		}
+		Assert.assertTrue(sentCount == 2);
+	}
+}

Added: ctakes/branches/ytex/ctakes-ytex/.classpath
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/.classpath?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/.classpath (added)
+++ ctakes/branches/ytex/ctakes-ytex/.classpath Mon Dec 16 16:30:30 2013
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java">
+		<attributes>
+			<attribute name="optional" value="true"/>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="src" output="target/classes" path="target/generated-sources/jaxb">
+		<attributes>
+			<attribute name="optional" value="true"/>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java">
+		<attributes>
+			<attribute name="optional" value="true"/>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: ctakes/branches/ytex/ctakes-ytex/.project
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/.project?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/.project (added)
+++ ctakes/branches/ytex/ctakes-ytex/.project Mon Dec 16 16:30:30 2013
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>ctakes-ytex</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: ctakes/branches/ytex/ctakes-ytex/.settings/org.eclipse.core.resources.prefs
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/.settings/org.eclipse.core.resources.prefs?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/.settings/org.eclipse.core.resources.prefs (added)
+++ ctakes/branches/ytex/ctakes-ytex/.settings/org.eclipse.core.resources.prefs Mon Dec 16 16:30:30 2013
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding//src/main/resources=UTF-8
+encoding//src/test/java=UTF-8
+encoding//src/test/resources=UTF-8
+encoding//target/generated-sources/jaxb=UTF-8
+encoding/<project>=UTF-8

Added: ctakes/branches/ytex/ctakes-ytex/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/.settings/org.eclipse.jdt.core.prefs?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/.settings/org.eclipse.jdt.core.prefs (added)
+++ ctakes/branches/ytex/ctakes-ytex/.settings/org.eclipse.jdt.core.prefs Mon Dec 16 16:30:30 2013
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6

Added: ctakes/branches/ytex/ctakes-ytex/.settings/org.eclipse.m2e.core.prefs
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/.settings/org.eclipse.m2e.core.prefs?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/.settings/org.eclipse.m2e.core.prefs (added)
+++ ctakes/branches/ytex/ctakes-ytex/.settings/org.eclipse.m2e.core.prefs Mon Dec 16 16:30:30 2013
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1

Added: ctakes/branches/ytex/ctakes-ytex/LICENSE
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/LICENSE?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/LICENSE (added)
+++ ctakes/branches/ytex/ctakes-ytex/LICENSE Mon Dec 16 16:30:30 2013
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

Added: ctakes/branches/ytex/ctakes-ytex/README
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/README?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/README (added)
+++ ctakes/branches/ytex/ctakes-ytex/README Mon Dec 16 16:30:30 2013
@@ -0,0 +1,36 @@
+Contents
+
+############
+Introduction
+############
+
+Need buildhelper m2e plugin
+
+== Developing ==
+YTEX is driven by a property file, ytex.properties.  The property file used when running ytex java programs 
+(aside from junit tests) is src\main\resources\org\apache\ctakes\ytex\ytex.properties.  Create this file
+for use when running java programs.
+
+YTEX relies on some config files generated from templates via an ant build script.  These config files are 
+generated automatically by the maven build (which runs the ant build script).  
+M2E is a bit (understatement) buggy, you may have to run the maven
+build from the command line so that things work correctly.
+
+== Testing ==
+
+YTEX is dependent upon a database which is set up by the ant script scripts\data\build.xml
+
+Note that all ytex-related tables in these databases will be dropped and recreated every time 
+the maven build is run (don't put data you want to keep there).
+  
+Maven runs the ant script prior to running the tests. 
+By default, we set up an hsqldb database for testing in the TEMP dir.
+Override this by:
+ * passing -Ddb.type=[mysql|mssql|orcl] to the maven command line.  If you do that,
+ we will use the \src\test\resources\org\apache\ctakes\ytex\ytex.${db.type}.properties
+ which point to the ytex_test schema (mysql/orcl) or catalog (mssql).
+ * or dropping your own ytex.properties in 
+ \src\test\resources\org\apache\ctakes\ytex.
+ 
+
+



Mime
View raw message