ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seanfi...@apache.org
Subject svn commit: r1719256 - in /ctakes/sandbox/dictionary-gui/src/main/java: ./ org/apache/ctakes/dictionary/creator/gui/ org/apache/ctakes/dictionary/creator/gui/ctakes/ org/apache/ctakes/dictionary/creator/gui/main/ org/apache/ctakes/dictionary/creator/gu...
Date Fri, 11 Dec 2015 05:10:28 GMT
Author: seanfinan
Date: Fri Dec 11 05:10:28 2015
New Revision: 1719256

URL: http://svn.apache.org/viewvc?rev=1719256&view=rev
Log:
Proto main panel with tui and source selection

Added:
    ctakes/sandbox/dictionary-gui/src/main/java/log4j2.xml
    ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/CreatorGui.java
    ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/ctakes/
    ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/main/
    ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/main/DirChooser.java
    ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/main/MainPanel.java
    ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/
    ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/MrconsoIndex.java
      - copied, changed from r1719001, ctakes/sandbox/dictionarytool/src/org/apache/ctakes/dictionarytool/util/index/MrconsoIndex.java
    ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/MrstyIndex.java
      - copied, changed from r1719001, ctakes/sandbox/dictionarytool/src/org/apache/ctakes/dictionarytool/util/index/MrstyIndex.java
    ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/SourceTableModel.java
    ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/Tui.java
    ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/TuiTableModel.java
    ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/util/
    ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/util/FileUtil.java
      - copied, changed from r1719001, ctakes/sandbox/dictionarytool/src/org/apache/ctakes/dictionarytool/util/FileUtil.java
    ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/util/TokenUtil.java
      - copied, changed from r1719001, ctakes/sandbox/dictionarytool/src/org/apache/ctakes/dictionarytool/util/TokenUtil.java

Added: ctakes/sandbox/dictionary-gui/src/main/java/log4j2.xml
URL: http://svn.apache.org/viewvc/ctakes/sandbox/dictionary-gui/src/main/java/log4j2.xml?rev=1719256&view=auto
==============================================================================
--- ctakes/sandbox/dictionary-gui/src/main/java/log4j2.xml (added)
+++ ctakes/sandbox/dictionary-gui/src/main/java/log4j2.xml Fri Dec 11 05:10:28 2015
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="WARN">
+	<Appenders>
+		<Console name="Console" target="SYSTEM_OUT">
+			<PatternLayout pattern="%-5p %c{1}:%L - %msg%n"/>
+		</Console> 
+	</Appenders>
+	<Loggers>
+		<Root level="info">
+			<AppenderRef ref="Console" />
+		</Root>
+	</Loggers>
+</Configuration>

Added: ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/CreatorGui.java
URL: http://svn.apache.org/viewvc/ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/CreatorGui.java?rev=1719256&view=auto
==============================================================================
--- ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/CreatorGui.java
(added)
+++ ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/CreatorGui.java
Fri Dec 11 05:10:28 2015
@@ -0,0 +1,61 @@
+package org.apache.ctakes.dictionary.creator.gui;
+
+
+import org.apache.ctakes.dictionary.creator.gui.main.MainPanel;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import javax.swing.*;
+import java.awt.*;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 12/10/2015
+ */
+public class CreatorGui {
+
+   static private final Logger LOGGER = LogManager.getLogger( CreatorGui.class );
+
+
+   static private JFrame createFrame() {
+      final JFrame frame = new JFrame( "cTAKES Dictionary Creator" );
+      frame.setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE );
+      // Use 1024 x 768 as the minimum required resolution (XGA)
+      // iPhone 3 : 480 x 320 (3:2, HVGA)
+      // iPhone 4 : 960 x 640  (3:2, unique to Apple)
+      // iPhone 5 : 1136 x 640 (under 16:9, unique to Apple)
+      // iPad 3&4 : 2048 x 1536 (4:3, QXGA)
+      // iPad Mini: 1024 x 768 (4:3, XGA)
+      final Dimension size = new Dimension( 1024, 768 );
+      frame.setSize( size );
+      frame.setMinimumSize( size );
+      final JMenuBar menuBar = new JMenuBar();
+      final JMenu fileMenu = new JMenu( "File" );
+      menuBar.add( fileMenu );
+
+      frame.setJMenuBar( menuBar );
+      System.setProperty( "apple.laf.useScreenMenuBar", "true" );
+      return frame;
+   }
+
+   static private JComponent createMainPanel() {
+      return new MainPanel();
+   }
+
+   public static void main( final String... args ) {
+      try {
+         UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
+         UIManager.getDefaults().put( "SplitPane.border", BorderFactory.createEmptyBorder()
);
+      } catch ( ClassNotFoundException | InstantiationException
+            | IllegalAccessException | UnsupportedLookAndFeelException multE ) {
+         LOGGER.error( multE.getLocalizedMessage() );
+      }
+      final JFrame frame = createFrame();
+      final JComponent mainPanel = createMainPanel();
+      frame.add( mainPanel );
+      frame.pack();
+      frame.setVisible( true );
+   }
+
+}

