Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

I seek /prog/'s help.

Name: Anonymous 2009-07-28 0:06

Hello /prog/. Before you dismiss this as a request for a walkthrough, I would gladly read it somewhere if someone knows of a manual I can read to make this program.

I need to make a program that's flash-card like, in that it presents a word and you have to translate it. Is there a way I can do this in Python?
Ideally the simpler the better. At the very least I would like it to work:
It displays a word in a different language, with a prompt to enter it's equivalent in another language, and it checks if it's right, if it is, it says that, and moves on, removing it from the list of what to ask, if not, it marks it to a list and comes back to it later. Also, would one be able to have this list randomized?

Name: Anonymous 2009-07-28 0:09

Yes.

Name: Anonymous 2009-07-28 0:13

>>1
That program already basically exists and it's called Anki. Though you'd need to write a plugin to do the prompt as it uses the mouse. Use the Source, Luke!

Name: Anonymous 2009-07-28 0:16

>>3
Well I know there are such programs that exist, it's just that I can't bring myself to write useless exercising-programs in Python so I 'learn' the commands. No matter how well I know them, I'll never use the language unless I have a reason to. I'm a fan of learning foreign languages and I figured this would be a low-medium difficulty program and since I've made another more basic py program this would be a good thing to move up to.

Name: Anonymous 2009-07-28 0:20

>>4
That's why I said just write the plugin. You wanted a manual or something similar, but I don't know of one, that's why I suggested using the source code of an already existing one and adapting it. It's in python too.

Name: Anonymous 2009-07-28 0:39

#!/usr/bin/python2.5

import random
from sys import stdin

filename = "wordpairs.txt"

f = open(filename)
pairs = dict()

for line in f:
    a, _, b = line.partition(':')
    pairs[a.strip()] = b.strip()

f.close()

total, right = 0, 0

while len(pairs) > 0:
    k = random.choice(pairs.keys())
    print "\033[1m" + k + "\033[0m" + "? ",
    answer = stdin.readline().strip()

    if answer == pairs[k]:
        print "Correct!"
        del pairs[k]
        right += 1
    else:
        print "Wrong!"
    total += 1

print "Done! Your final score is %d / %d (%.2f%%)." % (right, total,
                                                       right * 100. / total)


Whine whine whine.
Just put your shit in wordpairs.txt, in the format foreign word or phrase:translated word or phrase.

The way to learn a language is to start with a basic tutorial, then find a simple problem that interests you and doing it. Not finding a problem that interests you and then looking for a tutorial on how to solve that problem online.

Name: Anonymous 2009-07-28 2:53

>>1
Don't do it like that, OP. Just display the question, have the user press a key to see the answer, then have them indicate whether they were right or wrong. Worst case scenario: two key presses, as opposed to either lots of key presses or getting input methods for non-latin alphabets set up then pressing lots of keys.

If you really wanted to do it right you'd rip off Supermemo's spaced repetition algorithm. Doesn't seem like there's much point in writing an ineffective flashcard program, even for learning purposes.

Name: Anonymous 2011-01-31 20:08

<-- check em dubz

Name: Anonymous 2011-02-03 3:46

Don't change these.
Name: Email:
Entire Thread Thread List