Questions tagged [dictionary]
The dictionary tag has no usage guidance.
153
questions
0
votes
1
answer
51
views
My code looks and works correctly but check50 fails
import csv
import sys
global y
def main():
y = 0
x = 0
# Check for command-line usage
if len(sys.argv) != 3:
sys.exit("Usage: python dna.py data.csv sequence.txt")
...
0
votes
1
answer
20
views
Pset5 Speller - trying to understand more about segmentation fault
I tested a piece of code to figure out what's causing the segmentation fault with the 'load' function. The code below opens the large dictionary. Then it scans and prints each string inside the ...
0
votes
1
answer
38
views
segmentation fault from pointers
i keep getting segmentation fault when running this code. using printf i can see its from loading ala and the hashtable to store this is set to nil. other words when the hashtable to store them is nil ...
0
votes
1
answer
24
views
PSET 9 Finance - NONETYPE error after querying db
Need help solving this error:
File "/workspaces/finance/app.py", line 223, in sell
if available_shares < shares:
TypeError: '<' not supported between instances of 'NoneType' and 'int'
...
0
votes
1
answer
286
views
pset6 DNA - help creating and referencing dictionaries
This may be a strange question - my code actually worked, but I feel like I got to a solution by brute force, rather than something more elegant.
I'm still not sure how to create and reference ...
0
votes
1
answer
55
views
PSet5 - Dictionary loading only one word
I've been banging my head for the last few hours as to why my dictionary function only saves one word from the whole dictionary. Even though debug50 and printf shows different hashes for different ...
0
votes
1
answer
750
views
Program is free of memory errors, valgrind tests failed - pset5 speller
I'm am getting this error - program is free of memory errors, valgrind tests failed; see log for more information.
I have tried so many things but I keep getting more errors. Here is my code:
// ...
0
votes
1
answer
98
views
PSET6 DNA Why is my (count consecutive substrings in string) function always returns 0's?
I tried writing different function variations but my count_dna function keeps returning zeroes (despite having consecutive sequences of STRs in the dna sequences)--can anyone please tell me why?
Note: ...
1
vote
1
answer
58
views
What is the usage of creating DICTIONARY_H in pset5?
I cann't understand when to use the preprocessor directives as (ifndef, define ,etc.)? In dictionary.h, what is the importance of writing those statements? and regarding the reason that was mentioned ...
0
votes
2
answers
187
views
Pset5 Speller,Check function isn't working as expected, strcasecmp always returns false
The problem is the word is found in loaded dictionary it's found but check function still returns false
i've been like 7 days in this problem someone helps please,
((I'm Trying to test code ./speller ...
0
votes
1
answer
58
views
Print keys of CSV files in DNA pset6
I want to see what the keys of the reader dictionary are so I use the print(key) function. The result is all the lines of the dictionary. Why is that?
import csv
from sys import argv, exit
# Check if ...
0
votes
1
answer
82
views
Pset 5 Speller: Could not load small
I don´t know what may be happening with my code. When I run it without any dictionaries it runs (although is also not able to open cat.txt), but when I try to run it using small it could not load it.
/...
0
votes
1
answer
63
views
pset5 speller "Could not load dictionaries/large" error
#include <ctype.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "dictionary.h"
#define ...
0
votes
1
answer
100
views
I dont understand valgrind pset5
Error from valgrind
$ valgrind ./speller texts/cat.txt
==1453== Memcheck, a memory error detector
==1453== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1453== Using Valgrind-3.13....
0
votes
1
answer
360
views
Finance index function does not return lookup value in index.html
I'm trying to render my lookup values inside of my index function implementation, but I cannot get these values to render in my index.html page. I added share = lookup(record['share_symbol']) to grab ...
0
votes
1
answer
91
views
Finance index.html is not rendering values from my index function
I'm having some issues trying to render values on my index.html page. In my index function, I created a dictionary of values from my transactions table to grab each record of my share symbols, share ...
0
votes
1
answer
76
views
Please help! I'm stuck on Pset5 Speller!
#include <stdbool.h>
#include <stdlib.h>
#include "dictionary.h"
#include <string.h>
#include <stdio.h>
#include <ctype.h>
int wordCount = 0;
// Represents a ...
1
vote
2
answers
62
views
Pset5: check unable to find words
Thankfully, I don't get any seg faults so I'm guessing unload() is working properly. Also, load() seems to run correctly when debugging, so I'm guessing the problem isn't on loading either. I don't ...
0
votes
1
answer
55
views
PSET5 Speller everything works but then I catch all the words as misspelled
Basically when I run the test with texts/lalaland.txt and compare to the staff's key, they have something like 955 misspelled words and I have all but 5 misspelled. I tried to but a "tolower"...
0
votes
1
answer
583
views
pset5 valgrind tests failed
I'm very close to completing pset5; all smiley faces except the Valgrind memory leak. I'm hoping someone can help find the problem. I am only leaking 112 bytes and have tried to fix the issue by ...
0
votes
1
answer
75
views
PSET 5 My hash table doesn't seem to be storing correctly
When I load the dictionary, I add the words to the hash table, by calling the hash function to calculate the bucket ID, then add hash function to actually insert it into the list.
Inside the addhash ...
0
votes
2
answers
248
views
strcpy not working with struct items
bool load(const char *dictionary)
{
char splitStrings[9999][45];
FILE* dict = fopen(dictionary, "r");
node* item = table[0];
int i = 0;
for (i = 0; fscanf(dict, "%...
0
votes
0
answers
173
views
check50 keeps printing "Could not load basic/dict." what might be the problem in the code?
// Implements a dictionary's functionality
include
include
include
include "dictionary.h"
include
include
include
// Number of buckets in hash table
define N 120000
//maximum length of ...
1
vote
0
answers
116
views
PSET6: dna.py, updating dictionary
I'm struggling with Python, specifically adding/updating keys and values in a dictionary.
This is my code so far (I know it's probably far from perfect, this is my first time working with Python, ...
0
votes
1
answer
203
views
pset5 speller "Could not load dictionaries/large"
I cannot figure out what I am missing.
Program keeps returning "Could not load dictionaries/large"
I have checked and tried different suggestions from similar questions but I do have the folder ...
0
votes
1
answer
110
views
CHECK50 ERRORS IN SPELLER PSET
Here is my code for the pset
I am getting 2 errors after check50. I am not able to get hold of any loopholes in the code. Kindly help!
1) :( handles max length (45-char) words
expected "MISSPELLED ...
0
votes
1
answer
45
views
I am having a segmentation fault before my main code runs, but code will compile. pset 5 - speller
// Implements a dictionary's functionality
#include "dictionary.h"
// Represents a node in a hash table
typedef struct node
{
char word[LENGTH + 1];
struct node *next;
}
node;
// Number of ...
0
votes
1
answer
27
views
trie speller works on custom dict but misses mispellings on large dictionary
So my speller works fine with a custom dict, but not with the large dict.
This is my code in dictionary.c (haven't modified other files):
// Implements a dictionary's functionality
#include <...
0
votes
1
answer
22
views
Pset4 Speller (Hash table) word count only fails in check50
All of the "WORDS IN DICTIONARY: " parts are resulting in "0"
but when i run the code on my computer trying both the "small" and "large" dictionary it seems to work perfectly. So what might be the ...
1
vote
0
answers
33
views
dictionary hints?
I just submitted my dictionary code to the Big Board. My results weren't horrific (well, I did use more memory than anyone else, lol); but I'm a little disheartened when comparing to the best results. ...
0
votes
1
answer
36
views
dictionary.c trie: setting variable to NULL doesn't set element to NULL
Working on the unload function in speller (dictionary.c)...
My current test dictionary simply contains a letter c, as I'm just trying to make sure one iteration will work.
So I should (and do, ...
0
votes
1
answer
113
views
Check50 issues, Pset 4, Speller
My code finally works, and I believe it is operating correctly but check50 says otherwise. Anyone see any blatant issues in my code that you can point out?
// Implements a dictionary's functionality
...
1
vote
0
answers
63
views
CS50, pset2, crack, suggested dictionary file
I am taking cs50 on edx and I am currently on pset2, crack. I want to find a dictionary file that has a fair (maybe over 50,000?) amount of words in it to encrypt and compare them with the hashed ...
0
votes
1
answer
306
views
Unload works on small dictionary, but not on large? (speller.c / hash table method)
When testing with the small dictionary, it unloads as expected however when testing with the large dictionary, I receive the error "Could not unload dictionaries/large."
The only difference that I've ...
0
votes
0
answers
31
views
I keep getting seg faults when running code
I've been looking through my code, but I'm unable to figure out why my code keeps seg faulting. I used my own custom hash function to take the first character of each string in the dictionary to 26 ...
0
votes
1
answer
223
views
2018 pset4 dictionary check() doesn't check dictionary
I'm in a pickle here.
I have followed walkthrough step by step for this part.
But my code just keeps on refusing to load dictionary.
(Sorry for the low quality code here)
bool load(const char *...
0
votes
1
answer
79
views
Scramble.c lookup function found flag
So I've got the binary search function working for this problem, but I have no idea how to deal with the "found" flag portion of the problem. I think the idea is to add a "true" condition to the bool ...
0
votes
1
answer
49
views
Pset5 Speller dictionary entries getting overwritten
I'm having problems with pset5 speller where the words I load into my dictionary hash table are getting overwritten. So for example if I load "Ashley", "Britney" and "Charlie" into my dictionary, all ...
0
votes
1
answer
1k
views
error: use of undeclared identifier 'word'
I've been having quite a few issues with Pset5 and I can't figure anything out. I've been playing around with the placement of 'char word[LENGTH+1]' but I always get an error: "use of undeclared ...
0
votes
1
answer
208
views
dictionary.c not iterating through the linked list, if the hash exists it always returns true
Trying to figure out a bug in my dictionary.c code. Please bear with me as I try to explain the bug.
I've been using the debugger, and it seems that anytime there is a collision in my hash table, ...
0
votes
1
answer
306
views
Please help with Speller: all words return misspelled
I've combed through my code for this pset and reviewed the walkthroughs and shorts countless times and am now resigned to admit I need help.
Thanks to Peter, I'm no longer leaking any memory (yay!), ...
0
votes
1
answer
558
views
PSET 5 Spell Checker - Error: Could not load dictionaries/large
I would be so grateful to anyone who can help me figure out this issue.
After finally getting my code to compile I was met with the following terminal error when attempting to run the program:
"...
0
votes
1
answer
117
views
Problem in unload
I am having problem in my unload. While running valgrind it shows no leaks, but the program wont acquiesce check50. Here is the unload function:
//free the memory
bool freenode(node *first)
{
//...
0
votes
2
answers
260
views
Pset5 - Valgrind causes 9544106 errors, Uninitialised value was created by a heap allocation
Im unsure if there is any error in my recursion in unloading/unload to free all memory. (But i doubt so because help50 tells me all my memory were freed- 367,084 allocs, 367,084 frees)
I checked ...
0
votes
1
answer
110
views
pset5 speller dictionary errors
Can someone give me feedback on my code please? I can't compile this, and it says too many errors. A lot of the errors don't seem to make sense. For example, it says "error: use of undeclared ...
0
votes
2
answers
80
views
PSET5 Speller Trie Errors
So far, all other methods except check have already been implemented properly in my code. The problem with check is that it only returns true a lot fewer times than expected, which means that most ...
0
votes
1
answer
647
views
Need help with check in speller (trie)
Stuck on speller, especially check, but load has some problems too.
I am using a trie, but I kind of regret choosing it, because it has been very tough.
I believe my problem is with the use of *next ...
0
votes
1
answer
1k
views
pset5 speller Invalid write of size 1
my implementation of dictionary.c passes all checks using check50 except memory leaks. I'm using valgrind and most of my leaks seem to be happening in my check function:
// Returns true if word is ...
0
votes
1
answer
59
views
For the spell checker, isn't the dictionary data structure only made of local variables?
For the spell check program, we have to read the dictionary from a file into a data structure (e.g. linked list, hash table with linked lists, a try). However, we have to do this within the function ...
0
votes
1
answer
534
views
Segmentation Fault on Hashtable
PLease Someone help me
I was trying to implement a hash table that stores the word of English language for pset 5. So to be in brief, I used an array of linked list ( Chaining ) , I haven't made the ...