VrrtepCLI

Started by Tirea Aean, May 22, 2011, 03:40:58 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Swoka Ikran

Quote from: Tirea Aean on May 26, 2011, 02:01:01 PM
I've ported your code and credited you in the comments and did some re-writing of the quiz module to make it fit. it currently works on the linux version.

Cool. Is the quiz module the only change in the attachment?

It works on Windows, but unicode support is broken again, and the "clear" function doesn't work (because CLEAR is not a valid command on Windows. It's CLS. OS detection can be used to choose the correct command).

Also, I spent an hour googling and messing with the scramble issue...not looking good so far. :(
2010 was the year of the Na'vi.Vivar 'ivong Na'vi!


 
Avatray | NWOTD Sigbars | Sacred's Sigbar Tool | My collection of Avatar merchandise

Tirea Aean

#101
Quote from: Swoka Ikran on May 26, 2011, 02:49:21 PM
Quote from: Tirea Aean on May 26, 2011, 02:01:01 PM
I've ported your code and credited you in the comments and did some re-writing of the quiz module to make it fit. it currently works on the linux version.

Cool. Is the quiz module the only change in the attachment?

It works on Windows, but unicode support is broken again, and the "clear" function doesn't work (because CLEAR is not a valid command on Windows. It's CLS. OS detection can be used to choose the correct command).

Also, I spent an hour googling and messing with the scramble issue...not looking good so far. :(

It's the only MAJOR change. there are other differences between the linux/mac and windows versions. seems you might have discovered some of them.

right. I was gonna say that stuff but forgot. yes, cls is what's supposed to be in that version, and the linux version didnt need any unicode(), but apparently win did. I just kinda pulled together my linux version resources and zipped it up.

sorry to hear about the scramble game.. I have a feeling the quiz game would be more popular anyway.

Swoka Ikran

Quote from: Tirea Aean on May 26, 2011, 03:06:25 PM
right. I was gonna say that stuff but forgot. yes, cls is what's supposed to be in that version, and the linux version didnt need any unicode(), but apparently win did. I just kinda pulled together my linux version resources and zipped it up.
Well, the zip was called LIN_release.zip, so I kinda figured it was linux code. ;) I'll fix the unicode and clear function for Windows. :)

Quote from: Tirea Aean on May 26, 2011, 03:06:25 PM
sorry to hear about the scramble game.. I have a feeling the quiz game would be more popular anyway.
Is it possible to make it choose words without ä or ì ? If so, we could keep the feature and just have a limited word set on Windows. (CMD's unicode support sucks big time...now I'm starting to see the benefits of Linux)

Also, you forgot to remove a call to quiz() that you have at the bottom of quiz.py. I'm assuming it was for debugging. With it there, nothing else works (arguments are ignored, program always runs quiz).
2010 was the year of the Na'vi.Vivar 'ivong Na'vi!


 
Avatray | NWOTD Sigbars | Sacred's Sigbar Tool | My collection of Avatar merchandise

Tirea Aean

Quote from: Swoka Ikran on May 26, 2011, 03:28:49 PM
Quote from: Tirea Aean on May 26, 2011, 03:06:25 PM
right. I was gonna say that stuff but forgot. yes, cls is what's supposed to be in that version, and the linux version didnt need any unicode(), but apparently win did. I just kinda pulled together my linux version resources and zipped it up.
Well, the zip was called LIN_release.zip, so I kinda figured it was linux code. ;) I'll fix the unicode and clear function for Windows. :)

Quote from: Tirea Aean on May 26, 2011, 03:06:25 PM
sorry to hear about the scramble game.. I have a feeling the quiz game would be more popular anyway.
Is it possible to make it choose words without ä or ì ? If so, we could keep the feature and just have a limited word set on Windows. (CMD's unicode support sucks big time...now I'm starting to see the benefits of Linux)

Also, you forgot to remove a call to quiz() that you have at the bottom of quiz.py. I'm assuming it was for debugging. With it there, nothing else works (arguments are ignored, program always runs quiz).

right, that was debug. I removed that in my source after attaching it. sorry about that

well yes it is possible to only scramble non special char words on win version I'll look into that. limited word set is better than none.

Swoka Ikran

#104
Quote from: Tirea Aean on May 26, 2011, 03:42:43 PM
well yes it is possible to only scramble non special char words on win version I'll look into that. limited word set is better than none.
Ok :)

