Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package vn.hieptn.interesttopic; import com.nct.framework.common.LogUtil; import com.nct.framework.util.ConvertUtils; import com.nct.framework.util.DateTimeUtils; import commonUtils.FunctionUtils; import config.ConfigInfo; import controllers.jGibbLDA.Estimator; import controllers.jGibbLDA.Inferencer; import controllers.jGibbLDA.LDACmdOption; import controllers.twitterCollection.CollectTwitterStatus; import extentEntity.ClassifiedTopicEnt; import extentEntity.MainTopicEnt; import extentEntity.TrainTopicEnt; import extentEntity.TwitterPostEnt; import extentEntity.TwitterPostListEnt; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.FilenameFilter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Vector; import javax.swing.DefaultComboBoxModel; import javax.swing.JOptionPane; import javax.swing.Timer; import javax.swing.table.DefaultTableModel; import mainService.DataBaseService; import mainService.InitService; import mainService.ProbabilityCalculation; import org.apache.commons.lang.StringUtils; import vn.hus.nlp.tokenizer.VietTokenizer; /** * * @author liempt */ public class InterestTopicMain extends javax.swing.JFrame { private static final org.apache.log4j.Logger logger = LogUtil.getLogger(InterestTopicMain.class); private final Timer timerProcessBar = new Timer(20, new progresso()); public class progresso implements ActionListener { @Override public void actionPerformed(ActionEvent ae) { int n = proressBarTwitterCollection.getValue(); if (n < 100) { n++; proressBarTwitterCollection.setValue(n); } else { proressBarTwitterCollection.setValue(0); } // System.out.println("Timer: "+n); } } /** * Creates new form InterestTopicMain */ public InterestTopicMain() { initComponents(); InitService.Init(); } /** * 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() { jPanel3 = new javax.swing.JPanel(); jPanel4 = new javax.swing.JPanel(); labelTitle = new javax.swing.JLabel(); tabTwitterCollection = new javax.swing.JTabbedPane(); jPanel5 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); txtOutput = new javax.swing.JTextArea(); btnTwitterCollectionStart = new javax.swing.JButton(); btnTwitterCollectionStop = new javax.swing.JButton(); txtNumCollected = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); jPanel6 = new javax.swing.JPanel(); btnCleanContent = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); txtContent2Msg1 = new javax.swing.JTextField(); btnMsg1ToMsg2 = new javax.swing.JButton(); txtMsg1ToMsg2 = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); btnCreateFileDat = new javax.swing.JButton(); jLabel4 = new javax.swing.JLabel(); txtCreateFileDatNum = new javax.swing.JTextField(); txtCreateFileDatTotal = new javax.swing.JTextField(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); txtMsg1ToMsg2Total = new javax.swing.JTextField(); txtContent2Msg1Total = new javax.swing.JTextField(); btnRunLDA = new javax.swing.JButton(); jLabel8 = new javax.swing.JLabel(); txtLDAAlpha = new javax.swing.JTextField(); jLabel9 = new javax.swing.JLabel(); txtLDABeta = new javax.swing.JTextField(); jLabel10 = new javax.swing.JLabel(); txtLDANTopics = new javax.swing.JTextField(); jLabel11 = new javax.swing.JLabel(); txtLDANiters = new javax.swing.JTextField(); jLabel12 = new javax.swing.JLabel(); txtLDASaveStep = new javax.swing.JTextField(); jLabel13 = new javax.swing.JLabel(); txtLDATWords = new javax.swing.JTextField(); jScrollPane2 = new javax.swing.JScrollPane(); tableTopic = new javax.swing.JTable(); jScrollPane3 = new javax.swing.JScrollPane(); tableMessage = new javax.swing.JTable(); jPanel1 = new javax.swing.JPanel(); cmboxTopic = new javax.swing.JComboBox(); jLabel14 = new javax.swing.JLabel(); jLabel15 = new javax.swing.JLabel(); jTextField1 = new javax.swing.JTextField(); jLabel16 = new javax.swing.JLabel(); jScrollPane4 = new javax.swing.JScrollPane(); tableKeyword = new javax.swing.JTable(); jLabel17 = new javax.swing.JLabel(); jScrollPane5 = new javax.swing.JScrollPane(); jTable2 = new javax.swing.JTable(); jScrollPane6 = new javax.swing.JScrollPane(); jTable3 = new javax.swing.JTable(); jLabel18 = new javax.swing.JLabel(); jPanel7 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jLabel19 = new javax.swing.JLabel(); jLabel20 = new javax.swing.JLabel(); jLabel21 = new javax.swing.JLabel(); txtLDATrainAlpha = new javax.swing.JTextField(); txtLDATrainNiters = new javax.swing.JTextField(); jLabel22 = new javax.swing.JLabel(); jLabel23 = new javax.swing.JLabel(); txtLDATrainBeta = new javax.swing.JTextField(); txtLDATrainSaveStep = new javax.swing.JTextField(); jLabel24 = new javax.swing.JLabel(); jLabel25 = new javax.swing.JLabel(); txtLDATrainNTopics = new javax.swing.JTextField(); txtLDATrainTWords = new javax.swing.JTextField(); jScrollPane8 = new javax.swing.JScrollPane(); tableResultFindHideTopic = new javax.swing.JTable(); jScrollPane9 = new javax.swing.JScrollPane(); txtWordTopic = new javax.swing.JTextArea(); cmbMainTopicResult = new javax.swing.JComboBox(); cmbTrainTopic = new javax.swing.JComboBox(); jScrollPane7 = new javax.swing.JScrollPane(); tableTrainTopicKeyword = new javax.swing.JTable(); btnExit = new javax.swing.JButton(); proressBarTwitterCollection = new javax.swing.JProgressBar(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setResizable(false); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 0, Short.MAX_VALUE)); labelTitle.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N labelTitle.setText("INTEREST TOPIC"); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout .setHorizontalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup().addGap(214, 214, 214) .addComponent(labelTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 455, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(labelTitle, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); tabTwitterCollection.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { tabTwitterCollectionStateChanged(evt); } }); tabTwitterCollection.addFocusListener(new java.awt.event.FocusAdapter() { public void focusGained(java.awt.event.FocusEvent evt) { tabTwitterCollectionFocusGained(evt); } }); tabTwitterCollection.addHierarchyListener(new java.awt.event.HierarchyListener() { public void hierarchyChanged(java.awt.event.HierarchyEvent evt) { tabTwitterCollectionHierarchyChanged(evt); } }); txtOutput.setColumns(20); txtOutput.setRows(5); jScrollPane1.setViewportView(txtOutput); btnTwitterCollectionStart.setText("Start"); btnTwitterCollectionStart.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnTwitterCollectionStartActionPerformed(evt); } }); btnTwitterCollectionStop.setText("Stop"); btnTwitterCollectionStop.setEnabled(false); btnTwitterCollectionStop.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnTwitterCollectionStopActionPerformed(evt); } }); txtNumCollected.setText("0"); jLabel1.setText("Num of Tweet Collected"); javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout .setHorizontalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup() .addContainerGap(511, Short.MAX_VALUE).addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtNumCollected, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnTwitterCollectionStart, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnTwitterCollectionStop, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap())); jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnTwitterCollectionStart).addComponent(btnTwitterCollectionStop) .addComponent(txtNumCollected, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1)) .addContainerGap())); tabTwitterCollection.addTab("Twitter Collection", jPanel5); btnCleanContent.setText("CleanUp Content"); btnCleanContent.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCleanContentActionPerformed(evt); } }); jLabel2.setText("Num of Records:"); txtContent2Msg1.setText("0"); txtContent2Msg1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtContent2Msg1ActionPerformed(evt); } }); btnMsg1ToMsg2.setText("vnToniken Message"); btnMsg1ToMsg2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnMsg1ToMsg2ActionPerformed(evt); } }); txtMsg1ToMsg2.setText("0"); txtMsg1ToMsg2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtMsg1ToMsg2ActionPerformed(evt); } }); jLabel3.setText("Num of Records:"); btnCreateFileDat.setText("Create File .dat"); btnCreateFileDat.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCreateFileDatActionPerformed(evt); } }); jLabel4.setText("Num of Records:"); txtCreateFileDatNum.setText("0"); txtCreateFileDatTotal.setText("0"); jLabel5.setText("Total"); jLabel6.setText("Total"); jLabel7.setText("Total"); txtMsg1ToMsg2Total.setText("0"); txtContent2Msg1Total.setText("0"); txtContent2Msg1Total.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtContent2Msg1TotalActionPerformed(evt); } }); btnRunLDA.setText("Run LDA"); btnRunLDA.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnRunLDAActionPerformed(evt); } }); jLabel8.setText("alpha"); txtLDAAlpha.setText("0.5"); txtLDAAlpha.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtLDAAlphaActionPerformed(evt); } }); jLabel9.setText("beta"); txtLDABeta.setText("0.1"); txtLDABeta.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtLDABetaActionPerformed(evt); } }); jLabel10.setText("nTopics"); txtLDANTopics.setText("10"); jLabel11.setText("niters"); txtLDANiters.setText("1000"); jLabel12.setText("savestep"); txtLDASaveStep.setText("1000"); txtLDASaveStep.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtLDASaveStepActionPerformed(evt); } }); jLabel13.setText("twords"); txtLDATWords.setText("20"); txtLDATWords.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtLDATWordsActionPerformed(evt); } }); jScrollPane2.setBorder(null); tableTopic .setModel(new javax.swing.table.DefaultTableModel(new Object[][] { {}, {}, {}, {} }, new String[] { })); jScrollPane2.setViewportView(tableTopic); jScrollPane3.setBorder(null); tableMessage .setModel(new javax.swing.table.DefaultTableModel(new Object[][] { {}, {}, {}, {} }, new String[] { })); jScrollPane3.setViewportView(tableMessage); javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); jPanel6.setLayout(jPanel6Layout); jPanel6Layout.setHorizontalGroup(jPanel6Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel6Layout.createSequentialGroup().addContainerGap().addGroup(jPanel6Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel6Layout.createSequentialGroup().addGroup(jPanel6Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(btnRunLDA, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnCreateFileDat, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnMsg1ToMsg2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnCleanContent, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(90, 90, 90) .addGroup(jPanel6Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel6Layout.createSequentialGroup().addGroup(jPanel6Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel6Layout.createSequentialGroup() .addGroup(jPanel6Layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel11).addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel6Layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtLDAAlpha, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtLDANiters, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGap(0, 127, Short.MAX_VALUE))) .addGap(18, 18, 18)) .addGroup(jPanel6Layout.createSequentialGroup() .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 337, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel6Layout.createSequentialGroup().addGroup(jPanel6Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel6Layout.createSequentialGroup().addGroup(jPanel6Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel9).addComponent(jLabel12)).addGap(10, 10, 10) .addGroup(jPanel6Layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel6Layout.createSequentialGroup() .addComponent(txtLDABeta, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(20, 20, 20).addComponent(jLabel10)) .addGroup(jPanel6Layout.createSequentialGroup() .addComponent(txtLDASaveStep, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(19, 19, 19).addComponent(jLabel13))) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup().addGroup(jPanel6Layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel6Layout.createSequentialGroup() .addGroup(jPanel6Layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel6Layout .createSequentialGroup() .addComponent(txtMsg1ToMsg2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel7)) .addGroup(jPanel6Layout .createSequentialGroup() .addComponent(txtCreateFileDatNum, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED)) .addGroup(jPanel6Layout.createSequentialGroup() .addComponent(txtContent2Msg1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel6).addGap(23, 23, 23))) .addGroup(jPanel6Layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtContent2Msg1Total, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtCreateFileDatTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtMsg1ToMsg2Total, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 89, Short.MAX_VALUE) .addGroup(jPanel6Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtLDATWords, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtLDANTopics, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) .addGap(25, 25, 25))); jPanel6Layout.setVerticalGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel6Layout.createSequentialGroup().addContainerGap().addGroup(jPanel6Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnCleanContent).addComponent(jLabel2) .addComponent(txtContent2Msg1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel6).addComponent(txtContent2Msg1Total, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnMsg1ToMsg2).addComponent(jLabel3) .addComponent(txtMsg1ToMsg2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel7).addComponent(txtMsg1ToMsg2Total, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnCreateFileDat).addComponent(jLabel4) .addComponent(txtCreateFileDatTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5).addComponent(txtCreateFileDatNum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(btnRunLDA, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel6Layout.createSequentialGroup().addGroup(jPanel6Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(txtLDABeta, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel6Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel8) .addComponent(txtLDAAlpha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel10).addComponent(txtLDANTopics, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel6Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel11) .addComponent(txtLDANiters, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel12) .addComponent(txtLDASaveStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel13).addComponent(txtLDATWords, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE) .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) .addContainerGap(60, Short.MAX_VALUE))); tabTwitterCollection.addTab("Tweet Content CleanUp", jPanel6); jPanel1.addFocusListener(new java.awt.event.FocusAdapter() { public void focusGained(java.awt.event.FocusEvent evt) { jPanel1FocusGained(evt); } }); cmboxTopic.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { cmboxTopicItemStateChanged(evt); } }); cmboxTopic.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cmboxTopicActionPerformed(evt); } }); jLabel14.setText("Topic "); jLabel15.setText("Probability"); jTextField1.setText("0.5"); jLabel16.setText("Keyword of Topic:"); tableKeyword.setModel(new javax.swing.table.DefaultTableModel( new Object[][] { { null, null }, { null, null }, { null, null }, { null, null } }, new String[] { "Title 1", "Title 2" })); jScrollPane4.setViewportView(tableKeyword); jLabel17.setText("Topic Infomation:"); jTable2.setModel(new javax.swing.table.DefaultTableModel(new Object[][] { { null, null, null }, { null, null, null }, { null, null, null }, { null, null, null } }, new String[] { "Title 1", "Title 2", "Title 3" })); jScrollPane5.setViewportView(jTable2); jTable3.setModel( new javax.swing.table.DefaultTableModel( new Object[][] { { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, { null, null, null, null } }, new String[] { "Title 1", "Title 2", "Title 3", "Title 4" })); jScrollPane6.setViewportView(jTable3); jLabel18.setText("jLabel18"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel14) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(cmboxTopic, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel16)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel17) .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel15) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel18).addGap(0, 0, Short.MAX_VALUE)) .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 523, Short.MAX_VALUE)) .addContainerGap())); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cmboxTopic, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel14).addComponent(jLabel15).addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel16).addComponent(jLabel17).addComponent(jLabel18)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE) .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) .addContainerGap())); tabTwitterCollection.addTab("Show Data", jPanel1); jButton1.setText("File Hun Luyn & Chy LDA"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton2.setText("Doc File Dac Trung Chu De"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jButton3.setText("Gan Nhan Cho Chu De"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); jLabel19.setText("Thng S Chy LDA Cho File Hun Luyn"); jLabel20.setText("alpha"); jLabel21.setText("niters"); txtLDATrainAlpha.setText("0.5"); txtLDATrainNiters.setText("1000"); jLabel22.setText("beta"); jLabel23.setText("savestep"); txtLDATrainBeta.setText("0.1"); txtLDATrainSaveStep.setText("1000"); jLabel24.setText("nTopics"); jLabel25.setText("twords"); txtLDATrainNTopics.setText("10"); txtLDATrainTWords.setText("20"); txtLDATrainTWords.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtLDATrainTWordsActionPerformed(evt); } }); tableResultFindHideTopic .setModel(new javax.swing.table.DefaultTableModel(new Object[][] { {}, {}, {}, {} }, new String[] { })); jScrollPane8.setViewportView(tableResultFindHideTopic); txtWordTopic.setColumns(20); txtWordTopic.setLineWrap(true); txtWordTopic.setRows(5); jScrollPane9.setViewportView(txtWordTopic); cmbMainTopicResult.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cmbMainTopicResultActionPerformed(evt); } }); cmbTrainTopic.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cmbTrainTopicActionPerformed(evt); } }); tableTrainTopicKeyword .setModel(new javax.swing.table.DefaultTableModel(new Object[][] { {}, {}, {}, {} }, new String[] { })); jScrollPane7.setViewportView(tableTrainTopicKeyword); javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7); jPanel7.setLayout(jPanel7Layout); jPanel7Layout.setHorizontalGroup( jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel7Layout .createSequentialGroup().addContainerGap().addGroup(jPanel7Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jButton1).addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup() .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 712, Short.MAX_VALUE) .addContainerGap()) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup().addGroup(jPanel7Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPanel7Layout.createSequentialGroup() .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(10, 10, 10).addComponent(txtLDATrainNiters, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel7Layout.createSequentialGroup() .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent( txtLDATrainAlpha, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(32, 32, 32) .addGroup(jPanel7Layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel22, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel23, javax.swing.GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE)) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel7Layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(txtLDATrainSaveStep, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE) .addComponent(txtLDATrainBeta)) .addGap(18, 18, 18).addGroup(jPanel7Layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel24, javax.swing.GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE) .addComponent(jLabel25, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(18, 18, 18) .addGroup(jPanel7Layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtLDATrainNTopics) .addComponent(txtLDATrainTWords)) .addGap(107, 107, 107)) .addGroup(jPanel7Layout.createSequentialGroup().addGroup(jPanel7Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel7Layout.createSequentialGroup().addComponent(jLabel19) .addGap(127, 127, 127)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout .createSequentialGroup() .addGroup(jPanel7Layout .createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(cmbMainTopicResult, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane9, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED))) .addGroup(jPanel7Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(cmbTrainTopic, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) .addGap(107, 107, 107))))); jPanel7Layout.setVerticalGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel7Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel7Layout.createSequentialGroup() .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(27, 27, 27).addComponent( jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel7Layout.createSequentialGroup().addComponent(jLabel19) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel7Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel20) .addComponent(txtLDATrainAlpha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel22) .addComponent(txtLDATrainBeta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel24).addComponent( txtLDATrainNTopics, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel7Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel21) .addComponent(txtLDATrainNiters, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel23) .addComponent(txtLDATrainSaveStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel25).addComponent(txtLDATrainTWords, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel7Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cmbTrainTopic, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cmbMainTopicResult, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jScrollPane9, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE) .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(19, 19, 19))); tabTwitterCollection.addTab("Read Data", jPanel7); btnExit.setText("Exit"); btnExit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnExitActionPerformed(evt); } }); proressBarTwitterCollection.setBorderPainted(false); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(tabTwitterCollection, javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap() .addComponent(proressBarTwitterCollection, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnExit, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(tabTwitterCollection, javax.swing.GroupLayout.PREFERRED_SIZE, 437, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(btnExit, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(proressBarTwitterCollection, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); pack(); }// </editor-fold>//GEN-END:initComponents private void btnTwitterCollectionStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTwitterCollectionStartActionPerformed // TODO add your handling code here: try { btnTwitterCollectionStart.setEnabled(false); txtNumCollected.setText(String.valueOf(ConfigInfo.TWITTER_COLLECTION_COUNTER)); //proressBarTwitterCollection.setIndeterminate(true); //proressBarTwitterCollection.setStringPainted(true); //proressBarTwitterCollection.setForeground(Color.BLUE); timerProcessBar.start(); txtOutput.setText(ConfigInfo.TWITTER_COLLECTION_OUTPUT); CollectTwitterStatus.startCollectTwitterStatus(); btnTwitterCollectionStop.setEnabled(true); // while(ConfigInfo.TWITTER_COLLECTION_COLLECTING){ // txtOutput.setText(ConfigInfo.TWITTER_COLLECTION_OUTPUT); // Thread.sleep(1000); // } } catch (Exception ex) { logger.error(LogUtil.stackTrace(ex)); JOptionPane.showMessageDialog(null, "Net!", "Thong Bao", JOptionPane.INFORMATION_MESSAGE); } }//GEN-LAST:event_btnTwitterCollectionStartActionPerformed private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExitActionPerformed // TODO add your handling code here: btnTwitterCollectionStart.setEnabled(true); btnTwitterCollectionStop.setEnabled(false); txtNumCollected.setText(String.valueOf(ConfigInfo.TWITTER_COLLECTION_COUNTER)); // // CollectTwitterStatus.stopCollectTwitterStatus(); this.setVisible(false); this.dispose(); System.exit(0); }//GEN-LAST:event_btnExitActionPerformed private void btnTwitterCollectionStopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTwitterCollectionStopActionPerformed // TODO add your handling code here: btnTwitterCollectionStart.setEnabled(true); btnTwitterCollectionStop.setEnabled(false); txtNumCollected.setText(String.valueOf(ConfigInfo.TWITTER_COLLECTION_COUNTER)); //proressBarTwitterCollection.setIndeterminate(false); timerProcessBar.stop(); CollectTwitterStatus.stopCollectTwitterStatus(); }//GEN-LAST:event_btnTwitterCollectionStopActionPerformed private void txtContent2Msg1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtContent2Msg1ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_txtContent2Msg1ActionPerformed private void btnCleanContentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCleanContentActionPerformed // TODO add your handling code here: proressBarTwitterCollection.setValue(0); btnCleanContent.setEnabled(false); int couterConvert = 0; txtContent2Msg1.setText(String.valueOf(couterConvert)); TwitterPostListEnt lstPost = DataBaseService.GetList(TwitterPostEnt.STATUS.INIT); if (lstPost != null && lstPost.totalRecords > 0) { txtContent2Msg1Total.setText(String.valueOf(lstPost.totalRecords)); proressBarTwitterCollection.setMaximum((int) lstPost.totalRecords); for (TwitterPostEnt tmpPost : lstPost.listEnts) { if (tmpPost != null) { tmpPost = FunctionUtils.ConvertContentToMessage1(tmpPost); if (DataBaseService.Update(tmpPost)) { couterConvert++; txtContent2Msg1.setText(String.valueOf(couterConvert)); } } proressBarTwitterCollection.setValue(couterConvert); } } btnCleanContent.setEnabled(true); //Thong Bao Thanh Cong JOptionPane.showMessageDialog(null, "Clear Content Thnh Cng!", "Clear Content", JOptionPane.INFORMATION_MESSAGE); }//GEN-LAST:event_btnCleanContentActionPerformed private void btnMsg1ToMsg2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMsg1ToMsg2ActionPerformed // TODO add your handling code here: try { proressBarTwitterCollection.setValue(0); btnMsg1ToMsg2.setEnabled(false); int couterConvert = 0; txtMsg1ToMsg2.setText(String.valueOf(couterConvert)); TwitterPostListEnt lstPost = DataBaseService.GetList(TwitterPostEnt.STATUS.ToMsg1); if (lstPost != null && lstPost.totalRecords > 0) { txtMsg1ToMsg2Total.setText(String.valueOf(lstPost.totalRecords)); // String outFilename = ConfigInfo.LOCATION_OUTPUT_FILE + File.separator + DateTimeUtils.getMilisecondsNow(); // File fileDir = new File(outFilename); // if (!fileDir.exists()) { // fileDir.mkdirs(); // } // outFilename += File.separator + "msg1Data.txt"; for (TwitterPostEnt tmpPost : lstPost.listEnts) { if (tmpPost != null) { // File file = new File(outFilename); // //if file doesnt exists, then create it // if (!file.exists()) { // file.createNewFile(); // } // // //true = append file // FileWriter fileWritter = new FileWriter(file.getPath(), false); // BufferedWriter bufferWritter = new BufferedWriter(fileWritter); // bufferWritter.write(tmpPost.Message1); // bufferWritter.close(); VietTokenizer tokenizer = new VietTokenizer(); String[] keyContent = tokenizer.tokenize(tmpPost.Message1); tmpPost.Message2 = StringUtils.join(keyContent, " "); tmpPost.Status = TwitterPostEnt.STATUS.ToMsg2; if (DataBaseService.Update(tmpPost)) { couterConvert++; txtMsg1ToMsg2.setText(String.valueOf(couterConvert)); } } proressBarTwitterCollection.setValue(couterConvert); } } btnMsg1ToMsg2.setEnabled(true); //Thong Bao Thanh Cong JOptionPane.showMessageDialog(null, "Chay VietTokenizer Thnh Cng!", "Chay VietTokenizer", JOptionPane.INFORMATION_MESSAGE); } catch (Exception ex) { logger.error(LogUtil.stackTrace(ex)); } }//GEN-LAST:event_btnMsg1ToMsg2ActionPerformed private void txtMsg1ToMsg2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtMsg1ToMsg2ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_txtMsg1ToMsg2ActionPerformed private void btnCreateFileDatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCreateFileDatActionPerformed // TODO add your handling code here: try { btnCreateFileDat.setEnabled(false); int numCreated = 0; txtCreateFileDatNum.setText("0"); proressBarTwitterCollection.setValue(0); String outFilename = ConfigInfo.LOCATION_OUTPUT_FILE + File.separator + FunctionUtils.DateToDirView(); File fileDir = new File(outFilename); if (!fileDir.exists()) { fileDir.mkdirs(); } ConfigInfo.LOCATION_OUTPUT_FILE_DAT = outFilename; outFilename += File.separator + "msgInput.dat"; File file = new File(outFilename); //if file doesnt exists, then create it if (!file.exists()) { file.createNewFile(); } //Collecting Data String fileDate = ""; TwitterPostListEnt lstPost = DataBaseService.GetList(TwitterPostEnt.STATUS.ToMsg2); if (lstPost != null && lstPost.totalRecords > 0) { txtCreateFileDatTotal.setText(String.valueOf(lstPost.totalRecords)); fileDate += lstPost.totalRecords + "\n"; ConfigInfo.LIST_POSTID_LDA = new ArrayList<Long>(); for (TwitterPostEnt tmpPost : lstPost.listEnts) { if (tmpPost != null) { fileDate += FunctionUtils.ClearWord1Char(tmpPost.Message2) + "\n"; ConfigInfo.LIST_POSTID_LDA.add(tmpPost.PostId); numCreated++; txtCreateFileDatNum.setText(String.valueOf(numCreated)); } proressBarTwitterCollection.setValue(numCreated); } } //true = append file FileWriter fileWritter = new FileWriter(file.getPath(), false); BufferedWriter bufferWritter = new BufferedWriter(fileWritter); bufferWritter.write(fileDate); bufferWritter.close(); btnCreateFileDat.setEnabled(true); JOptionPane.showMessageDialog(null, "To File Thnh Cng!", "To File .Dat", JOptionPane.INFORMATION_MESSAGE); } catch (Exception ex) { logger.error(LogUtil.stackTrace(ex)); } }//GEN-LAST:event_btnCreateFileDatActionPerformed private void txtContent2Msg1TotalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtContent2Msg1TotalActionPerformed // TODO add your handling code here: }//GEN-LAST:event_txtContent2Msg1TotalActionPerformed private void btnRunLDAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRunLDAActionPerformed // TODO add your handling code here: proressBarTwitterCollection.setValue(0); //Clear DB : ClassifiedTopic , ClassifiedMessage DataBaseService.ClearDataClassified(); btnRunLDA.setEnabled(false); LDACmdOption ldaOption = new LDACmdOption(); ldaOption.inf = true; ldaOption.est = true; ldaOption.estc = false; ldaOption.dir = (!ConfigInfo.LOCATION_OUTPUT_FILE_DAT.isEmpty()) ? ConfigInfo.LOCATION_OUTPUT_FILE_DAT : ConfigInfo.LOCATION_OUTPUT_FILE + File.separator + FunctionUtils.DateToDirView(); //"/media/liempt/DATA/PhamLiem/DAHiep/OutputData/20140703/"; ldaOption.dfile = "msgInput.dat"; ldaOption.modelName = ""; ldaOption.alpha = ConvertUtils.toDouble(txtLDAAlpha.getText()) > 0 ? ConvertUtils.toDouble(txtLDAAlpha.getText()) : 0.5; ldaOption.beta = ConvertUtils.toDouble(txtLDABeta.getText()) > 0 ? ConvertUtils.toDouble(txtLDABeta.getText()) : 0.1; ldaOption.K = ConvertUtils.toInt(txtLDANTopics.getText()) > 0 ? ConvertUtils.toInt(txtLDANTopics.getText()) : 10; ldaOption.niters = ConvertUtils.toInt(txtLDANiters.getText()) > 0 ? ConvertUtils.toInt(txtLDANiters.getText()) : 1000; ldaOption.savestep = ConvertUtils.toInt(txtLDASaveStep.getText()) > 0 ? ConvertUtils.toInt(txtLDASaveStep.getText()) : 1000; ldaOption.twords = ConvertUtils.toInt(txtLDATWords.getText()) > 0 ? ConvertUtils.toInt(txtLDATWords.getText()) : 20; ldaOption.withrawdata = false; ldaOption.traindata = false; ldaOption.wordMapFileName = "wordmap.txt"; // Inferencer inferencer = new Inferencer(); // inferencer.init(ldaOption); if (ldaOption.est || ldaOption.estc) { System.out.println(DateTimeUtils.getNow("dd/MM/yyyy HH:mm:ss")); Estimator estimator = new Estimator(); estimator.init(ldaOption); System.out.println(DateTimeUtils.getNow("dd/MM/yyyy HH:mm:ss")); estimator.estimate(); System.out.println(DateTimeUtils.getNow("dd/MM/yyyy HH:mm:ss")); } else if (ldaOption.inf) { Inferencer inferencer = new Inferencer(); inferencer.init(ldaOption); // Model newModel = inferencer.inference(); // for (int i = 0; i < newModel.phi.length; ++i){ // //phi: K * V // System.out.println("-----------------------\ntopic" + i + " : "); // for (int j = 0; j < 10; ++j){ // System.out.println(inferencer.globalDict.id2word.get(j) + "\t" + newModel.phi[i][j]); // } // } } //Show Table View Vector<Vector<String>> dataTopic = DataBaseService.GetDataClassifiedTopic(); Vector<String> columnNamesTopic = new Vector<String>(); columnNamesTopic.add("TopicId"); columnNamesTopic.add("TopicName"); columnNamesTopic.add("Keyword"); tableTopic.setModel(new DefaultTableModel(dataTopic, columnNamesTopic)); jScrollPane2.setViewportView(tableTopic); jScrollPane2.setBorder(jScrollPane1.getViewportBorder()); tableTopic.setVisible(true); //tableTopic.setPreferredScrollableViewportSize(new Dimension(500, 70)); tableTopic.setFillsViewportHeight(true); Vector<Vector<String>> dataMessage = DataBaseService.GetDataClassifiedMessage(); Vector<String> columnNamesMessage = new Vector<String>(); columnNamesMessage.add("PostId"); columnNamesMessage.add("TopicId"); columnNamesMessage.add("Probability"); tableMessage.setModel(new DefaultTableModel(dataMessage, columnNamesMessage)); jScrollPane3.setViewportView(tableMessage); tableMessage.setVisible(true); btnRunLDA.setEnabled(true); //Thong Bao Thanh Cong JOptionPane.showMessageDialog(null, "Chay LDA Thnh Cng!", "Chay LDA", JOptionPane.INFORMATION_MESSAGE); }//GEN-LAST:event_btnRunLDAActionPerformed private void txtLDAAlphaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtLDAAlphaActionPerformed // TODO add your handling code here: }//GEN-LAST:event_txtLDAAlphaActionPerformed private void txtLDASaveStepActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtLDASaveStepActionPerformed // TODO add your handling code here: }//GEN-LAST:event_txtLDASaveStepActionPerformed private void txtLDATWordsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtLDATWordsActionPerformed // TODO add your handling code here: }//GEN-LAST:event_txtLDATWordsActionPerformed private void txtLDABetaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtLDABetaActionPerformed // TODO add your handling code here: }//GEN-LAST:event_txtLDABetaActionPerformed private void tabTwitterCollectionFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tabTwitterCollectionFocusGained // TODO add your handling code here: }//GEN-LAST:event_tabTwitterCollectionFocusGained private void jPanel1FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jPanel1FocusGained // TODO add your handling code here: }//GEN-LAST:event_jPanel1FocusGained private void tabTwitterCollectionHierarchyChanged(java.awt.event.HierarchyEvent evt) {//GEN-FIRST:event_tabTwitterCollectionHierarchyChanged // TODO add your handling code here: }//GEN-LAST:event_tabTwitterCollectionHierarchyChanged private void tabTwitterCollectionStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_tabTwitterCollectionStateChanged // TODO add your handling code here: System.out.println("Mo:" + tabTwitterCollection.getSelectedIndex()); DefaultComboBoxModel modelTopic = (DefaultComboBoxModel) cmboxTopic.getModel(); modelTopic.removeAllElements(); if (tabTwitterCollection.getSelectedIndex() == 2) { List<ClassifiedTopicEnt> lstTopic = DataBaseService.GetListDataClassifiedTopic(); if (lstTopic != null && lstTopic.size() > 0) { for (ClassifiedTopicEnt tmpTopic : lstTopic) { if (tmpTopic != null) { modelTopic.addElement(tmpTopic.TopicName); ConfigInfo.MAP_TOPIC_REPORT.put(tmpTopic.TopicName, tmpTopic); } } cmboxTopic.setModel(modelTopic); } } }//GEN-LAST:event_tabTwitterCollectionStateChanged private void cmboxTopicActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmboxTopicActionPerformed // TODO add your handling code here: if (cmboxTopic != null && cmboxTopic.getSelectedItem() != null) { String selectedName = cmboxTopic.getSelectedItem().toString(); ClassifiedTopicEnt tmpTopicEnt = ConfigInfo.MAP_TOPIC_REPORT.get(selectedName); if (tmpTopicEnt != null) { Vector<Vector<String>> dataMessage = new Vector<Vector<String>>(); String[] listKeyword = StringUtils.split(tmpTopicEnt.Keyword, "#"); if (listKeyword != null && listKeyword.length > 0) { for (String tmpKeyword : listKeyword) { if (!tmpKeyword.isEmpty()) { String[] listWord = StringUtils.split(tmpKeyword, "|"); Vector<String> vstring = new Vector<String>(); vstring.add(listWord[0]); vstring.add(listWord[1]); vstring.add("\n\n\n\n\n\n\n"); dataMessage.add(vstring); } } } Vector<String> columnNamesMessage = new Vector<String>(); columnNamesMessage.add("Word"); columnNamesMessage.add("Probability"); tableKeyword.setModel(new DefaultTableModel(dataMessage, columnNamesMessage)); jScrollPane4.setViewportView(tableKeyword); tableKeyword.setVisible(true); } } //Get Post of Topic Vector<Vector<String>> dataMessage = DataBaseService.GetDataClassifiedMessage(1, 1); System.out.println("Check"); }//GEN-LAST:event_cmboxTopicActionPerformed private void cmboxTopicItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cmboxTopicItemStateChanged // TODO add your handling code here: }//GEN-LAST:event_cmboxTopicItemStateChanged private void txtLDATrainTWordsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtLDATrainTWordsActionPerformed // TODO add your handling code here: }//GEN-LAST:event_txtLDATrainTWordsActionPerformed private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed // TODO add your handling code here: List<MainTopicEnt> listMainTopic = DataBaseService.GetListMainTopicEnt(); List<ClassifiedTopicEnt> lstTopic = DataBaseService.GetListDataClassifiedTopic(); if (lstTopic != null && lstTopic.size() > 0 && listMainTopic != null && listMainTopic.size() > 0) { //Tinh So Vocalbulary int numVocabulary = 0; int numVocabularyWinDuplicate = 0; for (MainTopicEnt tmpMainTopicEnt : listMainTopic) { numVocabulary += tmpMainTopicEnt.NumKeywordNoDuplicate; numVocabularyWinDuplicate += tmpMainTopicEnt.NumKeyword; } //Tinh Xac Suat Cho Tung TOPIC HashMap<String, Double> mapXSTopic = new HashMap<String, Double>(); for (ClassifiedTopicEnt tmpTopicEnt : lstTopic) { List<String> listKeywordOfTopic = FunctionUtils.ConvertListKeywordOfTopic(tmpTopicEnt.Keyword); for (MainTopicEnt tmpMainTopicEnt : listMainTopic) { int numN = 0; HashMap<String, Integer> mapNK = new HashMap<String, Integer>(); for (String tmpKeywordTopic : listKeywordOfTopic) { int nShowTime = FunctionUtils.CountWordShow(tmpKeywordTopic, tmpMainTopicEnt.Message2); numN += nShowTime; String KeyMapKeywordTopic = tmpKeywordTopic + "|" + tmpMainTopicEnt.TopicName; mapNK.put(KeyMapKeywordTopic, nShowTime); } //Tinh Xac Suat Cua Tung Key Word HashMap<String, Double> mapXSKeyword = new HashMap<String, Double>(); for (String tmpKeywordTopic : listKeywordOfTopic) { String KeyMapKeywordTopic = tmpKeywordTopic + "|" + tmpMainTopicEnt.TopicName; int numNK = mapNK.get(KeyMapKeywordTopic) > 0 ? mapNK.get(KeyMapKeywordTopic) : 0; double XSKeyword = ((double) (numNK + 1)) / ((double) (numN + numVocabulary)); mapXSKeyword.put(KeyMapKeywordTopic, XSKeyword); } //Xac Suat Cho Main Topic double pMainTopic = ((double) tmpMainTopicEnt.NumKeyword) / ((double) numVocabularyWinDuplicate); //Xac Suat cho Topic voi Main Topic String KeyMapTopic = tmpTopicEnt.TopicName + "|" + tmpMainTopicEnt.TopicName; double pMainTopicSum = ProbabilityCalculation.LogBase2(pMainTopic); for (String tmpKeywordTopic : listKeywordOfTopic) { String KeyMapKeywordTopic = tmpKeywordTopic + "|" + tmpMainTopicEnt.TopicName; double XSKeyword = mapXSKeyword.get(KeyMapKeywordTopic); pMainTopicSum += ProbabilityCalculation.LogBase2(XSKeyword); } mapXSTopic.put(KeyMapTopic, pMainTopicSum); } } //Tim Chu De Chinh Cho Tung TOPIC Vector<String> columnNamesMessage = new Vector<String>(); columnNamesMessage.add("Chu De An"); for (MainTopicEnt tmpMainTopicEnt : listMainTopic) { columnNamesMessage.add("XS " + tmpMainTopicEnt.TopicName); } columnNamesMessage.add("Chu De"); Vector<Vector<String>> dataMessage = new Vector<Vector<String>>(); for (ClassifiedTopicEnt tmpTopicEnt : lstTopic) { String topicNameFind = ""; double XSTopic = 0; double XSTopicDuplicate = 0; boolean isWaiting = false; Vector<String> vstring = new Vector<String>(); vstring.add(tmpTopicEnt.TopicName); for (MainTopicEnt tmpMainTopicEnt : listMainTopic) { String KeyMapTopic = tmpTopicEnt.TopicName + "|" + tmpMainTopicEnt.TopicName; double tmpXSTopic = mapXSTopic.get(KeyMapTopic); if (XSTopic == 0 || tmpXSTopic > XSTopic) { XSTopic = tmpXSTopic; topicNameFind = KeyMapTopic; } if (XSTopicDuplicate == 0 || tmpXSTopic == XSTopicDuplicate) { XSTopicDuplicate = tmpXSTopic; isWaiting = true; } else { isWaiting = false; } vstring.add(String.format("%.6f", tmpXSTopic)); } String[] listWord = StringUtils.split(topicNameFind, "|"); if (isWaiting) { vstring.add("Dang Cho Phan Lop"); } else { vstring.add(listWord[1]); } vstring.add("\n\n\n\n\n\n\n"); dataMessage.add(vstring); } tableResultFindHideTopic.setModel(new DefaultTableModel(dataMessage, columnNamesMessage)); jScrollPane8.setViewportView(tableResultFindHideTopic); tableResultFindHideTopic.setVisible(true); } }//GEN-LAST:event_jButton3ActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed // TODO add your handling code here: List<MainTopicEnt> listMainTopic = DataBaseService.GetListMainTopicEnt(); DefaultComboBoxModel modelMainTopic = (DefaultComboBoxModel) cmbMainTopicResult.getModel(); modelMainTopic.removeAllElements(); if (listMainTopic != null && listMainTopic.size() > 0) { for (MainTopicEnt tmpMainTopicEnt : listMainTopic) { tmpMainTopicEnt.Keyword = ""; String fileWordmap = ConfigInfo.DIR_DATA_TRAIN + File.separator + tmpMainTopicEnt.TopicName + File.separator + "WordTopic.txt"; List<String> listWordmap = FunctionUtils.ReadTextFileToList(fileWordmap); if (listWordmap != null && listWordmap.size() > 1) { tmpMainTopicEnt.NumKeywordNoDuplicate = ConvertUtils.toInt(listWordmap.get(0)); for (int i = 1; i < listWordmap.size(); i++) { String tmpKeyword = listWordmap.get(i); String[] listWord = StringUtils.split(tmpKeyword, " "); if (!FunctionUtils.IsNullOrEmpty(listWord[0])) { tmpMainTopicEnt.Keyword += listWord[0] + "|"; } } } modelMainTopic.addElement( tmpMainTopicEnt.TopicName + ": " + tmpMainTopicEnt.NumKeywordNoDuplicate + " Tu."); //Update MainTopicEnt DataBaseService.Update(tmpMainTopicEnt); List<TrainTopicEnt> lstTopic = DataBaseService.GetListTrainTopic(tmpMainTopicEnt.Id); if (lstTopic != null && lstTopic.size() > 0) { for (TrainTopicEnt tmpTopic : lstTopic) { if (tmpTopic != null) { ConfigInfo.MAP_TRAIN_TOPIC.put(tmpTopic.TopicName + "|" + tmpMainTopicEnt.Id, tmpTopic); } } } } } cmbMainTopicResult.setModel(modelMainTopic); //Thong Bao Thanh Cong JOptionPane.showMessageDialog(null, "Cp Nht File WordTopic Thnh Cng!", "Read File WordTopic", JOptionPane.INFORMATION_MESSAGE); }//GEN-LAST:event_jButton2ActionPerformed private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: //Lam Sach DB MainTopic DataBaseService.ClearDataMainTopic(); File file = new File(ConfigInfo.DIR_DATA_TRAIN); String[] directories = file.list(new FilenameFilter() { @Override public boolean accept(File current, String name) { return new File(current, name).isDirectory(); } }); for (String tmpFolder : directories) { String filePath = ConfigInfo.DIR_DATA_TRAIN + File.separator + tmpFolder + File.separator + tmpFolder + ".txt"; File tmpFile = new File(filePath); if (tmpFile.isFile()) { String tmpFileContent = FunctionUtils.ReadTextFile(filePath, "\n"); if (!FunctionUtils.IsNullOrEmpty(tmpFileContent)) { MainTopicEnt newMainTopicEnt = new MainTopicEnt(); newMainTopicEnt.TopicName = tmpFolder; newMainTopicEnt.Content = tmpFileContent; //Lam Sach Du Lieu newMainTopicEnt.Message1 = FunctionUtils.ClearTextUnicode(tmpFileContent); newMainTopicEnt.Message1 = FunctionUtils.ClearStopWord(newMainTopicEnt.Message1); // Chay VietTokenizer VietTokenizer tokenizer = new VietTokenizer(); String[] keyContent = tokenizer.tokenize(newMainTopicEnt.Message1); newMainTopicEnt.Message2 = StringUtils.join(keyContent, " "); //Tao File .dat String fileDatPath = ConfigInfo.DIR_DATA_TRAIN + File.separator + tmpFolder + File.separator + tmpFolder + ".dat"; if (!FunctionUtils.WriteTextFile(fileDatPath, FunctionUtils.ClearWord1Char(newMainTopicEnt.Message2))) { JOptionPane.showMessageDialog(null, "To File " + tmpFolder + ".dat Khoong Thnh Cng!", "To File .Dat", JOptionPane.INFORMATION_MESSAGE); } newMainTopicEnt.NumKeyword = FunctionUtils.CountWord(newMainTopicEnt.Message2); //Luu vao DB long newMainTopicId = DataBaseService.Create(newMainTopicEnt); if (newMainTopicId > 0) { ConfigInfo.MAIN_TOPICID_LDA = newMainTopicId; } else { JOptionPane.showMessageDialog(null, "Chay LDA File " + tmpFolder + ".dat Khoong Thnh Cng!", "Chay LDA", JOptionPane.INFORMATION_MESSAGE); } //Chay LDA LDACmdOption ldaOption = new LDACmdOption(); ldaOption.inf = true; ldaOption.est = true; ldaOption.estc = false; ldaOption.dir = ConfigInfo.DIR_DATA_TRAIN + File.separator + tmpFolder; ldaOption.dfile = tmpFolder + ".dat"; ldaOption.modelName = ""; ldaOption.alpha = ConvertUtils.toDouble(txtLDATrainAlpha.getText()) > 0 ? ConvertUtils.toDouble(txtLDATrainAlpha.getText()) : 0.5; ldaOption.beta = ConvertUtils.toDouble(txtLDATrainBeta.getText()) > 0 ? ConvertUtils.toDouble(txtLDATrainBeta.getText()) : 0.1; ldaOption.K = ConvertUtils.toInt(txtLDATrainNTopics.getText()) > 0 ? ConvertUtils.toInt(txtLDATrainNTopics.getText()) : 10; ldaOption.niters = ConvertUtils.toInt(txtLDATrainNiters.getText()) > 0 ? ConvertUtils.toInt(txtLDATrainNiters.getText()) : 1000; ldaOption.savestep = ConvertUtils.toInt(txtLDATrainSaveStep.getText()) > 0 ? ConvertUtils.toInt(txtLDATrainSaveStep.getText()) : 1000; ldaOption.twords = ConvertUtils.toInt(txtLDATrainTWords.getText()) > 0 ? ConvertUtils.toInt(txtLDATrainTWords.getText()) : 20; ldaOption.withrawdata = false; ldaOption.traindata = true; ldaOption.wordMapFileName = "wordmap.txt"; Estimator estimator = new Estimator(); estimator.init(ldaOption); estimator.estimate(); } } } //Thong Bao Thanh Cong JOptionPane.showMessageDialog(null, "Doc File Train Data Thnh Cng!", "Read Train Data", JOptionPane.INFORMATION_MESSAGE); }//GEN-LAST:event_jButton1ActionPerformed private void cmbMainTopicResultActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbMainTopicResultActionPerformed // TODO add your handling code here: if (cmbMainTopicResult != null && cmbMainTopicResult.getSelectedItem() != null) { String selectedName = StringUtils.split(cmbMainTopicResult.getSelectedItem().toString(), ":")[0]; MainTopicEnt tmpMainTopicEnt = DataBaseService.GetMainTopicByName(selectedName); if (tmpMainTopicEnt != null && tmpMainTopicEnt.Keyword != null) { txtWordTopic.setText(tmpMainTopicEnt.Keyword.replaceAll("\\|", " \n")); } //Show Cc Topic ca Ch ? ny ConfigInfo.cmbMainTopicResult_ID = tmpMainTopicEnt.Id; DefaultComboBoxModel modelTopic = (DefaultComboBoxModel) cmbTrainTopic.getModel(); modelTopic.removeAllElements(); List<TrainTopicEnt> lstTopic = DataBaseService.GetListTrainTopic(tmpMainTopicEnt.Id); if (lstTopic != null && lstTopic.size() > 0) { for (TrainTopicEnt tmpTopic : lstTopic) { if (tmpTopic != null) { modelTopic.addElement(tmpTopic.TopicName); ConfigInfo.MAP_TRAIN_TOPIC.put(tmpTopic.TopicName + "|" + tmpMainTopicEnt.Id, tmpTopic); } } cmbTrainTopic.setModel(modelTopic); } } }//GEN-LAST:event_cmbMainTopicResultActionPerformed private void cmbTrainTopicActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbTrainTopicActionPerformed // TODO add your handling code here: if (cmbTrainTopic != null && cmbTrainTopic.getSelectedItem() != null) { String selectedName = cmbTrainTopic.getSelectedItem().toString(); TrainTopicEnt tmpTopicEnt = ConfigInfo.MAP_TRAIN_TOPIC .get(selectedName + "|" + ConfigInfo.cmbMainTopicResult_ID); if (tmpTopicEnt != null) { Vector<Vector<String>> dataMessage = new Vector<Vector<String>>(); String[] listKeyword = StringUtils.split(tmpTopicEnt.Keyword, "#"); if (listKeyword != null && listKeyword.length > 0) { for (String tmpKeyword : listKeyword) { if (!tmpKeyword.isEmpty()) { String[] listWord = StringUtils.split(tmpKeyword, "|"); Vector<String> vstring = new Vector<String>(); vstring.add(listWord[0]); vstring.add(listWord[1]); vstring.add("\n\n\n\n\n\n\n"); dataMessage.add(vstring); } } } Vector<String> columnNamesMessage = new Vector<String>(); columnNamesMessage.add("Word"); columnNamesMessage.add("Probability"); tableTrainTopicKeyword.setModel(new DefaultTableModel(dataMessage, columnNamesMessage)); jScrollPane7.setViewportView(tableTrainTopicKeyword); tableTrainTopicKeyword.setVisible(true); } } }//GEN-LAST:event_cmbTrainTopicActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception ex) { logger.error(LogUtil.stackTrace(ex)); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new InterestTopicMain().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnCleanContent; private javax.swing.JButton btnCreateFileDat; private javax.swing.JButton btnExit; private javax.swing.JButton btnMsg1ToMsg2; private javax.swing.JButton btnRunLDA; private javax.swing.JButton btnTwitterCollectionStart; private javax.swing.JButton btnTwitterCollectionStop; private javax.swing.JComboBox cmbMainTopicResult; private javax.swing.JComboBox cmbTrainTopic; private javax.swing.JComboBox cmboxTopic; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel12; private javax.swing.JLabel jLabel13; private javax.swing.JLabel jLabel14; private javax.swing.JLabel jLabel15; private javax.swing.JLabel jLabel16; private javax.swing.JLabel jLabel17; private javax.swing.JLabel jLabel18; private javax.swing.JLabel jLabel19; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel20; private javax.swing.JLabel jLabel21; private javax.swing.JLabel jLabel22; private javax.swing.JLabel jLabel23; private javax.swing.JLabel jLabel24; private javax.swing.JLabel jLabel25; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel5; private javax.swing.JPanel jPanel6; private javax.swing.JPanel jPanel7; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane3; private javax.swing.JScrollPane jScrollPane4; private javax.swing.JScrollPane jScrollPane5; private javax.swing.JScrollPane jScrollPane6; private javax.swing.JScrollPane jScrollPane7; private javax.swing.JScrollPane jScrollPane8; private javax.swing.JScrollPane jScrollPane9; private javax.swing.JTable jTable2; private javax.swing.JTable jTable3; private javax.swing.JTextField jTextField1; private javax.swing.JLabel labelTitle; private javax.swing.JProgressBar proressBarTwitterCollection; private javax.swing.JTabbedPane tabTwitterCollection; private javax.swing.JTable tableKeyword; private javax.swing.JTable tableMessage; private javax.swing.JTable tableResultFindHideTopic; private javax.swing.JTable tableTopic; private javax.swing.JTable tableTrainTopicKeyword; private javax.swing.JTextField txtContent2Msg1; private javax.swing.JTextField txtContent2Msg1Total; private javax.swing.JTextField txtCreateFileDatNum; private javax.swing.JTextField txtCreateFileDatTotal; private javax.swing.JTextField txtLDAAlpha; private javax.swing.JTextField txtLDABeta; private javax.swing.JTextField txtLDANTopics; private javax.swing.JTextField txtLDANiters; private javax.swing.JTextField txtLDASaveStep; private javax.swing.JTextField txtLDATWords; private javax.swing.JTextField txtLDATrainAlpha; private javax.swing.JTextField txtLDATrainBeta; private javax.swing.JTextField txtLDATrainNTopics; private javax.swing.JTextField txtLDATrainNiters; private javax.swing.JTextField txtLDATrainSaveStep; private javax.swing.JTextField txtLDATrainTWords; private javax.swing.JTextField txtMsg1ToMsg2; private javax.swing.JTextField txtMsg1ToMsg2Total; public static javax.swing.JTextField txtNumCollected; public static javax.swing.JTextArea txtOutput; private javax.swing.JTextArea txtWordTopic; // End of variables declaration//GEN-END:variables }