Author Topic: VrrtepCLI  (Read 21083 times)

0 Members and 1 Guest are viewing this topic.

Offline Swoka Ikran

  • Palulukan Makto
  • *****
  • *
  • Posts: 1642
  • Karma: 29
Re: VrrtepCLI: Translator+
« Reply #100 on: May 26, 2011, 02:49:21 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

Offline Tirea Aean

  • The Blue One
  • Olo'eyktan Anawm
  • Palulukan Makto
  • *****
  • *
  • *
  • *
  • Posts: 9910
  • nv Eywa'eveng
  • Karma: 243
  • Oeri ran lu srung
    • Tirea Aean
Re: VrrtepCLI: Translator+
« Reply #101 on: May 26, 2011, 03:06:25 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.
« Last Edit: May 26, 2011, 03:08:34 pm by Tirea Aean »

kelku ikranä a hawnventi yom podcast (na'vi-only): https://tirearadio.com/podcast
Learn Na'vi Discord Chat: https://discord.gg/WF6qcmv

Offline Swoka Ikran

  • Palulukan Makto
  • *****
  • *
  • Posts: 1642
  • Karma: 29
Re: VrrtepCLI: Translator+
« Reply #102 on: May 26, 2011, 03:28:49 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. :)

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

Offline Tirea Aean

  • The Blue One
  • Olo'eyktan Anawm
  • Palulukan Makto
  • *****
  • *
  • *
  • *
  • Posts: 9910
  • nv Eywa'eveng
  • Karma: 243
  • Oeri ran lu srung
    • Tirea Aean
Re: VrrtepCLI: Translator+
« Reply #103 on: May 26, 2011, 03:42:43 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. :)

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.

kelku ikranä a hawnventi yom podcast (na'vi-only): https://tirearadio.com/podcast
Learn Na'vi Discord Chat: https://discord.gg/WF6qcmv

Offline Swoka Ikran

  • Palulukan Makto
  • *****
  • *
  • Posts: 1642
  • Karma: 29
Re: VrrtepCLI: Translator+
« Reply #104 on: May 26, 2011, 03:58:37 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.
« Last Edit: May 26, 2011, 06:58:04 pm by Swoka Ikran »
2010 was the year of the Na'vi.Vivar 'ivong Na'vi!

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

Offline Human No More

  • Palulukan Makto
  • *****
  • *
  • Posts: 1591
  • Karma: 15
  • Misplaced.
    • Tree of Souls
Re: VrrtepCLI: Translator+
« Reply #105 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.
"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

Offline Tirea Aean

  • The Blue One
  • Olo'eyktan Anawm
  • Palulukan Makto
  • *****
  • *
  • *
  • *
  • Posts: 9910
  • nv Eywa'eveng
  • Karma: 243
  • Oeri ran lu srung
    • Tirea Aean
Re: VrrtepCLI: Translator+
« Reply #106 on: May 26, 2011, 07:49:57 pm »
use the windows one. xD

kelku ikranä a hawnventi yom podcast (na'vi-only): https://tirearadio.com/podcast
Learn Na'vi Discord Chat: https://discord.gg/WF6qcmv

Offline Swoka Ikran

  • Palulukan Makto
  • *****
  • *
  • Posts: 1642
  • Karma: 29
Re: VrrtepCLI: Translator+
« Reply #107 on: May 26, 2011, 07:55:38 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.
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

Offline Tirea Aean

  • The Blue One
  • Olo'eyktan Anawm
  • Palulukan Makto
  • *****
  • *
  • *
  • *
  • Posts: 9910
  • nv Eywa'eveng
  • Karma: 243
  • Oeri ran lu srung
    • Tirea Aean
Re: VrrtepCLI: Translator+
« Reply #108 on: May 26, 2011, 08:38:46 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.
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.

kelku ikranä a hawnventi yom podcast (na'vi-only): https://tirearadio.com/podcast
Learn Na'vi Discord Chat: https://discord.gg/WF6qcmv

Offline Blue Elf

  • Palulukan Makto
  • *****
  • *
  • *
  • Posts: 5499
  • cz Czech Republic
  • Karma: 112
    • My attempt for blog
Re: VrrtepCLI: Translator+
« Reply #109 on: May 27, 2011, 01:47:24 am »
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)


Offline Tirea Aean

  • The Blue One
  • Olo'eyktan Anawm
  • Palulukan Makto
  • *****
  • *
  • *
  • *
  • Posts: 9910
  • nv Eywa'eveng
  • Karma: 243
  • Oeri ran lu srung
    • Tirea Aean
Re: VrrtepCLI: Translator+
« Reply #110 on: May 27, 2011, 04:16:32 am »
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. :)

kelku ikranä a hawnventi yom podcast (na'vi-only): https://tirearadio.com/podcast
Learn Na'vi Discord Chat: https://discord.gg/WF6qcmv

Offline Swoka Ikran

  • Palulukan Makto
  • *****
  • *
  • Posts: 1642
  • Karma: 29
Re: VrrtepCLI: Translator+
« Reply #111 on: May 27, 2011, 12:29:51 pm »
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.
« Last Edit: May 28, 2011, 01:23:39 pm by Swoka Ikran »
2010 was the year of the Na'vi.Vivar 'ivong Na'vi!

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

Offline Tirea Aean

  • The Blue One
  • Olo'eyktan Anawm
  • Palulukan Makto
  • *****
  • *
  • *
  • *
  • Posts: 9910
  • nv Eywa'eveng
  • Karma: 243
  • Oeri ran lu srung
    • Tirea Aean
Re: VrrtepCLI: Translator+
« Reply #112 on: May 27, 2011, 04:05:03 pm »
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.
« Last Edit: May 27, 2011, 09:04:34 pm by Tirea Aean »

kelku ikranä a hawnventi yom podcast (na'vi-only): https://tirearadio.com/podcast
Learn Na'vi Discord Chat: https://discord.gg/WF6qcmv

Offline Swoka Ikran

  • Palulukan Makto
  • *****
  • *
  • Posts: 1642
  • Karma: 29
Re: VrrtepCLI: Translator+
« Reply #113 on: May 27, 2011, 04:06:41 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

Offline Kä'eng

  • Uniltìranyu
  • **
  • Posts: 133
  • Karma: 12
Re: VrrtepCLI: Translator+
« Reply #114 on: May 28, 2011, 03:08:50 am »
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!

Offline Swoka Ikran

  • Palulukan Makto
  • *****
  • *
  • Posts: 1642
  • Karma: 29
Re: VrrtepCLI: Translator+
« Reply #115 on: May 28, 2011, 11:24:07 am »
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

Offline Kä'eng

  • Uniltìranyu
  • **
  • Posts: 133
  • Karma: 12
Re: VrrtepCLI: Translator+
« Reply #116 on: May 28, 2011, 12:19:03 pm »
Just convert both word and a to UTF-16:

Code: [Select]
    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!

Offline Swoka Ikran

  • Palulukan Makto
  • *****
  • *
  • Posts: 1642
  • Karma: 29
Re: VrrtepCLI: Translator+
« Reply #117 on: May 28, 2011, 01:18:36 pm »
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:
Quote
UnicodeEncodeError: '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.
« Last Edit: May 28, 2011, 01:21:39 pm by Swoka Ikran »
2010 was the year of the Na'vi.Vivar 'ivong Na'vi!

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

Offline Kä'eng

  • Uniltìranyu
  • **
  • Posts: 133
  • Karma: 12
Re: VrrtepCLI: Translator+
« Reply #118 on: May 28, 2011, 01:44:51 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).)

Quote
Also, as soon as I change code pages (I used CP852 - East Europe, which was what Blue Elf was using), it crashes with:
Quote
UnicodeEncodeError: '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.
« Last Edit: May 28, 2011, 01:49:15 pm by Kä'eng »
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!

Offline Swoka Ikran

  • Palulukan Makto
  • *****
  • *
  • Posts: 1642
  • Karma: 29
Re: VrrtepCLI: Translator+
« Reply #119 on: May 28, 2011, 02:30:27 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 :)

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?
« Last Edit: May 28, 2011, 02:35:26 pm by Swoka Ikran »
2010 was the year of the Na'vi.Vivar 'ivong Na'vi!

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

 

Become LearnNavi's friend on Facebook Follow LearnNavi on Twitter! Watch LearnNavi's videos on YouTube

SMF 2.0.15 | SMF © 2017, Simple Machines
Privacy Policy
| XHTML | RSS | WAP2 | Site Rules

LearnNavi is not affiliated with the official Avatar website,
James Cameron, LightStorm Entertainment or The Walt Disney Company.
All trademarks and servicemarks are the properties of their respective owners.
Images in the LearnNavi.org Forums and Gallery may not be used without permission.

LearnNavi Affiliates:
ToS

LearnNavi is the community to learn Na'vi, the Avatar Language
"A place where real friendships are made." -Paul Frommer

AvatarMeet | Learn Na'vi Forum | Learn Na'vi Wiki | Na'viteri

LearnNavi