Question: 1 /** 2 * FileRelations is intended to be a simple search engine to find the most related text files possible 3 * @author [Your

1 /** 2 * FileRelations is intended to be a simple search engine to find the most related text files possible 3 * @author [Your Name] 4 * @version 1.0 5 */ 6 7 import java.io.*; 8 9 public class FileRelations{ 10 11 /** 12 * a String holding the file name for the highest scoring file 13 */ 14 private String topFile; 15 /** 16 * an int holding the score for the highest scoring file 17 */ 18 private double topScore; 19 /** 20 * wordsToFind: a String array holding all the words to search for 21 */ 22 private String[] wordsToFind; 23 24 /** 25 * This is the primary and only constructor for the FileRelations class. 26 * @param toFind holds all the key words to search for 27 */ 28 public FileRelations(String[] toFind){ 29 public String userInput; 30 31 //TODO 1 Initialize instance variables 32 } 33 34 /** 35 * Analyses the file based on the keywords and updates the top scoring file and score once done. 36 * @param fileContent an array of Strings each representing a line in the original file 37 * @param fileName the name of the file being analysed 38 */ 39 public void analyseFile(String[] fileContent, String fileName){ 40 //TODO 4 41 // Search the fileContent array to find the frequency of words in each line, using the scoreLine method 42 // Divide the score by the total number of lines 43 // Compare to and possibly replace topScore 44 // Assign the topFile to the file name with topScore if needed 45 } 46 47 /** 48 * Analyses the line passed in and scores it based on frequency of the key words. A helper method for analyseFile. 49 * @param line a String representing a single line in a file 50 * @returns the score of the line passed in 51 */ 52 private int scoreLine(String line){ 53 //TODO 3 54 // Split the line into words 55 // Score each word and sum those scores 56 // Return the sums 57 return 0; 58 } 59 60 /** 61 * Analyses the word passed in and scores it based on if it is one of the key words. A helper method for scoreLine. 62 * @param word a String representing a single word in a file 63 * @returns the score of the word passed in 64 */ 65 private int countWord(String word){ 66 //TODO 2 67 // Compare word to each of the wordsToFind and count the words 68 // Return the result of the word comparison 69 return 0; 70 } 71 72 /** 73 * A getter method for the key words used in this object's search 74 * @returns a String array containing the key words to search for. 75 */ 76 public String[] getWords(){ 77 //TODO 5 78 return null; 79 } 80 81 /** 82 * A getter method for the top scoring file in the object currently 83 * @returns a String representing the file name of the top scoring file. 84 */ 85 public String getTopFile(){ 86 //TODO 6 87 return ""; 88 } 89 90 /** 91 * A getter method for the score of the top scoring file in the object currently 92 * @returns an int representing the score of the top scoring file. 93 */ 94 public double getTopScore(){ 95 //TODO 7 96 return 0; 97 } 98 }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!