Updated quiz module is working beautifully on Windows. Unicode and CLS issues are fixed :)

EDIT: Think I may have just found a way to cheat and make ì and ä work in scramble...


RE-EDIT: Tried my discovery in a variety of codepage/locale configurations. Not a good solution. :( Research also indicates it will break Linux support.
2010 was the year of the Na'vi.Vivar 'ivong Na'vi!


 
Avatray | NWOTD Sigbars | Sacred's Sigbar Tool | My collection of Avatar merchandise

Human No More

I really need to have a go with this... but I'll need to set up a working Linux VM first as I don't have one at the moment.
"I can barely remember my old life. I don't know who I am any more."

HNM, not 'Human' :)

Na'vi tattoo:
1 | 2 (finished) | 3
ToS: Human No More
dA
Personal site coming soon(ish

"God was invented to explain mystery. God is always invented to explain those things that you do not understand."
- Richard P. Feynman

Tirea Aean


Swoka Ikran

Quote from: Human No More on May 26, 2011, 06:34:33 PM
I really need to have a go with this... but I'll need to set up a working Linux VM first as I don't have one at the moment.
Quote from: Tirea Aean on May 26, 2011, 07:49:57 PM
use the windows one. xD
Agreed. :D

@TA: You need to edit the first post. It still says its Mac/Linux only and that it does not support Windows.
2010 was the year of the Na'vi.Vivar 'ivong Na'vi!


 
Avatray | NWOTD Sigbars | Sacred's Sigbar Tool | My collection of Avatar merchandise

Tirea Aean

Quote from: Swoka Ikran on May 26, 2011, 07:55:38 PM
Quote from: Human No More on May 26, 2011, 06:34:33 PM
I really need to have a go with this... but I'll need to set up a working Linux VM first as I don't have one at the moment.
Quote from: Tirea Aean on May 26, 2011, 07:49:57 PM
use the windows one. xD
Agreed. :D

@TA: You need to edit the first post. It still says its Mac/Linux only and that it does not support Windows.

oh! too true. edited.

Blue Elf

So, is fixed version for Windows already available?
Oe lu skxawng skxakep. Slä oe nerume mi.
"Oe tasyätxaw ulte koren za'u oehu" (Limonádový Joe)


Tirea Aean

I didn't update the zip on the site. swoka ikran never sent me his most updated version. including standalone. but I was thinking I really want prefix and lenition support before releasing. swoka ikran I sent you the linux version and it claims to be v.2 it's really not supposed to be yet. how bout v.1.9? send me the most upiated win version and I'll upload it as well as linux version. then finally I can start an prefix recognition. :)

Swoka Ikran

#111
Quote from: Tirea Aean on May 27, 2011, 04:16:32 AM
swoka ikran I sent you the linux version and it claims to be v.2 it's really not supposed to be yet. how bout v.1.9? send me the most upiated win version and I'll upload it as well as linux version. then finally I can start an prefix recognition. :)
I only used the quiz module from your linux v2, so mine still says 1.8. AFAIK, there were no functional differences in the main or rhyme modules.

Scramble is still broken, and will remain so until we can get a limited (no ä or ì words) wordset version for Windows. You can play it as-is, but you'll have to "ans" all words with ì or ä in it. Issue is caused by a limitation in CMD. Apparently it's actually caused by Python, and is fixable...see posts below.

I'll change version numbers to 1.9 and compile it. :)

EDIT: Had to squish another unicode bug. Anyway, here it is. "v1.9": http://swokaikran.skxawng.lu/files/vcli_win.zip - Both versions included.
2010 was the year of the Na'vi.Vivar 'ivong Na'vi!


 
Avatray | NWOTD Sigbars | Sacred's Sigbar Tool | My collection of Avatar merchandise

Tirea Aean

#112
much thanks. I'll update that tonight. (this post will be edited.)

EDIT: I have updated the windows scramble module to ignore words containing ä and/or ì and use all the rest.
Here is the zip. The windows release is attached. Swoka Ikran, you might wanna convert the newlines in the major txt files (README, ChangeLog etc) before compiling and releasing again. when you do, I'll put THAT and the linux version up on tirea.skxawng.lu/source.

Swoka Ikran

