Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java, Lost on this Assigment, please show output and explain There are 3 parts t

ID: 3831389 • Letter: J

Question

Java, Lost on this Assigment, please show output and explain

There are 3 parts to this assignment,

Part 1.

--Develop a TextAnalyzer class that implements the ITextAnalyzer interface. See ITextAnalyzer.java posted on BlackBoard. You will also need to develop a WordData class that implements the IWordData interface . See IWordData.java posted on BlackBoard.

--The TextAnalyzer class can be configured to use either a java.util.HashMap class or a java.util.TreeMap class to store the unique words and the associated frequency counts. A constructor parameter is used to identifier the type of Map to use.

---The TextAnalyzer reads words from a text file. It counts the number of times (frequency) that the word appears in the file. The TextAnalyzer class does not write to System.out or any file.

Part 2:

--Develop a TextAnalyzerTester class to test the TextAnalyser class developed in Part 1. The test should prove the the TextAnalyzer works correctly.

Part 3:

---Develop a graphical user interface application that uses the TextAnalyzer class developed in Part 1. The TextAnalyzerFrame class See TextAnalyzerFrame.java posted on BlackBoard contains the generated code for the graphical user interface components. You are to complete this class. Most of the work will involve completing the actionPerformed methods for each button.

The application behaves as follows:

---When the “Analyze Text” button is selected, the application displays an open file dialog (see JFileChooser) to select the file to be analyzed. A TextAnalyzer object is created. The selected radio button in the “Map Type” panel indicates how the TextAnalyzer object is configured. The application displays the name of the analyzed file, the total number of words in the file, the number of unique words, and the time it took to the TextAnalyzer object to analyze the file in the “Text Analyzer Log” panel.

---When the “Show Words” button is selected, the application displays all the unique words in ascending alphabetical order and the associated frequency count in the “Text Analyzer Log” panel. It also displays the time it took the TextAnalyzer object to return the words. You can display several words and counts per line.

When the “Show Words By Frequency” button is selected, the application displays all the unique words in decending order by frequency count and the associated frequency count in the “Text Analyzer Log” panel. It also displays the time it took the TextAnalyzer object to return the words. You can display several words and counts per line.

When the “Lookup Word” button is selected, the application will display a dialog box to get the word. The TextAnalyer object will return the text and frequency count for the word. If the word is found, the application will display the word and frequency count in the “Text Analyzer Log” panel. Otherwise it displays a not found message in the panel. It also displays the time it took the TextAnalyer object to lookup the word.

When the “Clear Log” button is selected, the application will clear the text in the “Text Analyzer Log” panel. Before clearing the panel, the application will display a confirmation box. The confirmation box allows the user to cancel the operation.

When the “Save Log to File” button is selected, the application will write the text in the “Text Analyzer Log” panel to a file. The application first displays a save file dialog (See JFileChooser) to select the file. If the selected file already exists (see java.io.File), the application will display a confirmation box asking the user to confirm to overwriting the existing file. The confirmation box allows the user to cancel the operation.

Text files are available at https://archive.org/details/gutenberg. Hand in the output produced by analyzing “Alice’s Adventures in Wonderland” (https://archive.org/details/alicesadventures19033gut). Download the Plain Text UTF-8 version (https://ia801405.us.archive.org/18/items/alicesadventures19033gut/19033- 8.txt).

Here's the IWorldData code:

Here's ITextAnalyzer Code:

****Here's TextAnalyzerFrame Code:*****

Explanation / Answer