Added: ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/main/DirChooser.java
URL: http://svn.apache.org/viewvc/ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/main/DirChooser.java?rev=1719256&view=auto
==============================================================================
--- ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/main/DirChooser.java
(added)
+++ ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/main/DirChooser.java
Fri Dec 11 05:10:28 2015
@@ -0,0 +1,120 @@
+package org.apache.ctakes.dictionary.creator.gui.main;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import javax.swing.*;
+import javax.swing.border.EmptyBorder;
+import javax.swing.text.JTextComponent;
+import java.awt.*;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.DropTargetDropEvent;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 12/10/2015
+ */
+public class DirChooser extends JPanel {
+
+   static private final Logger LOGGER = LogManager.getLogger( "DirChooser" );
+
+   public DirChooser( final String name, final String defaultDirectory, final ActionListener
dirChangeListener ) {
+      super( new BorderLayout( 10, 10 ) );
+      setBorder( new EmptyBorder( 2, 10, 2, 10 ) );
+      final JLabel label = new JLabel( name );
+      label.setPreferredSize( new Dimension( 100, 0 ) );
+      label.setHorizontalAlignment( SwingConstants.TRAILING );
+      final JTextField textField = new JTextField( defaultDirectory );
+      textField.setEditable( false );
+      final JButton openChooserButton = new JButton( new OpenDirAction( textField, dirChangeListener
) );
+      add( label, BorderLayout.WEST );
+      add( textField, BorderLayout.CENTER );
+      add( openChooserButton, BorderLayout.EAST );
+
+      textField.setDropTarget( new DirDropTarget( textField, dirChangeListener ) );
+      textField.addActionListener( dirChangeListener );
+   }
+
+   /**
+    * Opens the JFileChooser
+    */
+   private class OpenDirAction extends AbstractAction {
+      private final JFileChooser __chooser;
+      private final JTextComponent __textComponent;
+      private final ActionListener __dirChangeListener;
+
+      private OpenDirAction( final JTextComponent textComponent, final ActionListener dirChangeListener
) {
+         super( "Select Directory" );
+         __textComponent = textComponent;
+         __chooser = new JFileChooser();
+         __chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
+         __dirChangeListener = dirChangeListener;
+      }
+
+      @Override
+      public void actionPerformed( final ActionEvent event ) {
+         final String startDirPath = __textComponent.getText();
+         if ( startDirPath != null && !startDirPath.isEmpty() ) {
+            final File startingDir = new File( startDirPath );
+            if ( startingDir.exists() ) {
+               __chooser.setCurrentDirectory( startingDir );
+            }
+         }
+         final int option = __chooser.showOpenDialog( null );
+         if ( option != JFileChooser.APPROVE_OPTION ) {
+            return;
+         }
+         final File file = __chooser.getSelectedFile();
+         __textComponent.setText( file.getAbsolutePath() );
+         final ActionEvent dirEvent = new ActionEvent( this, ActionEvent.ACTION_FIRST, file.getAbsolutePath()
);
+         __dirChangeListener.actionPerformed( dirEvent );
+      }
+   }
+
+
+   private class DirDropTarget extends DropTarget {
+      private final JTextComponent __textComponent;
+      private final ActionListener __dirChangeListener;
+      private DirDropTarget( final JTextComponent textComponent, final ActionListener dirChangeListener
) {
+         __textComponent = textComponent;
+         __dirChangeListener = dirChangeListener;
+      }
+      @Override
+      public synchronized void drop( final DropTargetDropEvent event ) {
+         event.acceptDrop( DnDConstants.ACTION_COPY );
+         try {
+            final Object values = event.getTransferable().getTransferData( DataFlavor.javaFileListFlavor
);
+            if ( !(values instanceof Iterable) ) {
+               return;
+            }
+            for ( Object value : (Iterable)values ) {
+               if ( !(value instanceof File) ) {
+                  continue;
+               }
+               final File file = (File)value;
+               if ( !file.isDirectory() ) {
+                  continue;
+               }
+               __textComponent.setText( file.getAbsolutePath() );
+               final ActionEvent dirEvent
+                     = new ActionEvent( this, ActionEvent.ACTION_FIRST, file.getAbsolutePath()
);
+               __dirChangeListener.actionPerformed( dirEvent );
+               return;
+            }
+         } catch ( UnsupportedFlavorException | IOException multE ) {
+            LOGGER.warn( multE.getMessage() );
+         }
+      }
+   }
+
+
+
+}

