コード例 #1
0
        public virtual void Redraw()
        {
            string text = editorPane.GetText();

            taggedContents   = null;
            untaggedContents = null;
            if (!editorPane.GetContentType().Equals("text/html"))
            {
                editorPane.SetContentType("text/rtf");
                IDocument doc = editorPane.GetDocument();
                try
                {
                    doc.InsertString(0, text, defaultAttrSet);
                }
                catch (Exception e)
                {
                    throw new Exception(e);
                }
                editorPane.Revalidate();
                editorPane.Repaint();
                editorPane.SetEditable(true);
                htmlContents = null;
            }
            else
            {
                editorPane.SetEditable(false);
                htmlContents = editorPane.GetText();
            }
            saveUntagged.SetEnabled(false);
            saveTaggedAs.SetEnabled(false);
        }
コード例 #2
0
 // = null;
 // = null;
 // = null;
 // = null;
 // = null;
 // = null;
 private void CreateAndShowGUI()
 {
     //Make sure we have nice window decorations.
     JFrame.SetDefaultLookAndFeelDecorated(true);
     //Create and set up the window.
     frame = new JFrame("Stanford Named Entity Recognizer");
     frame.SetDefaultCloseOperation(WindowConstantsConstants.ExitOnClose);
     frame.GetContentPane().SetLayout(new BorderLayout());
     frame.GetContentPane().SetPreferredSize(new Dimension(Width, Height));
     frame.SetJMenuBar(AddMenuBar());
     BuildTagPanel();
     BuildContentPanel();
     BuildExtractButton();
     extractButton.SetEnabled(false);
     extract.SetEnabled(false);
     //Display the window.
     frame.Pack();
     frame.SetVisible(true);
 }
コード例 #3
0
 public virtual void SaveUntaggedContents(File file)
 {
     try
     {
         string contents;
         if (editorPane.GetContentType().Equals("text/html"))
         {
             contents = editorPane.GetText();
         }
         else
         {
             IDocument doc = editorPane.GetDocument();
             contents = doc.GetText(0, doc.GetLength());
         }
         SaveFile(file, contents);
         saveUntagged.SetEnabled(true);
         loadedFile = file;
     }
     catch (Exception e)
     {
         throw new Exception(e);
     }
 }
コード例 #4
0
        private void OpenURL(string url)
        {
            try
            {
                editorPane.SetPage(url);
            }
            catch (Exception e)
            {
                log.Info("Error loading |" + url + '|');
                log.Warn(e);
                DisplayError("Error Loading URL " + url, "Message: " + e);
                return;
            }
            loadedFile = null;
            string text = editorPane.GetText();

            taggedContents = null;
            if (!editorPane.GetContentType().Equals("text/html"))
            {
                editorPane.SetContentType("text/rtf");
                IDocument doc = editorPane.GetDocument();
                try
                {
                    doc.InsertString(0, text, defaultAttrSet);
                }
                catch (Exception e)
                {
                    throw new Exception(e);
                }
                editorPane.Revalidate();
                editorPane.Repaint();
                editorPane.SetEditable(true);
                htmlContents = null;
            }
            else
            {
                editorPane.SetEditable(false);
                htmlContents = editorPane.GetText();
            }
            saveUntagged.SetEnabled(false);
            saveTaggedAs.SetEnabled(false);
        }