Quote from: Tirea Aean on May 27, 2011, 04:05:03 PM
much thanks. I'll update that tonight. (this post will be edited.)
You're welcome :)
2010 was the year of the Na'vi.Vivar 'ivong Na'vi!


 
Avatray | NWOTD Sigbars | Sacred's Sigbar Tool | My collection of Avatar merchandise

Kä'eng

Quote from: Swoka Ikran on May 27, 2011, 12:29:51 PM
Scramble is still broken, and will remain so until we can get a limited (no ä or ì words) wordset version for Windows. You can play it as-is, but you'll have to "ans" all words with ì or ä in it. Issue is caused by a limitation in CMD.
Actually, the Windows console (CMD is just one program that uses the console, don't confuse the two) allows any Unicode character to be input, even ones that can't be displayed in the current codepage! It's python that is to blame here; the raw_input function only returns text in the OEM codepage, but you could convert both it and the true word to Unicode for comparison: unicode(raw_input(), sys.stdin.encoding) == unicode(word, "utf-8").

BTW, I notice scramble takes a couple seconds to start, because of the way listscramble has to keep searching through the rst list in rst.count(rno). You could speed this up by having a set of which numbers have been added so far, since checking whether something is in a set (unlike a list) is quick no matter how large the set gets, but a simpler solution would be to use the Fisher-Yates shuffle algorithm (which Python has in the standard library: random.shuffle)
Ma evi, ke'u ke lu prrte' to fwa sim tuteot ayawne.
Slä txo tuteo fmi 'ivampi ngat ro seng, fu nìfya'o, a 'eykefu ngati vä', tsakem ke lu sìltsan.
Tsaw lu ngeyä tokx! Kawtu ke tsun nìmuiä 'ivampi ngat txo ngal ke new tsakemit.
Ha kempe si nga? Nì'awve, nga plltxe san kehe. Tsakrr, ngal tsatsengti hum!

Swoka Ikran

Quote from: Kä'eng on May 28, 2011, 03:08:50 AM
Quote from: Swoka Ikran on May 27, 2011, 12:29:51 PM
Scramble is still broken, and will remain so until we can get a limited (no ä or ì words) wordset version for Windows. You can play it as-is, but you'll have to "ans" all words with ì or ä in it. Issue is caused by a limitation in CMD.
Actually, the Windows console (CMD is just one program that uses the console, don't confuse the two) allows any Unicode character to be input, even ones that can't be displayed in the current codepage! It's python that is to blame here; the raw_input function only returns text in the OEM codepage, but you could convert both it and the true word to Unicode for comparison: unicode(raw_input(), sys.stdin.encoding) == unicode(word, "utf-8").
I tried that, and it doesn't work. :(

In the output below, notice that the sys.stdin.encoding encoded user input and the UTF-8 "correct answer" don't match. It looks like sys.stdin.encoding is making UTF-16, yet word is in UTF-8. I tried encoding the correct answer various ways, but Python throws an error and quits.

The unicode warning is easily fixable, but I didn't bother since the hex shows they won't match anyway...

Thanks for the help so far though :) I'm not a python programmer, so there's a LOT to learn. My 2 main languages both deal with unicode pretty much automatically.
2010 was the year of the Na'vi.Vivar 'ivong Na'vi!


 
Avatray | NWOTD Sigbars | Sacred's Sigbar Tool | My collection of Avatar merchandise

Kä'eng

Just convert both word and a to UTF-16:


    for word in scramlist:
        word,scr = scramble(word)
        word = unicode(word,"utf-8")
        print 'word: '+unicode(scr,"utf-8")+'\n'
        a = unicode(raw_input("vrrtep:> "), sys.stdin.encoding)
        while a != word and a!= "ans" and a!= "/quit" and a!= "/exit" and a != "/q":
            score -= 1
            print "\nKehe. :\\"+' score:',score,'\n'
            a = unicode(raw_input("vrrtep:> "), sys.stdin.encoding)
        if a == word:
            score += 1
            print "\nSrane! >:D"+' score:',score,'\n'
        elif a == "ans":
            score -= 1
            print word
            print "score:",score,'\n'
        elif a == "/quit" or a == "/exit" or a == "/q":
            break
        count += 1
Ma evi, ke'u ke lu prrte' to fwa sim tuteot ayawne.
Slä txo tuteo fmi 'ivampi ngat ro seng, fu nìfya'o, a 'eykefu ngati vä', tsakem ke lu sìltsan.
Tsaw lu ngeyä tokx! Kawtu ke tsun nìmuiä 'ivampi ngat txo ngal ke new tsakemit.
Ha kempe si nga? Nì'awve, nga plltxe san kehe. Tsakrr, ngal tsatsengti hum!

Swoka Ikran

#117
Apparently I'm a skxawng, because I copied your code and it works :)

Now I'm curious as to why yours does and mine doesn't. Mine was identical except for the word = unicode(word,"utf-8") line and 2 debug print statements.

I noticed you said to convert to UTF-16, but your code has unicode(word, UTF-8). I'm guessing that UTF-8ing something that's already UTF-8 makes UTF-16 out of it?

Also, as soon as I change code pages (I used CP852 - East Europe, which was what Blue Elf was using), it crashes with:
QuoteUnicodeEncodeError: 'charmap' codec can't encode character u'\xec' in position 7
: character maps to <undefined>

...so there's no international support. I can force the app to run in CP437 so it won't crash, but fixing it this way requires users to change their locale...otherwise ä and ì appear incorrectly.
2010 was the year of the Na'vi.Vivar 'ivong Na'vi!


 
Avatray | NWOTD Sigbars | Sacred's Sigbar Tool | My collection of Avatar merchandise

Kä'eng

#118
Quote from: Swoka Ikran on May 28, 2011, 01:18:36 PM
I noticed you said to convert to UTF-16, but your code has unicode(word, UTF-8). I'm guessing that UTF-8ing something that's already UTF-8 makes UTF-16 out of it?
The unicode(string, charset) function takes a string in the specified character set and returns it converted to UTF-16. (To do the opposite, converting a UTF-16 string to something else, you could use string.encode(charset).)

QuoteAlso, as soon as I change code pages (I used CP852 - East Europe, which was what Blue Elf was using), it crashes with:
QuoteUnicodeEncodeError: 'charmap' codec can't encode character u'\xec' in position 7
: character maps to <undefined>

...so there's no international support. I can force the app to run in CP437 so it won't crash, but fixing it this way requires users to change their locale...otherwise ä and ì appear incorrectly.
Codepage 852 does not have the ì character. And one annoying quirk of the Windows console is that its raster fonts only have characters for an individual codepage, so if you choose a different codepage it won't look right. However, if you go into the console properties and use a TrueType font instead (Lucida Console is the only choice it gives you), you'll always see the right characters for the current codepage.
Ma evi, ke'u ke lu prrte' to fwa sim tuteot ayawne.
Slä txo tuteo fmi 'ivampi ngat ro seng, fu nìfya'o, a 'eykefu ngati vä', tsakem ke lu sìltsan.
Tsaw lu ngeyä tokx! Kawtu ke tsun nìmuiä 'ivampi ngat txo ngal ke new tsakemit.
Ha kempe si nga? Nì'awve, nga plltxe san kehe. Tsakrr, ngal tsatsengti hum!

Swoka Ikran

#119
Quote from: Kä'eng on May 28, 2011, 01:44:51 PM
The unicode(string, charset) function takes a string in the specified character set and returns it converted to UTF-16. (To do the opposite, converting a UTF-16 string to something else, you could use string.encode(charset).)
That explains a lot. :) So charset specifies the encoding of the input, not the output...I thought it was taking string and returning it converted to charset (e.g. unicode(asciistring,"utf-8"): ASCII goes in, UTF-8 comes out.) I should use string.encode(charset) for conversion to a specific format, and unicode() only for converting to UTF-16.

Now I understand :)

Quote from: Kä'eng on May 28, 2011, 01:44:51 PM
Codepage 852 does not have the ì character. And one annoying quirk of the Windows console is that its raster fonts only have characters for an individual codepage, so if you choose a different codepage it won't look right. However, if you go into the console properties and use a TrueType font instead (Lucida Console is the only choice it gives you), you'll always see the right characters for the current codepage.
Never knew that about Raster Fonts...

Am I correct in saying that the best advice here is to always run the app with CP437, and just have international users change their font to Lucida to see it?
2010 was the year of the Na'vi.Vivar 'ivong Na'vi!


 
Avatray | NWOTD Sigbars | Sacred's Sigbar Tool | My collection of Avatar merchandise