Questions tagged [pset6]

The problem set for Week 7

Filter by
Sorted by
Tagged with
0
votes
1answer
200 views

CS50 2017: string index out of range when trying to load words into dictionary (dict.update())

I am at the very first part of pset6, which is just loading words in the text files into memory. I am using a python dict structure. To test a simple case first, I created a test-words.txt file, put ...
0
votes
2answers
41 views

How do you delete a line depending on its first character?

When trying to delete all of the comments in positive-words.txt I have tried iterating over the lines and checking if the line startswith ';' however I do not know how to delete the line if it does. ...
0
votes
1answer
43 views

Tokenizer adds space before text

When I tokenize my text, it is adding a space before it, and I am unable to strip it. tokenizer = nltk.tokenize.TweetTokenizer() tokens = tokenizer.tokenize(text) x = 0 for i in tokens: token = ...
0
votes
1answer
29 views

Tokenizer changing text

When I try to tokenise some text to check its sentiment, the tokeniser automatically adds [''] around it. So if my text says good, when I tokenize it and print it, it says ['good']. Please can you ...
0
votes
1answer
49 views

pset6 - range value in for loop

i implemented mario (less) in the following way import cs50 while True: x = cs50.get_int("Height: ") if x > 0 and x < 23: break hashes = 2 for i in range(x-1): for j in ...
0
votes
1answer
69 views

Pset 6 sentiments init function

I'm working on the init function is sentiments and I'm struggling a bit on what to put in the for loop. This is what I have so far, can someone tell me if this is correct or how to fix it? def ...
0
votes
1answer
41 views

Pset6 analyzer getting positive words from text and turning them into a string

I'm trying to get the analyzer function to work and I'm really just not fully understanding what to do and how to do it. I think I need to take each line of the text files and have put into a string. ...
0
votes
1answer
33 views

Using open.readlines, why won't it return the list?

My understanding of this part of sentiments is that I need to open the positive words file and make it all into a list, I thought I could do this with open.readlines, but it isn't working. Can someone ...
0
votes
1answer
29 views

pset6 sentiments init help

I just started working on the sentiments, at the moment I'm loading the positive words into a list and printing them out at a test. I'm having trouble with the for loops for getting each word into the ...
0
votes
1answer
40 views

Starting pset6, sentiments

I'm really not completely understanding how to get started on sentiments. I think I need to load the positive and negative words into the memory of analyze, but I don't really understand how I go ...
0
votes
1answer
40 views

analyzer.py cant store string in my dictionary

For some reason when i run the following python code I get the following error: Traceback (most recent call last): File "/home/ubuntu/workspace/pset6/sentiments/analyzer.py", line 20, in init ...
0
votes
1answer
389 views

pset6 caesar in python

I'm currently working in rewriting caesar into python, and I'm making good progress but I keep running into an error, after I enter the plaintext, it says Traceback (most recent call last): File "...
0
votes
1answer
308 views

pset6 mario.less

I recently started pset6, so I'm making the transition into python, and I'm having a little bit of trouble trying to figure it all out. I have the code for mario.less and it prints correctly, but its ...
0
votes
1answer
59 views

mario.py builds pyramid for > 23 even though condition set to <= 23

I've tried to get better re: testing not just for a successful result, but for the behavior I want for any given input. My code looks ok to me, but it's building the pyramid even when height > 23. It ...
1
vote
2answers
748 views

pset6 - Similarities: compare has error receiving lists

In Similarities, I'm told that my functions in helpers.py (lines, sentences, and substrings) should return lists. However, when I try testing my functions, I receive an error telling me that "object '...
0
votes
1answer
73 views

How can for File IO works in Python?

I have finished pset5 and now on pset6 but I have one doubt about how we can read the file without file.read() or readlines() etc. I understand both code file = open(“testfile.txt”, “r”) c = file....
0
votes
0answers
746 views

Pset6: Python how to extract a single number as int from a list of strings of numbers

i = 0 sum = 0 sum += number[i] i += 2 It gives me this error: 'int' object is not subscriptable Googled it. Don't understand. What I want to do is add every other number in a credit card number, ...
0
votes
2answers
134 views