private void initComponents() { mapTypeButtonGroup = new javax.swing.ButtonGroup(); logPanel = new javax.swing.JPanel(); logScrollPane = new javax.swing.JScrollPane(); logTextArea = new javax.swing.JTextArea(); mapTypePanel = new javax.swing.JPanel(); useHashMapRadioButton = new javax.swing.JRadioButton(); useTreeMapRadioButton = new javax.swing.JRadioButton(); buttonPanel = new javax.swing.JPanel(); analyzeTextButton = new javax.swing.JButton(); showWordsButton = new javax.swing.JButton(); showWordsByFrequencyButton = new javax.swing.JButton(); lookupWordButton = new javax.swing.JButton(); clearLogButton = new javax.swing.JButton(); saveLogToFileButton = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); logPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Text Analyzer Log")); logTextArea.setColumns(20); logTextArea.setRows(5); logScrollPane.setViewportView(logTextArea); javax.swing.GroupLayout logPanelLayout = new javax.swing.GroupLayout(logPanel); logPanel.setLayout(logPanelLayout); logPanelLayout.setHorizontalGroup( logPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(logScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 836, Short.MAX_VALUE) ); logPanelLayout.setVerticalGroup( logPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(logScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 353, Short.MAX_VALUE) ); mapTypePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Map Type")); mapTypeButtonGroup.add(useHashMapRadioButton); useHashMapRadioButton.setSelected(true); useHashMapRadioButton.setText("Use HashMap"); mapTypeButtonGroup.add(useTreeMapRadioButton); useTreeMapRadioButton.setText("Use TreeMap"); javax.swing.GroupLayout mapTypePanelLayout = new javax.swing.GroupLayout(mapTypePanel); mapTypePanel.setLayout(mapTypePanelLayout); mapTypePanelLayout.setHorizontalGroup( mapTypePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mapTypePanelLayout.createSequentialGroup() .addContainerGap(27, Short.MAX_VALUE) .addGroup(mapTypePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(useTreeMapRadioButton) .addComponent(useHashMapRadioButton)) .addGap(24, 24, 24)) ); mapTypePanelLayout.setVerticalGroup( mapTypePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(mapTypePanelLayout.createSequentialGroup() .addContainerGap() .addComponent(useHashMapRadioButton) .addGap(18, 18, 18) .addComponent(useTreeMapRadioButton) .addContainerGap(35, Short.MAX_VALUE)) ); buttonPanel.setLayout(new java.awt.GridLayout(2, 3)); analyzeTextButton.setText("Analyze Text"); analyzeTextButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { analyzeTextButtonActionPerformed(evt); } }); buttonPanel.add(analyzeTextButton); showWordsButton.setText("Show Words"); showWordsButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { showWordsButtonActionPerformed(evt); } }); buttonPanel.add(showWordsButton); showWordsByFrequencyButton.setText("Show Words By Frequency"); showWordsByFrequencyButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { showWordsByFrequencyButtonActionPerformed(evt); } }); buttonPanel.add(showWordsByFrequencyButton); lookupWordButton.setText("Lookup Word"); lookupWordButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { lookupWordButtonActionPerformed(evt); } }); buttonPanel.add(lookupWordButton); clearLogButton.setText("Clear Log"); clearLogButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { clearButtonActionPerformed(evt); } }); buttonPanel.add(clearLogButton); saveLogToFileButton.setText("Save Log to File"); saveLogToFileButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { saveLogToFileButtonnActionPerformed(evt); } }); buttonPanel.add(saveLogToFileButton); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(logPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(28, 28, 28) .addComponent(mapTypePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(35, 35, 35) .addComponent(buttonPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 629, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(14, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(25, 25, 25) .addComponent(logPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(1, 1, 1) .addComponent(mapTypePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addGap(2, 2, 2) .addComponent(buttonPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE))) .addContainerGap()) ); pack(); }// //GEN-END:initComponents private void clearButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearButtonActionPerformed // TODO add your handling code here: }//GEN-LAST:event_clearButtonActionPerformed private void saveLogToFileButtonnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveLogToFileButtonnActionPerformed // TODO add your handling code here: }//GEN-LAST:event_saveLogToFileButtonnActionPerformed private void analyzeTextButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_analyzeTextButtonActionPerformed // TODO add your handling code here: }//GEN-LAST:event_analyzeTextButtonActionPerformed private void lookupWordButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lookupWordButtonActionPerformed // TODO add your handling code here: }//GEN-LAST:event_lookupWordButtonActionPerformed private void showWordsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showWordsButtonActionPerformed // TODO add your handling code here: }//GEN-LAST:event_showWordsButtonActionPerformed private void showWordsByFrequencyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showWordsByionButtonFrequencyButtonAct // TODO add your handling code here: }//GEN-LAST:event_showWordsByionButtonFrequencyButtonAct /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new TextAnalyzerFrame().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton analyzeTextButton; private javax.swing.JPanel buttonPanel; private javax.swing.JButton clearLogButton; private javax.swing.JPanel logPanel; private javax.swing.JScrollPane logScrollPane; private javax.swing.JTextArea logTextArea; private javax.swing.JButton lookupWordButton; private javax.swing.ButtonGroup mapTypeButtonGroup; private javax.swing.JPanel mapTypePanel; private javax.swing.JButton saveLogToFileButton; private javax.swing.JButton showWordsButton; private javax.swing.JButton showWordsByFrequencyButton; private javax.swing.JRadioButton useHashMapRadioButton; private javax.swing.JRadioButton useTreeMapRadioButton; // End of variables declaration//GEN-END:variables }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote