#DElete

1 messages ยท Page 1 of 1 (latest)

quiet willowBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

tame gale
#

please put code in .cpp files so we can have syntax colouring.

#

I think you're supposed to create a second dictionary.

uncut tartan
#

shoot sorry!

tame gale
#

Yes I think you need two separate dictionaries.

#

Linked Lists I mean.

#

This is a very strange assignment.

#

Okay then don

#

Actually yeah you don't even need a second.

#

I don't get why your cleanword also adds to the dictionary.

#

It should only clean the word and not add to dictionary.

uncut tartan
tame gale
#

Yes, and remove the parameter for the dictionary reference.

#

You want to do that outside the function.

uncut tartan
tame gale
#

So in the loop .insert it into the dictionary

#

No, but you need to change that to fix the other issue.

#

Inside the loop for the book

#

Don't add the words to anything.

#

Clean the word.

#

Check spelling.

uncut tartan
tame gale
#

and write to the misspelled file.

#

Here's a tip.

#
for(istream bookFile("book.txt"); bookFile >> word;)
#

instead of the while loop

#

and you don't have to close bookFile manually

uncut tartan
novel ibex
lusty oak
#

The program takes hours to run?

uncut tartan
novel ibex
#

does it complete? or does it just run forever

#

like those are big data sets, but not unreasonably so

uncut tartan
#

and the averages should not be 0 or 1

novel ibex
#

Yeah, this should definitely be something that takes seconds or a minute at most, not hours lol

tame gale
#

He's using a linked list.

novel ibex
tame gale
#

Not a hashtable.

#

Prefix tree is probably the correct data structure for this.

lusty oak
#

Is this for school? Do you have to use linked lists?

tame gale
#

I think he does.

uncut tartan
lusty oak
#

Ah

uncut tartan
#

i can give more of the prompt here in a sec to help out sorry

#

i have been struggling with my cosc classes im minoring in it

uncut tartan
tame gale
#

Yeah you definitely don't need two dictionaries.

unique star
#

What you have to use the dictionary as is?

#

Wtf

#

This is just weird assignment lol

uncut tartan
tame gale
#

Replace the while with that and you don't have to manually call .close

#

what

uncut tartan
#

how does that look now

#

no more while

tame gale
#

Yeah, now you just have to fix the inside of the loop.

uncut tartan
tame gale
#

I don't think your code works yet.

uncut tartan
# tame gale I don't think your code works yet.

no not to the point where i want it to haha, let me take a step back you said that i don't need to insert anything into the dictionary. So is this more what you had in mind ? cpp string cleanWord(const string& word) { string cleanedWord; // Declaring a variable to store the cleaned word for (char ch : word) { // Loop through each character in the word if (isalnum(ch) || ch == '\'') { // Check if the character is alphanumeric or an apostrophe cleanedWord += tolower(ch); // Convert the character to lowercase and append it to the cleaned word } } return cleanedWord; // Return the cleaned word }

tame gale
#

Correct.

uncut tartan
tame gale
#

No, add to the dictionary outside the cleanword function.

#

So when you're reading in the dictionary file.

#

Read the word, clean it, insert it.

uncut tartan
# tame gale Read the word, clean it, insert it.
ifstream dictFile("dict.txt"); // Open the dictionary file
    string word; // Declare a variable to store each word read from the file
    while (dictFile >> word) { // Read each word from the dictionary file
        dictionary.insert(word); // Insert the word into the dictionary
    }
    dictFile.close();
#

this is the area where im okay to be doing this then

#

im sorry my code is really messy

tame gale
#

You didn't clean the word.

uncut tartan
# tame gale You didn't clean the word.

hows this look ? cpp ifstream dictFile("dict.txt"); // Open the dictionary file string word; // Declare a variable to store each word read from the file string cleanedWord = cleanWord(word); while (dictFile >> word) { // Read each word from the dictionary file dictionary.insert(word); // Insert the word into the dictionary } dictFile.close();

tame gale
#

No...

#

inside the loop

uncut tartan
tame gale
#

clean the word

#

You are calling cleanword outside the loop.

uncut tartan
#

ok its in it now im sorry

tame gale
#

That looks good.

#

You could turn that into a for loop like before if you don't want to manually call dictFile.close

#

but that's not necessary

#

Although I would recommend that for future code.

uncut tartan
uncut tartan
uncut tartan
# tame gale Although I would recommend that for future code.

Alright so now I have removed my insert to the dict from the clean function, fixed my bookfile loop to a for, and added clean to the dictfile code. It just sucks to see if this fixes my avgs because it takes 2-3 hours to run do you think i should try to run the code and then come back here once its done to give you results?

tame gale
#

Run it on a smaller sample.

#

So it doesn't take as long.

#

A sample small enough that you can manually check if the output is correct.

uncut tartan
#

i used dict.txt as apple
banana
orange
grape
lemon

#

book.txt as apple
banana
lemon
watermelon
orange

tame gale
#

Yeah seems right.

#

watermelon is the odd one out.

#

Now run it on the real example.

uncut tartan
tame gale
#

No problem.

uncut tartan
# tame gale No problem.

okay so it finished, but my professor says this thing should be taking like anywhere from 2-5 hours of runtime. here are my results : dictionary size: 133168
Done checking and these are the results
finished in time: 447.531
There are 950068 words found in the dictionary
981990 compares. Average: 1.0336
There are 27075 words NOT found in the dictionary
981990 compares. Average: 36.2693
There are 4847 words not checked.

[Done] exited with code=0 in 473.85 seconds so this dictionary size is correct which is good. but the average compares dont seem right still and i believe that the words not checked has to be about 2554

#

here is the full prompt and i have some slide notes too i just dont understand what i am missing.

tame gale
#

Depends on hardware.

#

Maybe you have a super fast ocmputer.

uncut tartan
#

maybe i will ask him tomorrow in lecture whats going on i just dont get why my avg is 1

tame gale
#

Compare your output with the expected.

uncut tartan
#

Expected : dictionary size 133168
Done checking and these are the results
finished in time: 1306.53
There are 950068 words found in the dictionary
172150028 compares. Average: 181
There are 27075 words NOT found in the dictionary
19383592 compares. Average: 715
There are 2544 words not checked.

tame gale
#

The word count seem to be correct.

uncut tartan
#

mine : dictionary size: 133168
Done checking and these are the results
finished in time: 447.531
There are 950068 words found in the dictionary
981990 compares. Average: 1.0336
There are 27075 words NOT found in the dictionary
981990 compares. Average: 36.2693
There are 4847 words not checked.

tame gale
#

Send new code maybe you aren't counting the comparisons properly.

uncut tartan
#

okay i will send you my main and my linked list too im sure i messed something up

#

he gives us the timer code and we dont have to change it at all so i dont need to supply that

#

wrong code hold on

tame gale
#

I'm not sure how you're supposed to count the comparisons.

uncut tartan
#

do you mean like how to count each comparison

#

single

#

idk if the notes help much

#

just extra stuff i had

tame gale
#

Yeah I'm not sure how you want to do that.

#

Ask him.

uncut tartan
tame gale
#

No problem.

quiet willowBOT
#

@uncut tartan Has your question been resolved? If so, type !solved :)

uncut tartan
# tame gale No problem.

as for the misspelledfile writing that need sto happen after the timer stops, do i need to open up the book.txt read it again in order to append to the misspelledfile.txt ?

#

needs to*

uncut tartan
#

my linked list stays unchanged

#

this is the most recent run of the code that I did with the output

uncut tartan
#

UPDATE: I fixed my misspelled words count it was counting spaces too! Now i am just trying to figure out where i am going wrong with my averaging!

#

@novel ibex do you have any idea why my avgs are being weird?

uncut tartan
#

@tame gale

tame gale
#

Hi.

quiet willowBOT
#

This question is being automatically marked as stale.
If your question has been answered, type !solved.
If your question is not answered feel free to bump the post or re-ask.
Take a look at !howto ask for tips on improving your question.

uncut tartan
#

@tame gale are you available

tame gale
#

Possibly.

#

Type your question and I'll answer it later.

quiet willowBOT
#

<@undefined>

Please Do Not Delete Posts!

Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.