Added: ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/main/MainPanel.java
URL: http://svn.apache.org/viewvc/ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/main/MainPanel.java?rev=1719256&view=auto
==============================================================================
--- ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/main/MainPanel.java
(added)
+++ ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/main/MainPanel.java
Fri Dec 11 05:10:28 2015
@@ -0,0 +1,81 @@
+package org.apache.ctakes.dictionary.creator.gui.main;
+
+import org.apache.ctakes.dictionary.creator.gui.umls.SourceTableModel;
+import org.apache.ctakes.dictionary.creator.gui.umls.TuiTableModel;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import javax.swing.*;
+import javax.swing.table.TableModel;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 12/10/2015
+ */
+final public class MainPanel extends JPanel {
+
+   static private final Logger LOGGER = LogManager.getLogger( "MainPanel" );
+
+
+   public MainPanel() {
+      super( new BorderLayout() );
+
+      final SourceTableModel sourceModel = new SourceTableModel();
+
+      final JComponent sourceDirPanel = new JPanel( new GridLayout( 2, 1 ) );
+      sourceDirPanel.add( new DirChooser("Ctakes Installation:", "C:/", new CtakesDirListener()
) );
+      sourceDirPanel.add( new DirChooser( "UMLS Installation:", "C:/", new UmlsDirListener(
sourceModel ) ) );
+      add( sourceDirPanel, BorderLayout.NORTH );
+
+      add( createTuiTable(), BorderLayout.WEST );
+      add( createSourceTable( sourceModel ), BorderLayout.EAST );
+   }
+
+   private JComponent createTuiTable() {
+      final JTable tuiTable = new JTable( new TuiTableModel() );
+      tuiTable.setCellSelectionEnabled( false );
+      tuiTable.setShowVerticalLines( false );
+      tuiTable.setAutoCreateRowSorter( true );
+      tuiTable.setAutoResizeMode( JTable.AUTO_RESIZE_LAST_COLUMN );
+      tuiTable.getColumnModel().getColumn( 0 ).setMaxWidth( 50 );
+      tuiTable.getColumnModel().getColumn( 1 ).setMaxWidth( 50 );
+      return new JScrollPane( tuiTable );
+   }
+
+   private JComponent createSourceTable( final TableModel sourceModel ) {
+      final JTable tuiTable = new JTable( sourceModel );
+      tuiTable.setCellSelectionEnabled( false );
+      tuiTable.setShowVerticalLines( false );
+      tuiTable.setAutoCreateRowSorter( true );
+      tuiTable.setAutoResizeMode( JTable.AUTO_RESIZE_LAST_COLUMN );
+      tuiTable.getColumnModel().getColumn( 0 ).setMaxWidth( 50 );
+      tuiTable.getColumnModel().getColumn( 1 ).setMaxWidth( 50 );
+      return new JScrollPane( tuiTable );
+   }
+
+
+   private class UmlsDirListener implements ActionListener {
+      final private SourceTableModel __sourceModel;
+      private UmlsDirListener( final SourceTableModel sourceModel ) {
+         __sourceModel = sourceModel;
+      }
+      public void actionPerformed( final ActionEvent event ) {
+         __sourceModel.initialize( event.getActionCommand() );
+      }
+   }
+
+
+   private class CtakesDirListener implements ActionListener {
+      public void actionPerformed( final ActionEvent event ) {
+         LOGGER.info( "Directory changed to " + event.getSource().getClass().getName()
+                      + " " + event.getID() + " " + event.getActionCommand() );
+      }
+   }
+
+
+
+}

