package ir.ac.iust.nlp.dependencyparser.parsing; import ir.ac.iust.nlp.dependencyparser.BasePanel; import ir.ac.iust.nlp.dependencyparser.DependencyParser; import ir.ac.iust.nlp.dependencyparser.utility.ExampleFileFilter; import ir.ac.iust.nlp.dependencyparser.utility.enumeration.Flowchart; import ir.ac.iust.nlp.dependencyparser.utility.enumeration.ParserType; import ir.ac.iust.nlp.dependencyparser.utility.parsing.*; import java.awt.Color; import java.awt.GridLayout; import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import javax.swing.JOptionPane; import javax.swing.JSplitPane; import javax.swing.filechooser.FileNameExtensionFilter; import org.maltparser.core.exception.MaltChainedException; import se.vxu.msi.malteval.treeviewer.MaltTreeViewerGui; import se.vxu.msi.malteval.treeviewer.gui.TreeViewer; /** * * @author Mojtaba Khallash */ public final class ParsePanel extends BasePanel { boolean isInit = false; ParserType type = ParserType.MaltParser; String inputFile; String outputFile; String currentTempFolder; ClearSettingsPanel pnlClear; MSTSettingsPanel pnlMST; MateSettingsPanel pnlMate; /** * Creates new form ParsePanel */ public ParsePanel(String dir) { super(dir); pnlClear = new ClearSettingsPanel(dir, Flowchart.Parse); pnlMST = new MSTSettingsPanel(Flowchart.Parse); pnlMate = new MateSettingsPanel(Flowchart.Parse); initComponents(); setDrop(); setCurrentDirectory(dir); lblVertical.setVisible(false); AdjustDividerLocation(); lblLess.setVisible(false); pnlAdvancedParameter.setVisible(false); tabSettings.removeAll(); tabSettings.setVisible(false); txtMaxRam.setText(getRam(true)); txtMinRam.setText(getRam(false)); } private void setDrop() { initDrop(txtInputFile, false); initDrop(txtParserModelFile, false); initDrop(txtOutputPath, true); } public void setCurrentDirectory(String dir) { txtInputFile.setText(dir + File.separator + "Treebank" + File.separator + "Persian" + File.separator + "test.conll"); txtOutputPath.setText(dir + File.separator + "Output" + File.separator + "parse" + File.separator); txtParserModelFile.setText(dir + File.separator + "Treebank" + File.separator + "Persian" + File.separator + "training_model" + File.separator + "langModel.mco"); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { buttonGroup1 = new javax.swing.ButtonGroup(); pnlParameter = new javax.swing.JPanel(); lblInputFile = new javax.swing.JLabel(); txtInputFile = new javax.swing.JTextField(); btnBrowseInputFile = new javax.swing.JButton(); lblParserModelFile = new javax.swing.JLabel(); txtParserModelFile = new javax.swing.JTextField(); btnBrowseParserModelFile = new javax.swing.JButton(); pnlAdvancedParameter = new javax.swing.JPanel(); tabSettings = new javax.swing.JTabbedPane(); pnlMSTSettings = new javax.swing.JPanel(); lblMSTSettingsL0Place = new javax.swing.JLabel(); pnlMateSettings = new javax.swing.JPanel(); lblMSTSettingsL0Place1 = new javax.swing.JLabel(); pnlMaltSettings = new javax.swing.JPanel(); pnlClearSettings = new javax.swing.JPanel(); lblClearSettingsPlace = new javax.swing.JLabel(); btnStartParse = new javax.swing.JButton(); pnlMore = new javax.swing.JPanel(); lblMore = new javax.swing.JLabel(); lblLess = new javax.swing.JLabel(); cboParser = new javax.swing.JComboBox(); lblParser = new javax.swing.JLabel(); lblOutputPath = new javax.swing.JLabel(); txtOutputPath = new javax.swing.JTextField(); btnBrowseOutputPath = new javax.swing.JButton(); txtMinRam = new javax.swing.JTextField(); chkMinRam = new javax.swing.JCheckBox(); txtMaxRam = new javax.swing.JTextField(); chkMaxRam = new javax.swing.JCheckBox(); tabDependencyInfo = new javax.swing.JTabbedPane(); pnlLog = new javax.swing.JPanel(); jScrollPane3 = new javax.swing.JScrollPane(); txtLog = new javax.swing.JTextArea(); pnlTree = new javax.swing.JPanel(); lblViewMode = new javax.swing.JLabel(); cboViewMode = new javax.swing.JComboBox(); splitTrees = new javax.swing.JSplitPane(); pnlLeft = new javax.swing.JPanel(); lblGoldTree = new javax.swing.JLabel(); pnlGoldDT = new javax.swing.JPanel(); pnlRight = new javax.swing.JPanel(); lblParseTree = new javax.swing.JLabel(); pnlParseDT = new javax.swing.JPanel(); pnlDirection = new javax.swing.JPanel(); lblVertical = new javax.swing.JLabel(); lblHorizontal = new javax.swing.JLabel(); btnNextError = new javax.swing.JButton(); btnPrevError = new javax.swing.JButton(); pnlNavigation = new javax.swing.JPanel(); lblCurrentTotal = new javax.swing.JLabel(); btnPrev = new javax.swing.JButton(); btnNext = new javax.swing.JButton(); sliderSentences = new javax.swing.JSlider(); lblPanelTitle = new javax.swing.JLabel(); pnlSeparator = new javax.swing.JPanel(); addComponentListener(new java.awt.event.ComponentAdapter() { public void componentResized(java.awt.event.ComponentEvent evt) { ReadingPanel_Resized(evt); } }); pnlParameter.setBorder(javax.swing.BorderFactory.createTitledBorder("Parameter")); lblInputFile.setText("Input File:"); txtInputFile.setEditable(false); btnBrowseInputFile.setText("..."); btnBrowseInputFile.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnBrowseInputFile_Click(evt); } }); lblParserModelFile.setText("Parser Model File:"); txtParserModelFile.setEditable(false); btnBrowseParserModelFile.setText("..."); btnBrowseParserModelFile.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnBrowseParserModelFile_Click(evt); } }); lblMSTSettingsL0Place.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblMSTSettingsL0Place.setText("MSTParser Settings: Appear after running"); javax.swing.GroupLayout pnlMSTSettingsLayout = new javax.swing.GroupLayout(pnlMSTSettings); pnlMSTSettings.setLayout(pnlMSTSettingsLayout); pnlMSTSettingsLayout.setHorizontalGroup( pnlMSTSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblMSTSettingsL0Place, javax.swing.GroupLayout.DEFAULT_SIZE, 665, Short.MAX_VALUE) ); pnlMSTSettingsLayout.setVerticalGroup( pnlMSTSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblMSTSettingsL0Place, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE) ); tabSettings.addTab("MSTParser Settings", pnlMSTSettings); pnlMSTSettings.removeAll(); pnlMSTSettings.removeAll(); pnlMSTSettings.setLayout(new GridLayout()); pnlMSTSettings.add(pnlMST); pnlMSTSettings.revalidate(); lblMSTSettingsL0Place1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblMSTSettingsL0Place1.setText("Mate-Tools Settings: Appear after running"); javax.swing.GroupLayout pnlMateSettingsLayout = new javax.swing.GroupLayout(pnlMateSettings); pnlMateSettings.setLayout(pnlMateSettingsLayout); pnlMateSettingsLayout.setHorizontalGroup( pnlMateSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblMSTSettingsL0Place1, javax.swing.GroupLayout.DEFAULT_SIZE, 665, Short.MAX_VALUE) ); pnlMateSettingsLayout.setVerticalGroup( pnlMateSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblMSTSettingsL0Place1, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE) ); tabSettings.addTab("Mate-Tools Settings", pnlMateSettings); pnlMateSettings.removeAll(); pnlMateSettings.removeAll(); pnlMateSettings.setLayout(new GridLayout()); pnlMateSettings.add(pnlMate); pnlMateSettings.revalidate(); javax.swing.GroupLayout pnlMaltSettingsLayout = new javax.swing.GroupLayout(pnlMaltSettings); pnlMaltSettings.setLayout(pnlMaltSettingsLayout); pnlMaltSettingsLayout.setHorizontalGroup( pnlMaltSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 665, Short.MAX_VALUE) ); pnlMaltSettingsLayout.setVerticalGroup( pnlMaltSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 126, Short.MAX_VALUE) ); tabSettings.addTab("MaltParser Settings", pnlMaltSettings); lblClearSettingsPlace.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblClearSettingsPlace.setText("ClearParser Settings: Appear after running"); javax.swing.GroupLayout pnlClearSettingsLayout = new javax.swing.GroupLayout(pnlClearSettings); pnlClearSettings.setLayout(pnlClearSettingsLayout); pnlClearSettingsLayout.setHorizontalGroup( pnlClearSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblClearSettingsPlace, javax.swing.GroupLayout.DEFAULT_SIZE, 665, Short.MAX_VALUE) ); pnlClearSettingsLayout.setVerticalGroup( pnlClearSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblClearSettingsPlace, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE) ); tabSettings.addTab("ClearParser Settings", pnlClearSettings); pnlClearSettings.removeAll(); pnlClearSettings.setLayout(new GridLayout()); pnlClearSettings.add(pnlClear); pnlClearSettings.revalidate(); javax.swing.GroupLayout pnlAdvancedParameterLayout = new javax.swing.GroupLayout(pnlAdvancedParameter); pnlAdvancedParameter.setLayout(pnlAdvancedParameterLayout); pnlAdvancedParameterLayout.setHorizontalGroup( pnlAdvancedParameterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(tabSettings) ); pnlAdvancedParameterLayout.setVerticalGroup( pnlAdvancedParameterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(tabSettings) ); btnStartParse.setText("Start"); btnStartParse.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnStartParse_Click(evt); } }); pnlMore.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(240, 240, 240))); lblMore.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N lblMore.setForeground(new java.awt.Color(153, 153, 153)); lblMore.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ir/ac/iust/nlp/dependencyparser/evaluation/directional_down.png"))); // NOI18N lblMore.setText(" More "); lblMore.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { lblMore_mouseClick(evt); } public void mouseEntered(java.awt.event.MouseEvent evt) { lblMorepnlMore_mouseEnter(evt); } public void mouseExited(java.awt.event.MouseEvent evt) { lblMorepnlMore_mouseExit(evt); } }); lblLess.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N lblLess.setForeground(new java.awt.Color(153, 153, 153)); lblLess.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ir/ac/iust/nlp/dependencyparser/evaluation/directional_up.png"))); // NOI18N lblLess.setText(" Less"); lblLess.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { lblLess_mouseClick(evt); } public void mouseEntered(java.awt.event.MouseEvent evt) { lblLesspnlMore_mouseEnter(evt); } public void mouseExited(java.awt.event.MouseEvent evt) { lblLesspnlMore_mouseExit(evt); } }); javax.swing.GroupLayout pnlMoreLayout = new javax.swing.GroupLayout(pnlMore); pnlMore.setLayout(pnlMoreLayout); pnlMoreLayout.setHorizontalGroup( pnlMoreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlMoreLayout.createSequentialGroup() .addGap(8, 8, 8) .addComponent(lblMore, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(lblLess) .addContainerGap()) ); pnlMoreLayout.setVerticalGroup( pnlMoreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlMoreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblLess, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblMore, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)) ); cboParser.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "MaltParser", "ClearParser", "MSTParser", "MateTools" })); cboParser.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { cboParser_stateChanged(evt); } }); lblParser.setText("Parser:"); lblOutputPath.setText("Output Path:"); txtOutputPath.setEditable(false); btnBrowseOutputPath.setText("..."); btnBrowseOutputPath.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnBrowseOutputPath_Click(evt); } }); txtMinRam.setEditable(false); chkMinRam.setText("Min Ram"); chkMinRam.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { chkMinRam_Click(evt); } }); txtMaxRam.setEditable(false); chkMaxRam.setText("Max Ram"); chkMaxRam.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { chkMaxRam_Click(evt); } }); javax.swing.GroupLayout pnlParameterLayout = new javax.swing.GroupLayout(pnlParameter); pnlParameter.setLayout(pnlParameterLayout); pnlParameterLayout.setHorizontalGroup( pnlParameterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlParameterLayout.createSequentialGroup() .addContainerGap() .addGroup(pnlParameterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(pnlAdvancedParameter, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(pnlParameterLayout.createSequentialGroup() .addComponent(pnlMore, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(lblParser) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(cboParser, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(chkMaxRam) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtMaxRam, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(chkMinRam) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtMinRam, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(btnStartParse)) .addGroup(pnlParameterLayout.createSequentialGroup() .addGroup(pnlParameterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblParserModelFile) .addComponent(lblInputFile)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(pnlParameterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtParserModelFile) .addComponent(txtInputFile)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(pnlParameterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(btnBrowseInputFile, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE) .addComponent(btnBrowseParserModelFile, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlParameterLayout.createSequentialGroup() .addComponent(lblOutputPath) .addGap(26, 26, 26) .addComponent(txtOutputPath) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnBrowseOutputPath, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); pnlParameterLayout.setVerticalGroup( pnlParameterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlParameterLayout.createSequentialGroup() .addGroup(pnlParameterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblInputFile) .addComponent(txtInputFile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnBrowseInputFile)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(pnlParameterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblParserModelFile) .addComponent(txtParserModelFile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnBrowseParserModelFile)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(pnlParameterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblOutputPath) .addComponent(txtOutputPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnBrowseOutputPath)) .addGap(8, 8, 8) .addGroup(pnlParameterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(pnlParameterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlParameterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(chkMaxRam) .addComponent(txtMaxRam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(chkMinRam) .addComponent(txtMinRam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(pnlParameterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnStartParse) .addComponent(lblParser) .addComponent(cboParser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(pnlMore, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(pnlAdvancedParameter, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); txtLog.setColumns(20); txtLog.setEditable(false); txtLog.setRows(5); jScrollPane3.setViewportView(txtLog); javax.swing.GroupLayout pnlLogLayout = new javax.swing.GroupLayout(pnlLog); pnlLog.setLayout(pnlLogLayout); pnlLogLayout.setHorizontalGroup( pnlLogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 697, Short.MAX_VALUE) ); pnlLogLayout.setVerticalGroup( pnlLogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE) ); tabDependencyInfo.addTab("Log", pnlLog); pnlTree.addComponentListener(new java.awt.event.ComponentAdapter() { public void componentShown(java.awt.event.ComponentEvent evt) { pnlTree_Shown(evt); } }); lblViewMode.setText("View Mode"); cboViewMode.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Inline Zoom", "Hierarchical Zoom", "NetGraph Zoom", "Inline Scroll" })); cboViewMode.setPreferredSize(new java.awt.Dimension(110, 20)); cboViewMode.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { cboViewMode_ValueChanged(evt); } }); splitTrees.setDividerLocation(300); pnlLeft.setBackground(new java.awt.Color(255, 255, 255)); lblGoldTree.setBackground(new java.awt.Color(255, 255, 255)); lblGoldTree.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblGoldTree.setText("Gold Tree"); lblGoldTree.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM); pnlGoldDT.setBackground(new java.awt.Color(255, 255, 255)); javax.swing.GroupLayout pnlGoldDTLayout = new javax.swing.GroupLayout(pnlGoldDT); pnlGoldDT.setLayout(pnlGoldDTLayout); pnlGoldDTLayout.setHorizontalGroup( pnlGoldDTLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 0, Short.MAX_VALUE) ); pnlGoldDTLayout.setVerticalGroup( pnlGoldDTLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 19, Short.MAX_VALUE) ); javax.swing.GroupLayout pnlLeftLayout = new javax.swing.GroupLayout(pnlLeft); pnlLeft.setLayout(pnlLeftLayout); pnlLeftLayout.setHorizontalGroup( pnlLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblGoldTree, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE) .addComponent(pnlGoldDT, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); pnlLeftLayout.setVerticalGroup( pnlLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlLeftLayout.createSequentialGroup() .addComponent(lblGoldTree, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(pnlGoldDT, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); splitTrees.setLeftComponent(pnlLeft); pnlRight.setBackground(new java.awt.Color(255, 255, 255)); lblParseTree.setBackground(new java.awt.Color(255, 255, 255)); lblParseTree.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblParseTree.setText("Parse Tree"); lblParseTree.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM); pnlParseDT.setBackground(new java.awt.Color(255, 255, 255)); javax.swing.GroupLayout pnlParseDTLayout = new javax.swing.GroupLayout(pnlParseDT); pnlParseDT.setLayout(pnlParseDTLayout); pnlParseDTLayout.setHorizontalGroup( pnlParseDTLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 0, Short.MAX_VALUE) ); pnlParseDTLayout.setVerticalGroup( pnlParseDTLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 19, Short.MAX_VALUE) ); javax.swing.GroupLayout pnlRightLayout = new javax.swing.GroupLayout(pnlRight); pnlRight.setLayout(pnlRightLayout); pnlRightLayout.setHorizontalGroup( pnlRightLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblParseTree, javax.swing.GroupLayout.DEFAULT_SIZE, 391, Short.MAX_VALUE) .addComponent(pnlParseDT, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); pnlRightLayout.setVerticalGroup( pnlRightLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlRightLayout.createSequentialGroup() .addComponent(lblParseTree) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(pnlParseDT, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); splitTrees.setRightComponent(pnlRight); pnlDirection.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(240, 240, 240))); lblVertical.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N lblVertical.setForeground(new java.awt.Color(153, 153, 153)); lblVertical.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ir/ac/iust/nlp/dependencyparser/evaluation/vertical.png"))); // NOI18N lblVertical.setText("Vertical"); lblVertical.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { lblVertical_mouseClick(evt); } public void mouseEntered(java.awt.event.MouseEvent evt) { lblVerticalpnlMore_mouseEnter(evt); } public void mouseExited(java.awt.event.MouseEvent evt) { lblVerticalpnlMore_mouseExit(evt); } }); lblHorizontal.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N lblHorizontal.setForeground(new java.awt.Color(153, 153, 153)); lblHorizontal.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ir/ac/iust/nlp/dependencyparser/evaluation/horizontal.png"))); // NOI18N lblHorizontal.setText("Horizontal"); lblHorizontal.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { lblHorizontal_mouseClick(evt); } public void mouseEntered(java.awt.event.MouseEvent evt) { lblHorizontalpnlMore_mouseEnter(evt); } public void mouseExited(java.awt.event.MouseEvent evt) { lblHorizontalpnlMore_mouseExit(evt); } }); javax.swing.GroupLayout pnlDirectionLayout = new javax.swing.GroupLayout(pnlDirection); pnlDirection.setLayout(pnlDirectionLayout); pnlDirectionLayout.setHorizontalGroup( pnlDirectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlDirectionLayout.createSequentialGroup() .addGap(8, 8, 8) .addComponent(lblVertical, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(lblHorizontal) .addContainerGap()) ); pnlDirectionLayout.setVerticalGroup( pnlDirectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlDirectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblHorizontal, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblVertical, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)) ); btnNextError.setText("Next Error >>"); btnNextError.setEnabled(false); btnNextError.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnNextErrorActionPerformed(evt); } }); btnPrevError.setText("<< Prev Error"); btnPrevError.setEnabled(false); btnPrevError.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPrevErrorActionPerformed(evt); } }); javax.swing.GroupLayout pnlTreeLayout = new javax.swing.GroupLayout(pnlTree); pnlTree.setLayout(pnlTreeLayout); pnlTreeLayout.setHorizontalGroup( pnlTreeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlTreeLayout.createSequentialGroup() .addContainerGap() .addComponent(lblViewMode) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(cboViewMode, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(30, 30, 30) .addComponent(btnPrevError) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnNextError) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(pnlDirection, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) .addComponent(splitTrees, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) ); pnlTreeLayout.setVerticalGroup( pnlTreeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlTreeLayout.createSequentialGroup() .addContainerGap() .addGroup(pnlTreeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(pnlTreeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlTreeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnPrevError) .addComponent(btnNextError)) .addGroup(pnlTreeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblViewMode) .addComponent(cboViewMode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(pnlDirection, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(splitTrees)) ); tabDependencyInfo.addTab("Tree", pnlTree); lblCurrentTotal.setText("-/-"); btnPrev.setText("Prev"); btnPrev.setEnabled(false); btnPrev.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPrev_Click(evt); } }); btnNext.setText("Next"); btnNext.setEnabled(false); btnNext.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnNext_Click(evt); } }); sliderSentences.setMaximum(0); sliderSentences.setEnabled(false); sliderSentences.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { sliderSentences_StateChanged(evt); } }); javax.swing.GroupLayout pnlNavigationLayout = new javax.swing.GroupLayout(pnlNavigation); pnlNavigation.setLayout(pnlNavigationLayout); pnlNavigationLayout.setHorizontalGroup( pnlNavigationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlNavigationLayout.createSequentialGroup() .addContainerGap() .addComponent(btnPrev) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(sliderSentences, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnNext) .addGap(76, 76, 76) .addComponent(lblCurrentTotal) .addContainerGap()) ); pnlNavigationLayout.setVerticalGroup( pnlNavigationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(sliderSentences, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnPrev, javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(pnlNavigationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblCurrentTotal) .addComponent(btnNext)) ); lblPanelTitle.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N lblPanelTitle.setText("Parsing"); pnlSeparator.setBorder(javax.swing.BorderFactory.createEtchedBorder()); pnlSeparator.setPreferredSize(new java.awt.Dimension(380, 2)); javax.swing.GroupLayout pnlSeparatorLayout = new javax.swing.GroupLayout(pnlSeparator); pnlSeparator.setLayout(pnlSeparatorLayout); pnlSeparatorLayout.setHorizontalGroup( pnlSeparatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 0, Short.MAX_VALUE) ); pnlSeparatorLayout.setVerticalGroup( pnlSeparatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 0, Short.MAX_VALUE) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(pnlNavigation, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(tabDependencyInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addComponent(pnlParameter, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(pnlSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 702, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addComponent(lblPanelTitle) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(lblPanelTitle) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(pnlSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(pnlParameter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(tabDependencyInfo) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(pnlNavigation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) ); }// </editor-fold>//GEN-END:initComponents private void makeFormReady() { if (currentTempFolder != null) { File dir = new File(workingDir + File.separator + currentTempFolder); deleteDirectory(dir); } pnlGoldDT.removeAll(); pnlGoldDT.revalidate(); pnlParseDT.removeAll(); pnlParseDT.revalidate(); for (int i = 1; i < tabDependencyInfo.getTabCount(); i++) { tabDependencyInfo.setEnabledAt(i, false); } tabDependencyInfo.setSelectedIndex(0); btnStartParse.setEnabled(false); cboParser.setEnabled(false); } File dest_from; File model_to; File log_from; File dest_to; private void btnStartParse_Click(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStartParse_Click makeFormReady(); try { if (isInit == false) { isInit = true; Settings settings = null; // Model String modelFile = txtParserModelFile.getText(); // Input String inputName = inputFile = txtInputFile.getText(); // Output String n = new File(inputFile).getName(); String extension = n.substring(n.lastIndexOf(".") + 1, n.length()); String outputName = outputFile = txtOutputPath.getText() + "parse_result." + extension; switch (type) { case MaltParser: MaltSettings malt = new MaltSettings(); // Working Directory malt.WorkingDirectory = "tmp" + File.separator; settings = malt; break; case MSTParser: MSTSettings mst = new MSTSettings(); mst.FileType = pnlMST.getFormat(); mst.DecodeType = pnlMST.getDecodeType(); mst.Order = pnlMST.getOrder(); settings = mst; break; case MateTools: MateSettings mate = new MateSettings(); mate.DecodeType = pnlMate.getDecodeType(); mate.FeatureCreation = pnlMate.getFeatureCreation(); mate.Cores = pnlMate.getNumberOfCores(); mate.NonProjectivityThreshold = pnlMate.getNonProjectivityThreshold(); settings = mate; break; case ClearParser: ClearSettings clear = new ClearSettings(); clear.OptionsFile = pnlClear.getOptionsFile(); settings = clear; break; } PrintStream out = new PrintStream(new OutputStream() { private StringBuffer buffer = new StringBuffer(); @Override public void write(int b) throws IOException { this.buffer.append((char) b); txtLog.setText(buffer.toString()); txtLog.setCaretPosition(txtLog.getDocument().getLength() - 1); } }); settings.Chart = Flowchart.Parse; settings.Model = modelFile; settings.Input = inputName; settings.Output = outputName; if (chkMaxRam.isSelected()) { DependencyParser.maxRam = txtMaxRam.getText(); } else { DependencyParser.maxRam = ""; } if (chkMinRam.isSelected()) { DependencyParser.minRam = txtMinRam.getText(); } else { DependencyParser.minRam = ""; } // Run in a new thread Runnable job = new RunnableParse(this, type, out, settings); ExecutorService threadPool = Executors.newFixedThreadPool(1); threadPool.execute(job); threadPool.shutdown(); } } catch (Exception ex) { JOptionPane.showMessageDialog( null, ex.getMessage(), "Reading Error", JOptionPane.ERROR_MESSAGE); isInit = false; } }//GEN-LAST:event_btnStartParse_Click @Override public void threadFinished() { try { for (int i = 1; i < tabDependencyInfo.getTabCount(); i++) { tabDependencyInfo.setEnabledAt(i, true); } btnStartParse.setEnabled(true); cboParser.setEnabled(true); } catch (Exception e) { } finally { isInit = false; } } private void btnBrowseParserModelFile_Click(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBrowseParserModelFile_Click FileNameExtensionFilter filter = new FileNameExtensionFilter( "Malt Configuration File", "mco"); txtParserModelFile.setText(showFileDialog(txtParserModelFile.getText(), false, filter)); }//GEN-LAST:event_btnBrowseParserModelFile_Click private void cboViewMode_ValueChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboViewMode_ValueChanged ChangeViewMode(); }//GEN-LAST:event_cboViewMode_ValueChanged private void ReadingPanel_Resized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_ReadingPanel_Resized AdjustDividerLocation(); ChangeViewMode(); }//GEN-LAST:event_ReadingPanel_Resized private void sliderSentences_StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sliderSentences_StateChanged try { UpdateTree(sliderSentences.getValue()); } catch(Exception ex) {} }//GEN-LAST:event_sliderSentences_StateChanged private void btnNext_Click(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNext_Click int val = sliderSentences.getValue(); int max = sliderSentences.getMaximum(); if (val < max) { sliderSentences.setValue(val + 1); } }//GEN-LAST:event_btnNext_Click private void btnPrev_Click(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrev_Click int val = sliderSentences.getValue(); int min = sliderSentences.getMinimum(); if (val > min) { sliderSentences.setValue(val - 1); } }//GEN-LAST:event_btnPrev_Click private void btnBrowseInputFile_Click(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBrowseInputFile_Click txtInputFile.setText(showFileDialog(txtInputFile.getText(), false)); }//GEN-LAST:event_btnBrowseInputFile_Click private void btnBrowseOutputPath_Click(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBrowseOutputPath_Click txtOutputPath.setText(showFileDialog(txtOutputPath.getText(), true)); }//GEN-LAST:event_btnBrowseOutputPath_Click private void lblMore_mouseClick(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblMore_mouseClick lblMore.setVisible(false); lblLess.setVisible(true); pnlAdvancedParameter.setVisible(true); }//GEN-LAST:event_lblMore_mouseClick private void lblMorepnlMore_mouseEnter(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblMorepnlMore_mouseEnter pnlMore.setBackground(new Color(235, 232, 232)); pnlMore.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 102, 102), 1, false)); }//GEN-LAST:event_lblMorepnlMore_mouseEnter private void lblMorepnlMore_mouseExit(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblMorepnlMore_mouseExit pnlMore.setBackground(new Color(240, 240, 240)); pnlMore.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(240, 240, 240), 1, false)); }//GEN-LAST:event_lblMorepnlMore_mouseExit private void lblLess_mouseClick(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblLess_mouseClick pnlAdvancedParameter.setVisible(false); lblLess.setVisible(false); lblMore.setVisible(true); }//GEN-LAST:event_lblLess_mouseClick private void lblLesspnlMore_mouseEnter(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblLesspnlMore_mouseEnter pnlMore.setBackground(new Color(235, 232, 232)); pnlMore.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 102, 102), 1, false)); }//GEN-LAST:event_lblLesspnlMore_mouseEnter private void lblLesspnlMore_mouseExit(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblLesspnlMore_mouseExit pnlMore.setBackground(new Color(240, 240, 240)); pnlMore.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(240, 240, 240), 1, false)); }//GEN-LAST:event_lblLesspnlMore_mouseExit private void lblVertical_mouseClick(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblVertical_mouseClick lblVertical.setVisible(false); lblHorizontal.setVisible(true); splitTrees.setOrientation(JSplitPane.HORIZONTAL_SPLIT); AdjustDividerLocation(); ChangeViewMode(); }//GEN-LAST:event_lblVertical_mouseClick private void AdjustDividerLocation() { int area; if (lblHorizontal.isVisible() == false) { area = splitTrees.getSize().height; } else { area = splitTrees.getSize().width; } int loc = area / 2; splitTrees.setDividerLocation(loc); } private void lblVerticalpnlMore_mouseEnter(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblVerticalpnlMore_mouseEnter pnlDirection.setBackground(new Color(235, 232, 232)); pnlDirection.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 102, 102), 1, false)); }//GEN-LAST:event_lblVerticalpnlMore_mouseEnter private void lblVerticalpnlMore_mouseExit(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblVerticalpnlMore_mouseExit pnlDirection.setBackground(new Color(240, 240, 240)); pnlDirection.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(240, 240, 240), 1, false)); }//GEN-LAST:event_lblVerticalpnlMore_mouseExit private void lblHorizontal_mouseClick(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblHorizontal_mouseClick lblHorizontal.setVisible(false); lblVertical.setVisible(true); splitTrees.setOrientation(JSplitPane.VERTICAL_SPLIT); AdjustDividerLocation(); ChangeViewMode(); }//GEN-LAST:event_lblHorizontal_mouseClick private void lblHorizontalpnlMore_mouseEnter(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblHorizontalpnlMore_mouseEnter pnlDirection.setBackground(new Color(235, 232, 232)); pnlDirection.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(102, 102, 102), 1, false)); }//GEN-LAST:event_lblHorizontalpnlMore_mouseEnter private void lblHorizontalpnlMore_mouseExit(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblHorizontalpnlMore_mouseExit pnlDirection.setBackground(new Color(240, 240, 240)); pnlDirection.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(240, 240, 240), 1, false)); }//GEN-LAST:event_lblHorizontalpnlMore_mouseExit private void btnNextErrorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNextErrorActionPerformed if (sliderSentences.getValue() < sliderSentences.getMaximum()) { this.nextError.doClick(); lblCurrentTotal.setText(gui.getCurrentSentence() + " / " + gui.getSentenceCount()); sliderSentences.setValue(gui.getCurrentSentence()); } }//GEN-LAST:event_btnNextErrorActionPerformed private void btnPrevErrorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrevErrorActionPerformed if (sliderSentences.getValue() > 0) { this.prevError.doClick(); lblCurrentTotal.setText(gui.getCurrentSentence() + " / " + gui.getSentenceCount()); sliderSentences.setValue(gui.getCurrentSentence()); } }//GEN-LAST:event_btnPrevErrorActionPerformed private void pnlTree_Shown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_pnlTree_Shown if (splitTrees.getDividerLocation() == 0) { AdjustDividerLocation(); } try { if (gui == null && outputFile != null && outputFile.length() != 0) { startGUI(); } } catch (Exception ex) { } }//GEN-LAST:event_pnlTree_Shown private void cboParser_stateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboParser_stateChanged tabSettings.removeAll(); tabSettings.setVisible(true); String text = cboParser.getSelectedItem().toString(); switch (text) { case "MaltParser": type = ParserType.MaltParser; tabSettings.setVisible(false); break; case "MSTParser": type = ParserType.MSTParser; tabSettings.add(pnlMSTSettings, "MSTParser Settings"); break; case "MateTools": type = ParserType.MateTools; tabSettings.add(pnlMateSettings, "Mate-Tools Settings"); break; case "ClearParser": type = ParserType.ClearParser; tabSettings.add(pnlClearSettings, "ClearParser Settings"); break; } }//GEN-LAST:event_cboParser_stateChanged private void chkMinRam_Click(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkMinRam_Click txtMinRam.setEditable(chkMinRam.isSelected()); }//GEN-LAST:event_chkMinRam_Click private void chkMaxRam_Click(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkMaxRam_Click txtMaxRam.setEditable(chkMaxRam.isSelected()); }//GEN-LAST:event_chkMaxRam_Click private void startGUI() throws Exception { String extension = inputFile.substring(inputFile.lastIndexOf(".") + 1, inputFile.length()); gui = new MaltTreeViewerGui( new String[]{outputFile}, extension, new String[]{inputFile}, extension); gui.setVisible(false); btnPrev.setEnabled(false); int size = gui.getSentenceCount(); if (size > 1) { btnNext.setEnabled(true); btnNextError.setEnabled(true); btnPrevError.setEnabled(true); } else { btnNext.setEnabled(false); btnNextError.setEnabled(false); btnPrevError.setEnabled(false); } lblCurrentTotal.setText("1 / " + size); sliderSentences.setMinimum(0); sliderSentences.setMaximum(size - 1); sliderSentences.setValue(0); sliderSentences.setEnabled(true); initTreeGui(); if (size == 1) { UpdateTree(0); } } private void ChangeViewMode() { if (gui != null) { gui.changeViewMode(cboViewMode.getSelectedIndex() + 1); } } @Override public boolean canSave() { return true; } @Override public void save() { switch (tabDependencyInfo.getSelectedIndex()) { case 0: ExampleFileFilter filter = new ExampleFileFilter("txt", "Text Files"); saveText(filter, "parse_log.txt", txtLog.getText()); break; case 1: // Tree saveTree(1); break; } } @Override public void saveAs() { save(); } private void UpdateTree(int index) throws MaltChainedException { gui.getCurrentSentenceListComponent().setSelectedSentence(index); gui.changeViewMode(cboViewMode.getSelectedIndex() + 1); TreeViewer tv = gui.getMediators().get(0); javax.swing.JPanel pnl = tv.getSplitPane(); pnlGoldDT.removeAll(); pnlGoldDT.setLayout(new GridLayout()); pnlGoldDT.add(pnl); pnlGoldDT.revalidate(); tv = gui.getMediators().get(1); pnl = tv.getSplitPane(); pnlParseDT.removeAll(); pnlParseDT.setLayout(new GridLayout()); pnlParseDT.add(pnl); pnlParseDT.revalidate(); lblCurrentTotal.setText((index + 1) + " / " + gui.getSentenceCount()); if (index == sliderSentences.getMaximum()) { btnNext.setEnabled(false); } else { btnNext.setEnabled(true); } if (index == sliderSentences.getMinimum()) { btnPrev.setEnabled(false); } else { btnPrev.setEnabled(true); } } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnBrowseInputFile; private javax.swing.JButton btnBrowseOutputPath; private javax.swing.JButton btnBrowseParserModelFile; private javax.swing.JButton btnNext; private javax.swing.JButton btnNextError; private javax.swing.JButton btnPrev; private javax.swing.JButton btnPrevError; private javax.swing.JButton btnStartParse; private javax.swing.ButtonGroup buttonGroup1; private javax.swing.JComboBox cboParser; private javax.swing.JComboBox cboViewMode; private javax.swing.JCheckBox chkMaxRam; private javax.swing.JCheckBox chkMinRam; private javax.swing.JScrollPane jScrollPane3; private javax.swing.JLabel lblClearSettingsPlace; private javax.swing.JLabel lblCurrentTotal; private javax.swing.JLabel lblGoldTree; private javax.swing.JLabel lblHorizontal; private javax.swing.JLabel lblInputFile; private javax.swing.JLabel lblLess; private javax.swing.JLabel lblMSTSettingsL0Place; private javax.swing.JLabel lblMSTSettingsL0Place1; private javax.swing.JLabel lblMore; private javax.swing.JLabel lblOutputPath; private javax.swing.JLabel lblPanelTitle; private javax.swing.JLabel lblParseTree; private javax.swing.JLabel lblParser; private javax.swing.JLabel lblParserModelFile; private javax.swing.JLabel lblVertical; private javax.swing.JLabel lblViewMode; private javax.swing.JPanel pnlAdvancedParameter; private javax.swing.JPanel pnlClearSettings; private javax.swing.JPanel pnlDirection; private javax.swing.JPanel pnlGoldDT; private javax.swing.JPanel pnlLeft; private javax.swing.JPanel pnlLog; private javax.swing.JPanel pnlMSTSettings; private javax.swing.JPanel pnlMaltSettings; private javax.swing.JPanel pnlMateSettings; private javax.swing.JPanel pnlMore; private javax.swing.JPanel pnlNavigation; private javax.swing.JPanel pnlParameter; private javax.swing.JPanel pnlParseDT; private javax.swing.JPanel pnlRight; private javax.swing.JPanel pnlSeparator; private javax.swing.JPanel pnlTree; private javax.swing.JSlider sliderSentences; private javax.swing.JSplitPane splitTrees; private javax.swing.JTabbedPane tabDependencyInfo; private javax.swing.JTabbedPane tabSettings; private javax.swing.JTextField txtInputFile; private javax.swing.JTextArea txtLog; private javax.swing.JTextField txtMaxRam; private javax.swing.JTextField txtMinRam; private javax.swing.JTextField txtOutputPath; private javax.swing.JTextField txtParserModelFile; // End of variables declaration//GEN-END:variables }