コード例 #5
0
        private JMenuBar AddMenuBar()
        {
            JMenuBar menubar  = new JMenuBar();
            JMenu    fileMenu = new JMenu("File");

            menubar.Add(fileMenu);
            JMenu editMenu = new JMenu("Edit");

            menubar.Add(editMenu);
            JMenu classifierMenu = new JMenu("Classifier");

            menubar.Add(classifierMenu);
            int menuMask = Toolkit.GetDefaultToolkit().GetMenuShortcutKeyMask();

            /*
             * FILE MENU
             */
            JMenuItem openFile = new JMenuItem("Open File");

            openFile.SetMnemonic('O');
            openFile.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkF, menuMask));
            openFile.AddActionListener(actor);
            fileMenu.Add(openFile);
            JMenuItem loadURL = new JMenuItem("Load URL");

            loadURL.SetMnemonic('L');
            loadURL.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkU, menuMask));
            loadURL.AddActionListener(actor);
            fileMenu.Add(loadURL);
            fileMenu.Add(new JSeparator());
            saveUntagged = new JMenuItem("Save Untagged File");
            saveUntagged.SetMnemonic('S');
            saveUntagged.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkS, menuMask));
            saveUntagged.AddActionListener(actor);
            saveUntagged.SetEnabled(false);
            fileMenu.Add(saveUntagged);
            JMenuItem saveUntaggedAs = new JMenuItem("Save Untagged File As ...");

            saveUntaggedAs.SetMnemonic('U');
            saveUntaggedAs.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkU, menuMask));
            saveUntaggedAs.AddActionListener(actor);
            fileMenu.Add(saveUntaggedAs);
            saveTaggedAs = new JMenuItem("Save Tagged File As ...");
            saveTaggedAs.SetMnemonic('T');
            saveTaggedAs.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkT, menuMask));
            saveTaggedAs.AddActionListener(actor);
            saveTaggedAs.SetEnabled(false);
            fileMenu.Add(saveTaggedAs);
            fileMenu.Add(new JSeparator());
            JMenuItem exit = new JMenuItem("Exit");

            exit.SetMnemonic('x');
            exit.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkQ, menuMask));
            exit.AddActionListener(actor);
            fileMenu.Add(exit);

            /*
             * EDIT MENU
             */
            JMenuItem clear = new JMenuItem("Clear");

            clear.SetMnemonic('C');
            clear.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkL, menuMask));
            clear.AddActionListener(actor);
            editMenu.Add(clear);

            /*
             * CLASSIFIER MENU
             */
            JMenuItem loadCRF = new JMenuItem("Load CRF From File");

            loadCRF.SetMnemonic('R');
            loadCRF.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkR, menuMask));
            loadCRF.AddActionListener(actor);
            classifierMenu.Add(loadCRF);
            JMenuItem loadDefaultCRF = new JMenuItem("Load Default CRF");

            loadDefaultCRF.SetMnemonic('L');
            loadDefaultCRF.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkL, menuMask));
            loadDefaultCRF.AddActionListener(actor);
            classifierMenu.Add(loadDefaultCRF);
            JMenuItem loadCMM = new JMenuItem("Load CMM From File");

            loadCMM.SetMnemonic('M');
            loadCMM.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkM, menuMask));
            loadCMM.AddActionListener(actor);
            classifierMenu.Add(loadCMM);
            JMenuItem loadDefaultCMM = new JMenuItem("Load Default CMM");

            loadDefaultCMM.SetMnemonic('D');
            loadDefaultCMM.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkD, menuMask));
            loadDefaultCMM.AddActionListener(actor);
            classifierMenu.Add(loadDefaultCMM);
            return(menubar);
        }
