emory-courses / dsa-java

Data Structures and Algorithms in Java
https://emory.gitbook.io/dsa-java/
42 stars 55 forks source link

[HW#2] test file #125

Closed caroltang0331 closed 3 years ago

caroltang0331 commented 3 years ago

In the unit test, the max = 20, but why do the three expected have only 3 or 4 strings instead of 20 strings?

    prefix = "sh";
    expected = List.of("she", "ship", "shell");
    testGetCandidates(ac, eval, prefix, expected);

    prefix = "sh";
    expected = List.of("she", "ship", "shell", "school");
    testGetCandidates(ac, eval, prefix, expected);

    prefix = "sh";
    expected = List.of("ship", "she", "shell");
    ac.pickCandidate(prefix, "ship");
    testGetCandidates(ac, eval, prefix, expected);`
HallOfSam commented 3 years ago

I feel confused about this as well. Also, technically, when the given prefix is "sh", shouldn't the first candidate be "sh" since it is the shortest word that starts with "sh"?

caroltang0331 commented 3 years ago

"sh" is not a word in the dictionary tho, so prolly wont show up as a candidate unless its picked before

HallOfSam commented 3 years ago

"sh" is not a word in the dictionary tho, so prolly wont show up as a candidate unless its picked before

Thank you so much for your response! I thought it was in the provided text file. How should I check if it is a word in the dictionary though?

caroltang0331 commented 3 years ago

oh wait it was. I missed it. Sorry. u were right i think it should be the first suggestion then. Also do you know how to get that file into IntelliJ, just copy paste?

HallOfSam commented 3 years ago

The function that reads a text file is already provided in AutoComplete and AutoCompleteHW will call its superclass' constructor to read the file. So try this in your main method: AutocompleteHW hw = new AutocompleteHW("src/main/resources/dict.txt", #maxCandidates, e.g. 20).

caroltang0331 commented 3 years ago

Thanks so much! hmm so when i copy the dict.txt file to the main/resources folder on my IntelliJ, got an error saying file is too large. do u hv that problem? might just go office hr this hw is so hard even to start

HallOfSam commented 3 years ago

Thanks so much! hmm so when i copy the dict.txt file to the main/resources folder on my IntelliJ, got an error saying file is too large. do u hv that problem? might just go office hr this hw is so hard even to start

Yeah I got the same message. But if you read carefully, you will realize that the message appears only because certain functions of IntelliJ are disabled when the file is too large. You can still use it and browse thorough it.

caroltang0331 commented 3 years ago

thanks its working now!