mario pset6 wrong side hashes

I'm a bit stuck in pset6 mario, hashes are printed in right number but not on the right side. I've tried to figure out myself but haven't come up with any correct solution so far so i'd really ...
0
votes
1answer
76 views

tokens in analyzer and tweets not working ? - sentiments - pset 6

i ve been reading post because the tokens is not working in the analyzer and i don t understand how come in all post i ve red about tweets there are no tokens at all (but zamyla said to use the tokens ...
-1
votes
1answer
117 views

caesar.py else syntax

In my caesar.py program, I seem to have a syntax error with one of my else statements, however I triple checked the indentation, made sure to include a colon afterwards, it is inline with the if ...
0
votes
0answers
77 views

Pset6 2017 Sentiments WebServer running problem

I have a problem running Pset6. I'm following instructions. I have set access rights, run flask and then click "CS50 IDE" -> "Web Server" in the left top corner and have an exception "Error opening ...
0
votes
1answer
83 views

Python: location of variable in code

I have a functional version of "Vigenère" for pset6 but I noted an issue with the location of a variable that I would appreciate some insight on. While iterating through each letter of the plaintext ...
0
votes
1answer
72 views

TweetTokenizer don't process 3 specific words

I am working on analyzer and smile. Except "a+", "2-faced" and "2-faces" my code works correctly.These words should give me ':)', ':(', ':('. But all of them give me ':|'. I am sure these words in ...
0
votes
1answer
293 views

Pset6 credit.py always outputs INVALID

I'm currently re-implementing every one of my projects that could be bettered before I submit them all. Right now, I'm stuck on my re-implementation of pset6 credit. For some reason, it always outputs ...
0
votes
1answer
188 views

Flask run application.py chart is alwys yellow

How the hell this flask works? I made application.py looks like this: from flask import Flask, redirect, render_template, request, url_for import os import helpers from analyzer import Analyzer app ...
0
votes
1answer
40 views

pset6 tweets subtraction when word is negative doesn't work

import nltk class Analyzer(): """Implements sentiment analysis.""" def __init__(self, positives, negatives): """Initialize Analyzer.""" # TODO self.pos_words = set() #starting set ...
0
votes
1answer
185 views

pset6 how do we check for string in mario

I've tried to find out how to check for string input for mario.py. I know to check for the range of integers when getting input from the user, but if they enter a string instead of a number, is there ...
0
votes
1answer
78 views

In pset6, have an error right from the start with mario.py

Here is my code so far in its entirety: import cs50 def main(): I immediately had an error (red dot with x next to def main): unexpected EOF while parsing I like that python notifies right away ...
0
votes
1answer
688 views

I don't understant how TweetTokenizer works

!/usr/bin/env python3 import os import sys from analyzer import Analyzer from termcolor import colored from helpers import get_user_timeline from nltk.tokenize import TweetTokenizer def main(): # ...
0
votes
1answer
1k views

Simple Python Loop Not Working

I'm converting the more comfortable version of mario.c to Python3 and cannot get the following loop to work: running = True while running: print("Height: ", end="") height = cs50.get_int() ...
0
votes
2answers
62 views

Pset 6 Words are randomly not being added to the dictionary

For the most part my solution to pset6 works, it correctly fetches the tweets, graphs them, and analyzes them, but for some reason some words will not get added to my dictionary. For example hate ...
0
votes
1answer
293 views

PSET 6: Caesar.py - stuck on "SyntaxError: invalid syntax"

For my caesar implementation in Python, the CS50 IDE keeps telling me that I have a syntax error at the else portion of my for loop as shown below. Any help would be GREATLY appreciated! Haha, thanks ...
0
votes
1answer
59 views

Pset6 analyzer.py not incrementing counter

I've checked over my code many times for errors, but everything looks logically sound to me. For some reason, "counter" in the analyze method will never change, which means that my conditional ...
0
votes
1answer
117 views

A simple question in application.py sentiments

Why neutral starts from 100.0, why not 0 like positive and negative positive, negative, neutral = 0.0, 0.0, 100.0 and is this right? for tweet in tweets: score = analyzer.analyze(tweet.lower()) ...
1
vote
1answer
171 views

greedy.py returning integer variable ending with .0 even w/ conversion from float to int() & round()

I am converting my greedy.py function and since python does not have datatypes, i'm getting really confused as to why my code does not convert to an int w/out a .0 ending. Code: import cs50 class ...
0
votes
1answer
208 views

pset6 sentiments PYTHON analyze

Hello stack overflow I am really having trouble with sentiments as I feel like I put the write functions down but it is not working. A question that I have is can someone help me understand how the ...
1
vote
1answer
824 views

Error in pset6 API Key not set

I'm getting this error, I have been working to make it work but i can't. I followed the instructions on setting up the API_KEY value: Traceback (most recent call last): File "tweets", line 25, in ...
0
votes
1answer
382 views

cs50 pset 6 caesar

I imported the below mention libraries but still getting this tracback error anyone who can help import cs50 import sys def main(): if len(sys.argv) is not 2: print("Please give me valid key") ...
0
votes
1answer
234 views

cs50 pset 6 greedy

import cs50 def main(): count = 0 while True: print(" O hai ! How much change is owed ?") input = cs50.get_float() if input >= 0: break input = ...
0
votes
1answer
77 views

Smile/Analyzer always return 0

I've been on this for a while and can't figure out the mistakes. Please correct me if i am mistaken. On running the code, the returned value is always 0. (2) When I use the 'startwith' function i'm ...
0
votes
1answer
184 views

PSET6 Loading Positive/Negative Words in Analyzer

I'm trying to get ./smile to work before moving on to tweets using just one word as input to check it my words are loading correctly. I structured the first function similar to how it is done in ...
0
votes
1answer
400 views

Pset6 Crack.py: could not find the right password

Since I started CS50 back in 2016, I didn't implement the C version of "crack"; and now I'm in some trouble. I have written this giant for-loop structure iterating each element in the 4-character ...
0
votes
1answer
30 views

Question about python dict syntax, how to past from one dict variable to another?

why does this code not work and gives back (TypeError: 'str' object does not support item assignment) : sharesOwned = {'name': 'Apple.inc', 'symbol': 'AAPL', 'price':110, 'name': 'Google', 'symbol': '...
0
votes
3answers
3k views

python invalid syntax end=""

The first print line I use , end="" in has a red dot next to it and is marked as invalid syntax. The python code still works with no problems but the invalid syntax is always there. I even copied ...
0
votes
1answer
180 views

When I run ./tweets @user_name, I get API_KEY not set and when do flask run ,I get this e What could be wrong?

builtins.SyntaxError File "/home/ubuntu/workspace/pset6/sentiments/application.py", line 26 return redirect (url_for("index")) ^ SyntaxError: 'return' outside function
0
votes
1answer
216 views

pset6, how can one resolve this error in sentiments, OSError: [Errno 98] Address already in use

/workspace/pset6/sentiments/ $ flask run * Serving Flask app "application" * Forcing debug mode on Traceback (most recent call last): File "/usr/local/bin/flask", line 11, in sys.exit(main()) ...
0
votes
1answer
1k views

Can someone help and hint me why I'm having this problem in sentimental, pset6! [duplicate]

File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 2000, in __call__ return self.wsgi_app(environ, start_response) File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1991, ...
0
votes
0answers
26 views

Pset6 Tweets - Installed pip3 install --user -r requirements.txt and it ruined my code :( [duplicate]

Trying to built tweets on pset6 and am encountering some errors, is it due to bad installation? What caused that error message? Should i have not used the import functions and i Here is my code: #!...
0
votes
1answer
74 views

pset6-analyzer: Please, can someone help me out. Analyzer gives me this error!

Traceback (most recent call last): File "./smile", line 6, in from analyzer import Analyzer File "/home/ubuntu/workspace/sentiments/analyzer.py", line 1, in import nltk
0
votes
1answer
87 views

pset6, caesar.py. I'm really having syntax issues with python! What could be the problem with this expression?

a = ord("plaintext[i]")? even though I do this: a = ord(plaintext[i], the response is the same! The compiler returns with this reply: Please, help!!! Traceback (most recent call last): File "...

1
3 4
5
6 7
17