Copied: ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/MrconsoIndex.java
(from r1719001, ctakes/sandbox/dictionarytool/src/org/apache/ctakes/dictionarytool/util/index/MrconsoIndex.java)
URL: http://svn.apache.org/viewvc/ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/MrconsoIndex.java?p2=ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/MrconsoIndex.java&p1=ctakes/sandbox/dictionarytool/src/org/apache/ctakes/dictionarytool/util/index/MrconsoIndex.java&r1=1719001&r2=1719256&rev=1719256&view=diff
==============================================================================
--- ctakes/sandbox/dictionarytool/src/org/apache/ctakes/dictionarytool/util/index/MrconsoIndex.java
(original)
+++ ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/MrconsoIndex.java
Fri Dec 11 05:10:28 2015
@@ -1,4 +1,4 @@
-package org.apache.ctakes.dictionarytool.util.index;
+package org.apache.ctakes.dictionary.creator.gui.umls;
 
 /**
  * Author: SPF

Copied: ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/MrstyIndex.java
(from r1719001, ctakes/sandbox/dictionarytool/src/org/apache/ctakes/dictionarytool/util/index/MrstyIndex.java)
URL: http://svn.apache.org/viewvc/ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/MrstyIndex.java?p2=ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/MrstyIndex.java&p1=ctakes/sandbox/dictionarytool/src/org/apache/ctakes/dictionarytool/util/index/MrstyIndex.java&r1=1719001&r2=1719256&rev=1719256&view=diff
==============================================================================
--- ctakes/sandbox/dictionarytool/src/org/apache/ctakes/dictionarytool/util/index/MrstyIndex.java
(original)
+++ ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/MrstyIndex.java
Fri Dec 11 05:10:28 2015
@@ -1,4 +1,4 @@
-package org.apache.ctakes.dictionarytool.util.index;
+package org.apache.ctakes.dictionary.creator.gui.umls;
 
 /**
  * Author: SPF

Added: ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/SourceTableModel.java
URL: http://svn.apache.org/viewvc/ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/SourceTableModel.java?rev=1719256&view=auto
==============================================================================
--- ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/SourceTableModel.java
(added)
+++ ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/SourceTableModel.java
Fri Dec 11 05:10:28 2015
@@ -0,0 +1,208 @@
+package org.apache.ctakes.dictionary.creator.gui.umls;
+
+
+import org.apache.ctakes.dictionary.creator.util.FileUtil;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import javax.swing.event.EventListenerList;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+import javax.swing.table.TableModel;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 12/10/2015
+ */
+final public class SourceTableModel implements TableModel {
+
+   static private final Logger LOGGER = LogManager.getLogger( "SourceTableModel" );
+
+   static private final String[] COLUMN_NAMES = { "Source", "Target", "Library" };
+   static private final Class<?>[] COLUMN_CLASSES = { Boolean.class, Boolean.class,
String.class };
+
+   static private final String[] CTAKES_SOURCES = { "SNOMEDCT", "SNOMEDCT_US", "RXNORM" };
+
+   private final EventListenerList _listenerList = new EventListenerList();
+   private final Map<String,Boolean> _useSource = new HashMap<>();
+   private final Map<String,Boolean> _useTarget = new HashMap<>();
+   private final List<String> _sources = new ArrayList<>();
+
+
+
+   public void initialize( final String umlsDirPath ) {
+      _sources.clear();
+      _useSource.clear();
+      _useTarget.clear();
+      File mrConso = new File( umlsDirPath, "MRCONSO.RRF" );
+      if ( !mrConso.exists() ) {
+         mrConso = new File( umlsDirPath + "/META/MRCONSO.RRF" );
+         if ( !mrConso.exists() ) {
+            LOGGER.error( "No MRCONSO.RRF in " + umlsDirPath );
+            return;
+         }
+      }
+      final String mrConsoPath = mrConso.getPath();
+      LOGGER.info( "Parsing source types from " + mrConsoPath );
+      final Collection<String> sources = new HashSet<>();
+      try ( final BufferedReader reader = FileUtil.createReader( mrConsoPath ) ) {
+         int lineCount = 0;
+         List<String> tokens = FileUtil.readBsvTokens( reader, mrConsoPath );
+         while ( tokens != null ) {
+            lineCount++;
+            if ( tokens.size() > MrconsoIndex.SOURCE._index ) {
+               sources.add( tokens.get( MrconsoIndex.SOURCE._index ) );
+            }
+            if ( lineCount % 100000 == 0 ) {
+               LOGGER.info( "File Line " + lineCount + "\t Sources " + sources.size() );
+            }
+            tokens = FileUtil.readBsvTokens( reader, mrConsoPath );
+         }
+         LOGGER.info( "Parsed " + sources.size() + " source types" );
+      } catch ( IOException ioE ) {
+         LOGGER.error( ioE.getMessage() );
+      }
+      _sources.addAll( sources );
+      Collections.sort( _sources );
+      for ( String source : CTAKES_SOURCES ) {
+         _useSource.put( source, true );
+         _useTarget.put( source, true );
+      }
+      fireTableChanged( new TableModelEvent( this ) );
+   }
+
+
+   public Collection<String> getWantedSources() {
+      return _useSource.keySet();
+   }
+
+   public Collection<String> getWantedTargets() {
+      return _useTarget.keySet();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public int getRowCount() {
+      return _sources.size();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public int getColumnCount() {
+      return 3;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public String getColumnName( final int columnIndex ) {
+      return COLUMN_NAMES[ columnIndex ];
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public Class<?> getColumnClass( final int columnIndex ) {
+      return COLUMN_CLASSES[ columnIndex ];
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public boolean isCellEditable( final int rowIndex, final int columnIndex ) {
+      return columnIndex == 0 || (columnIndex == 1 && (Boolean)getValueAt( rowIndex,
0 ) );
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public Object getValueAt( final int rowIndex, final int columnIndex ) {
+      final String source = _sources.get( rowIndex );
+      switch ( columnIndex ) {
+         case 0 : return isSourceEnabled( source );
+         case 1 : return isTargetEnabled( source );
+         case 2 : return source;
+      }
+      return "ERROR";
+   }
+
+   private boolean isSourceEnabled( final String source ) {
+      final Boolean enabled = _useSource.get( source );
+      return enabled != null && enabled;
+   }
+
+   private boolean isTargetEnabled( final String source) {
+      final Boolean enabled = _useTarget.get( source );
+      return enabled != null && enabled;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void setValueAt( final Object aValue, final int rowIndex, final int columnIndex
) {
+      if ( aValue instanceof Boolean ) {
+         final String source = _sources.get( rowIndex );
+         if ( columnIndex == 0 ) {
+            _useSource.put( source, (Boolean)aValue );
+         } else if ( columnIndex == 1 ) {
+            _useTarget.put( source, (Boolean)aValue );
+         }
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void addTableModelListener( final TableModelListener listener ) {
+      _listenerList.add( TableModelListener.class, listener );
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void removeTableModelListener( final TableModelListener listener ) {
+      _listenerList.remove( TableModelListener.class, listener );
+   }
+
+   /**
+    * Forwards the given notification event to all
+    * <code>TableModelListeners</code> that registered
+    * themselves as listeners for this table model.
+    *
+    * @param e  the event to be forwarded
+    *
+    * @see #addTableModelListener
+    * @see TableModelEvent
+    * @see EventListenerList
+    */
+   private void fireTableChanged(TableModelEvent e) {
+      // Guaranteed to return a non-null array
+      Object[] listeners = _listenerList.getListenerList();
+      // Process the listeners last to first, notifying
+      // those that are interested in this event
+      for (int i = listeners.length-2; i>=0; i-=2) {
+         if (listeners[i]==TableModelListener.class) {
+            ((TableModelListener)listeners[i+1]).tableChanged(e);
+         }
+      }
+   }
+
+
+
+}

Added: ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/Tui.java
URL: http://svn.apache.org/viewvc/ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/Tui.java?rev=1719256&view=auto
==============================================================================
--- ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/Tui.java
(added)
+++ ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/Tui.java
Fri Dec 11 05:10:28 2015
@@ -0,0 +1,167 @@
+package org.apache.ctakes.dictionary.creator.gui.umls;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 12/10/2015
+ */
+public enum Tui {
+   // Activities & Behaviors
+   T052( "Activity" ),
+   T053( "Behavior" ),
+   T056( "Daily or Recreational Activity" ),
+   T051( "Event" ),
+   T064( "Governmental or Regulatory Activity" ),
+   T055( "Individual Behavior" ),
+   T066( "Machine Activity" ),
+   T057( "Occupational Activity" ),
+   T054( "Social Behavior" ),
+   // Anatomy
+   T017( "Anatomical Structure" ),
+   T029( "Body Location or Region" ),
+   T023( "Body Part, Organ, or Organ Component" ),
+   T030( "Body Space or Junction" ),
+   T031( "Body Substance" ),
+   T022( "Body System" ),
+   T025( "Cell" ),
+   T026( "Cell Component" ),
+   T018( "Embryonic Structure" ),
+   T021( "Fully Formed Anatomical Structure" ),
+   T024( "Tissue" ),
+   // Chemicals & Drugs
+   T116( "Amino Acid, Peptide, or Protein" ),
+   T195( "Antibiotic" ),
+   T123( "Biologically Active Substance" ),
+   T122( "Biomedical or Dental Material" ),
+   T118( "Carbohydrate" ),
+   T103( "Chemical" ),
+   T120( "Chemical Viewed Functionally" ),
+   T104( "Chemical Viewed Structurally" ),
+   T200( "Clinical Drug" ),
+   T111( "Eicosanoid" ),
+   T196( "Element, Ion, or Isotope" ),
+   T126( "Enzyme" ),
+   T131( "Hazardous or Poisonous Substance" ),
+   T125( "Hormone" ),
+   T129( "Immunologic Factor" ),
+   T130( "Indicator, Reagent, or Diagnostic Aid" ),
+   T197( "Inorganic Chemical" ),
+   T119( "Lipid" ),
+   T124( "Neuroreactive Substance or Biogenic Amine" ),
+   T114( "Nucleic Acid, Nucleoside, or Nucleotide" ),
+   T109( "Organic Chemical" ),
+   T115( "Organophosphorus Compound" ),
+   T121( "Pharmacologic Substance" ),
+   T192( "Receptor" ),
+   T110( "Steroid" ),
+   T127( "Vitamin" ),
+   // Concepts & Ideas
+   T185( "Classification" ),
+   T077( "Conceptual Entity" ),
+   T169( "Functional Concept" ),
+   T102( "Group Attribute" ),
+   T078( "Idea or Concept" ),
+   T170( "Intellectual Product" ),
+   T171( "Language" ),
+   T080( "Qualitative Concept" ),
+   T081( "Quantitative Concept" ),
+   T089( "Regulation or Law" ),
+   T082( "Spatial Concept" ),
+   T079( "Temporal Concept" ),
+   // Devices
+   T203( "Drug Delivery Device" ),
+   T074( "Medical Device" ),
+   T075( "Research Device" ),
+   // Disorders
+   T020( "Acquired Abnormality" ),
+   T190( "Anatomical Abnormality" ),
+   T049( "Cell or Molecular Dysfunction" ),
+   T019( "Congenital Abnormality" ),
+   T047( "Disease or Syndrome" ),
+   T050( "Experimental Model of Disease" ),
+   T033( "Finding" ),
+   T037( "Injury or Poisoning" ),
+   T048( "Mental or Behavioral Dysfunction" ),
+   T191( "Neoplastic Process" ),
+   T046( "Pathologic Function" ),
+   T184( "Sign or Symptom" ),
+   // Genes & Molecular Sequences
+   T087( "Amino Acid Sequence" ),
+   T088( "Carbohydrate Sequence" ),
+   T028( "Gene or Genome" ),
+   T085( "Molecular Sequence" ),
+   T086( "Nucleotide Sequence" ),
+   // Geographic Areas
+   T083( "Geographic Area" ),
+   // Living Beings
+   T100( "Age Group" ),
+   T011( "Amphibian" ),
+   T008( "Animal" ),
+   T194( "Archaeon" ),
+   T007( "Bacterium" ),
+   T012( "Bird" ),
+   T204( "Eukaryote" ),
+   T099( "Family Group" ),
+   T013( "Fish" ),
+   T004( "Fungus" ),
+   T096( "Group" ),
+   T016( "Human" ),
+   T015( "Mammal" ),
+   T001( "Organism" ),
+   T101( "Patient or Disabled Group" ),
+   T002( "Plant" ),
+   T098( "Population Group" ),
+   T097( "Professional or Occupational Group" ),
+   T014( "Reptile" ),
+   T010( "Vertebrate" ),
+   T005( "Virus" ),
+   // Objects
+   T071( "Entity" ),
+   T168( "Food" ),
+   T073( "Manufactured Object" ),
+   T072( "Physical Object" ),
+   T167( "Substance" ),
+   // Occupations
+   T091( "Biomedical Occupation or Discipline" ),
+   T090( "Occupation or Discipline" ),
+   // Organizations
+   T093( "Health Care Related Organization" ),
+   T092( "Organization" ),
+   T094( "Professional Society" ),
+   T095( "Self-help or Relief Organization" ),
+   // Phenomena
+   T038( "Biologic Function" ),
+   T069( "Environmental Effect of Humans" ),
+   T068( "Human-caused Phenomenon or Process" ),
+   T034( "Laboratory or Test Result" ),
+   T070( "Natural Phenomenon or Process" ),
+   T067( "Phenomenon or Process" ),
+   // Physiology
+   T043( "Cell Function" ),
+   T201( "Clinical Attribute" ),
+   T045( "Genetic Function" ),
+   T041( "Mental Process" ),
+   T044( "Molecular Function" ),
+   T032( "Organism Attribute" ),
+   T040( "Organism Function" ),
+   T042( "Organ or Tissue Function" ),
+   T039( "Physiologic Function" ),
+   // Procedures
+   T060( "Diagnostic Procedure" ),
+   T065( "Educational Activity" ),
+   T058( "Health Care Activity" ),
+   T059( "Laboratory Procedure" ),
+   T063( "Molecular Biology Research Technique" ),
+   T062( "Research Activity" ),
+   T061( "Therapeutic or Preventive Procedure" );
+
+   final private String _description;
+   private Tui( final String description ) {
+      _description = description;
+   }
+
+   public String getDescription() {
+      return _description;
+   }
+
+}

Added: ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/TuiTableModel.java
URL: http://svn.apache.org/viewvc/ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/TuiTableModel.java?rev=1719256&view=auto
==============================================================================
--- ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/TuiTableModel.java
(added)
+++ ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/gui/umls/TuiTableModel.java
Fri Dec 11 05:10:28 2015
@@ -0,0 +1,142 @@
+package org.apache.ctakes.dictionary.creator.gui.umls;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import javax.swing.event.EventListenerList;
+import javax.swing.event.TableModelListener;
+import javax.swing.table.TableModel;
+import java.util.EnumMap;
+import java.util.Map;
+
+import static org.apache.ctakes.dictionary.creator.gui.umls.Tui.*;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 12/10/2015
+ */
+final public class TuiTableModel implements TableModel {
+
+   static private final Logger LOGGER = LogManager.getLogger( "TuiTableModel" );
+
+   static private final Tui[] CTAKES_ANAT = { T021, T022, T023, T024, T025, T026, T029, T030
};
+   static private final Tui[] CTAKES_DISO = { T019, T020, T037, T047, T048, T049, T050, T190,
T191 };
+   static private final Tui[] CTAKES_FIND = { T033, T034, T040, T041, T042, T043, T044, T045,
T046, T056, T057, T184 };
+   static private final Tui[] CTAKES_PROC = { T059, T060, T061 };
+   static private final Tui[] CTAKES_DRUG = { T109, T110, T114, T115, T116, T118, T119, T121,
T122, T123, T124,
+                                              T125, T126, T127, T129, T130, T131, T195, T196,
T197, T200, T203 };
+
+   static private final String[] COLUMN_NAMES = { "Use", "TUI", "Definition" };
+   static private final Class<?>[] COLUMN_CLASSES = { Boolean.class, String.class,
String.class };
+
+   private final EventListenerList _listenerList = new EventListenerList();
+   private final Map<Tui,Boolean> _usedTuis = new EnumMap<>( Tui.class );
+
+   public TuiTableModel() {
+      for ( Tui tui : CTAKES_ANAT ) {
+         _usedTuis.put( tui, true );
+      }
+      for ( Tui tui : CTAKES_DISO ) {
+         _usedTuis.put( tui, true );
+      }
+      for ( Tui tui : CTAKES_FIND ) {
+         _usedTuis.put( tui, true );
+      }
+      for ( Tui tui : CTAKES_PROC ) {
+         _usedTuis.put( tui, true );
+      }
+      for ( Tui tui : CTAKES_DRUG ) {
+         _usedTuis.put( tui, true );
+      }
+   }
+
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public int getRowCount() {
+      return Tui.values().length;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public int getColumnCount() {
+      return 3;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public String getColumnName( final int columnIndex ) {
+      return COLUMN_NAMES[ columnIndex ];
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public Class<?> getColumnClass( final int columnIndex ) {
+      return COLUMN_CLASSES[ columnIndex ];
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public boolean isCellEditable( final int rowIndex, final int columnIndex ) {
+      return columnIndex == 0;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public Object getValueAt( final int rowIndex, final int columnIndex ) {
+      final Tui tui = Tui.values()[ rowIndex ];
+      switch ( columnIndex ) {
+         case 0 : return isTuiEnabled( tui );
+         case 1 : return tui.name();
+         case 2 : return tui.getDescription();
+      }
+      return "ERROR";
+   }
+
+   private boolean isTuiEnabled( final Tui tui ) {
+      final Boolean enabled = _usedTuis.get( tui );
+      return enabled != null && enabled;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void setValueAt( final Object aValue, final int rowIndex, final int columnIndex
) {
+      if ( aValue instanceof Boolean && columnIndex == 0 ) {
+         final Tui tui = Tui.values()[ rowIndex ];
+         _usedTuis.put( tui, (Boolean)aValue );
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void addTableModelListener( final TableModelListener listener ) {
+      _listenerList.add( TableModelListener.class, listener );
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void removeTableModelListener( final TableModelListener listener ) {
+      _listenerList.remove( TableModelListener.class, listener );
+   }
+
+
+}

Copied: ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/util/FileUtil.java
(from r1719001, ctakes/sandbox/dictionarytool/src/org/apache/ctakes/dictionarytool/util/FileUtil.java)
URL: http://svn.apache.org/viewvc/ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/util/FileUtil.java?p2=ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/util/FileUtil.java&p1=ctakes/sandbox/dictionarytool/src/org/apache/ctakes/dictionarytool/util/FileUtil.java&r1=1719001&r2=1719256&rev=1719256&view=diff
==============================================================================
--- ctakes/sandbox/dictionarytool/src/org/apache/ctakes/dictionarytool/util/FileUtil.java
(original)
+++ ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/util/FileUtil.java
Fri Dec 11 05:10:28 2015
@@ -1,20 +1,10 @@
-package org.apache.ctakes.dictionarytool.util;
+package org.apache.ctakes.dictionary.creator.util;
 
-import org.apache.ctakes.dictionarytool.util.collection.HashSetMap;
+//import org.apache.ctakes.dictionarytool.util.collection.HashSetMap;
 
 import javax.swing.filechooser.FileSystemView;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.io.*;
+import java.util.*;
 import java.util.logging.Logger;
 
 /**
@@ -178,27 +168,27 @@ final public class FileUtil {
       return listItems;
    }
 
-   static public void writeNamedSets( final String filePath, final String description,
-                                      final HashSetMap<String, String> namedSets )
{
-      System.out.println( "Writing " + description + " to " + filePath );
-      long lineCount = 0;
-      try {
-         final BufferedWriter writer = createWriter( filePath );
-         for ( Map.Entry<String, Set<String>> namedSet : namedSets.entrySet()
) {
-            lineCount++;
-            writer.write( TokenUtil.createBsvLine( namedSet.getKey(),
-                                                   TokenUtil.createCsvLine( namedSet.getValue()
) ) );
-            writer.newLine();
-            if ( lineCount % 100000 == 0 ) {
-               System.out.println( "File Line " + lineCount );
-            }
-         }
-         writer.close();
-      } catch ( IOException ioE ) {
-         System.err.println( "Error writing " + description + " on line " + lineCount + "
in file " + filePath );
-      }
-      System.out.println( "Wrote " + lineCount + " " + description + " to " + filePath );
-   }
+//   static public void writeNamedSets( final String filePath, final String description,
+//                                      final HashSetMap<String, String> namedSets
) {
+//      System.out.println( "Writing " + description + " to " + filePath );
+//      long lineCount = 0;
+//      try {
+//         final BufferedWriter writer = createWriter( filePath );
+//         for ( Map.Entry<String, Set<String>> namedSet : namedSets.entrySet()
) {
+//            lineCount++;
+//            writer.write( TokenUtil.createBsvLine( namedSet.getKey(),
+//                                                   TokenUtil.createCsvLine( namedSet.getValue()
) ) );
+//            writer.newLine();
+//            if ( lineCount % 100000 == 0 ) {
+//               System.out.println( "File Line " + lineCount );
+//            }
+//         }
+//         writer.close();
+//      } catch ( IOException ioE ) {
+//         System.err.println( "Error writing " + description + " on line " + lineCount +
" in file " + filePath );
+//      }
+//      System.out.println( "Wrote " + lineCount + " " + description + " to " + filePath
);
+//   }
 
    /**
     * @deprecated
@@ -242,18 +232,18 @@ final public class FileUtil {
       return namedSets;
    }
 
-   static public HashSetMap<String, String> readNamedSets( final String filePath, final
String description ) {
-      final Collection<String> lines = readOneColumn( filePath, description );
-      final HashSetMap<String, String> namedSets = new HashSetMap<>( lines.size()
);
-      for ( String line : lines ) {
-         final List<String> nameAndList = TokenUtil.getBsvItems( line );
-         if ( nameAndList == null || nameAndList.size() != 2 ) {
-            System.err.println( "Bad line " + line );
-            continue;
-         }
-         namedSets.addAll( nameAndList.get( 0 ), TokenUtil.getCsvItems( nameAndList.get(
1 ) ) );
-      }
-      return namedSets;
-   }
+//   static public HashSetMap<String, String> readNamedSets( final String filePath,
final String description ) {
+//      final Collection<String> lines = readOneColumn( filePath, description );
+//      final HashSetMap<String, String> namedSets = new HashSetMap<>( lines.size()
);
+//      for ( String line : lines ) {
+//         final List<String> nameAndList = TokenUtil.getBsvItems( line );
+//         if ( nameAndList == null || nameAndList.size() != 2 ) {
+//            System.err.println( "Bad line " + line );
+//            continue;
+//         }
+//         namedSets.addAll( nameAndList.get( 0 ), TokenUtil.getCsvItems( nameAndList.get(
1 ) ) );
+//      }
+//      return namedSets;
+//   }
 
 }

Copied: ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/util/TokenUtil.java
(from r1719001, ctakes/sandbox/dictionarytool/src/org/apache/ctakes/dictionarytool/util/TokenUtil.java)
URL: http://svn.apache.org/viewvc/ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/util/TokenUtil.java?p2=ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/util/TokenUtil.java&p1=ctakes/sandbox/dictionarytool/src/org/apache/ctakes/dictionarytool/util/TokenUtil.java&r1=1719001&r2=1719256&rev=1719256&view=diff
==============================================================================
--- ctakes/sandbox/dictionarytool/src/org/apache/ctakes/dictionarytool/util/TokenUtil.java
(original)
+++ ctakes/sandbox/dictionary-gui/src/main/java/org/apache/ctakes/dictionary/creator/util/TokenUtil.java
Fri Dec 11 05:10:28 2015
@@ -1,4 +1,4 @@
-package org.apache.ctakes.dictionarytool.util;
+package org.apache.ctakes.dictionary.creator.util;
 
 import java.util.ArrayList;
 import java.util.Collection;




Mime
View raw message