コード例 #6
0
        private JMenuBar AddMenuBar()
        {
            JMenuBar menubar           = new JMenuBar();
            int      shortcutMask      = Toolkit.GetDefaultToolkit().GetMenuShortcutKeyMask();
            int      shiftShortcutMask = Toolkit.GetDefaultToolkit().GetMenuShortcutKeyMask() | InputEvent.ShiftDownMask;
            JMenu    fileMenu          = new JMenu("File");

            menubar.Add(fileMenu);
            JMenu editMenu = new JMenu("Edit");

            menubar.Add(editMenu);
            JMenu classifierMenu = new JMenu("Classifier");

            menubar.Add(classifierMenu);

            /*
             * FILE MENU
             */
            JMenuItem openFile = new JMenuItem("Open File");

            openFile.SetMnemonic('O');
            openFile.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkO, shortcutMask));
            openFile.AddActionListener(actor);
            fileMenu.Add(openFile);
            JMenuItem loadURL = new JMenuItem("Load URL");

            loadURL.SetMnemonic('L');
            loadURL.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkU, shortcutMask));
            loadURL.AddActionListener(actor);
            fileMenu.Add(loadURL);
            fileMenu.Add(new JSeparator());
            saveUntagged = new JMenuItem("Save Untagged File");
            saveUntagged.SetMnemonic('S');
            saveUntagged.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkS, shortcutMask));
            saveUntagged.AddActionListener(actor);
            saveUntagged.SetEnabled(false);
            fileMenu.Add(saveUntagged);
            JMenuItem saveUntaggedAs = new JMenuItem("Save Untagged File As ...");

            saveUntaggedAs.SetMnemonic('U');
            saveUntaggedAs.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkS, shiftShortcutMask));
            saveUntaggedAs.AddActionListener(actor);
            fileMenu.Add(saveUntaggedAs);
            saveTaggedAs = new JMenuItem("Save Tagged File As ...");
            saveTaggedAs.SetMnemonic('T');
            saveTaggedAs.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkT, shortcutMask));
            saveTaggedAs.AddActionListener(actor);
            saveTaggedAs.SetEnabled(false);
            fileMenu.Add(saveTaggedAs);
            if (!IsMacOSX())
            {
                // don't need if on Mac, since it has its own Quit on application menu!
                fileMenu.Add(new JSeparator());
                JMenuItem exit = new JMenuItem("Exit");
                exit.SetMnemonic('x');
                exit.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkQ, shortcutMask));
                exit.AddActionListener(actor);
                fileMenu.Add(exit);
            }

            /*
             * EDIT MENU
             */
            JMenuItem cut = new JMenuItem("Cut");

            cut.SetMnemonic('X');
            cut.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkX, shortcutMask));
            cut.AddActionListener(actor);
            editMenu.Add(cut);
            JMenuItem copy = new JMenuItem("Copy");

            copy.SetMnemonic('C');
            copy.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkC, shortcutMask));
            copy.AddActionListener(actor);
            editMenu.Add(copy);
            JMenuItem paste = new JMenuItem("Paste");

            paste.SetMnemonic('V');
            paste.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkV, shortcutMask));
            paste.AddActionListener(actor);
            editMenu.Add(paste);
            JMenuItem clear = new JMenuItem("Clear");

            clear.SetMnemonic('C');
            // clear.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, shortcutMask)); // used for load CRF
            clear.AddActionListener(actor);
            editMenu.Add(clear);

            /*
             * CLASSIFIER MENU
             */
            JMenuItem loadCRF = new JMenuItem("Load CRF from File");

            loadCRF.SetMnemonic('R');
            loadCRF.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkR, shortcutMask));
            loadCRF.AddActionListener(actor);
            classifierMenu.Add(loadCRF);
            JMenuItem loadResourceCRF = new JMenuItem("Load CRF from Classpath");

            // loadCRF.setMnemonic('R');
            // loadCRF.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, shortcutMask));
            loadResourceCRF.AddActionListener(actor);
            classifierMenu.Add(loadResourceCRF);
            JMenuItem loadDefaultCRF = new JMenuItem("Load Default CRF");

            loadDefaultCRF.SetMnemonic('L');
            loadDefaultCRF.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkL, shortcutMask));
            loadDefaultCRF.AddActionListener(actor);
            classifierMenu.Add(loadDefaultCRF);
            extract = new JMenuItem("Run NER");
            extract.SetMnemonic('N');
            extract.SetAccelerator(KeyStroke.GetKeyStroke(KeyEvent.VkN, shortcutMask));
            extract.AddActionListener(actor);
            classifierMenu.Add(extract);
            return(menubar);
        }