meisandy Posted October 10, 2010 Posted October 10, 2010 Just a thought, If anyones actually looking at this topic. Surely theres some way to use this (or something along these lines) as a langauge translator? Any one think the same? PS I'll explain more, etc later or if anyone reply's
jvanegmond Posted October 11, 2010 Posted October 11, 2010 PS I'll explain more, etc later or if anyone reply'sOk, how?By the way, your post basically says: "I have an idea, if anyone is interested please ask me what my idea is". Note that 200 people have probably spent time and effort to read your reply and they didn't get anything in return for their effort. github.com/jvanegmond
meisandy Posted October 11, 2010 Posted October 11, 2010 (edited) Oh okay sorry, I'm just pressed for time!I thought it was a bit more self explainartory than that but there you go.Basically, it's just something thats been in my head for months and I can't figure out how commercial programs do it. I know they use different programing langauges and not automation langauges but the method for TRANSLATING LANGAUGES must be the same?!Like, how would you go about doing something like 'an offline version of google translate' in autoit? I've had a go at doing it with _Array functions etc, and I found that it was fine if you where translating - say from english to french "While" To "Pedant que" [i think]because you can just search for "while" in the Array!But if you wanted to translate it back, theres your problem. How would you separate two words from a sentance?Do you see my point?Anyone else had a go with better results?EDIT: This is just an effort towards the forum. But I'd still like to continue this! [Alot, I'm intreged] Edited October 11, 2010 by DjATUit
jvanegmond Posted October 11, 2010 Posted October 11, 2010 Oh okay sorry, I'm just pressed for time! I thought it was a bit more self explainartory than that but there you go. Basically, it's just something thats been in my head for months and I can't figure out how commercial programs do it. I know they use different programing langauges and not automation langauges but the method for TRANSLATING LANGAUGES must be the same?! Like, how would you go about doing something like 'an offline version of google translate' in autoit? I've had a go at doing it with _Array functions etc, and I found that it was fine if you where translating - say from english to french "While" To "Pedant que" [i think] because you can just search for "while" in the Array! But if you wanted to translate it back, theres your problem. How would you separate two words from a sentance? Do you see my point? Anyone else had a go with better results? EDIT: This is just an effort towards the forum. But I'd still like to continue this! [Alot, I'm intreged] That's actually a really common problem with a very common solution. You start by matching the longest strings and go to shorter ones. In that case, pedant que means while since the que ads meaning to pedant and pedant can be used on its own since the string is already matched to pedant que. See below, I have a little script written: Dim $dic[4][2] = [["pedant que", "while"], ["Pedant", "yyyyyyyyyy"], ["que", "xxxx"], [" ", " "]] Dim $translateMe = "pedant que pedant que pedant pedant que que que pedant" ;expected: while while yyyyyy while xxxx xxxx yyyyyyy Dim $result = "" $pos = 1 While 1 For $i = 0 To UBound($dic)-1 $len = StringLen($dic[$i][0]) If StringMid($translateMe, $pos, $len) = $dic[$i][0] Then $result &= $dic[$i][1] $pos += $len ExitLoop EndIf Next If $pos >= StringLen($translateMe) Then ExitLoop EndIf WEnd ConsoleWrite($result & @CRLF) github.com/jvanegmond
meisandy Posted October 12, 2010 Posted October 12, 2010 One word, Manadar Epic Might be bit slow though with 2000 + entries? If it would be, could you incopperate _ArraySearch or something? Would That speed it up?
meisandy Posted October 22, 2010 Posted October 22, 2010 Hi, just to let you knowI've managed to speed things up by searching the array, as I mentioned!But now I've got another problem, and it occurs when I put two words in a sentance like these (for example):Que means xxxx...And...Queh means xxxxhin the setancePedant que que pedant quehIt just turns out: while xxxx yyyyyy xxxx(And it should turn out : while xxxx yyyyyy xxxxh)Now, I think this is because of what StringMid does - when I look at StringMid in a MsgBox it seems to try differen variations of a string, so when it gets to the variation "que" of "queh" it automatically puts the meaning of que instead of queh!Any Idea's on how to stop this?Thanks
jvanegmond Posted October 22, 2010 Posted October 22, 2010 That one was a bit of a brain squeezer but I figured the easiest solution is to add "pedant queh" to the translation list. Maybe this is undesirable, but I think you can work around this by creating a simple dictionary and then compiling it into a long dictionary which automatically ads cases for things like "pedant queh". Dim $dic[6][2] = [["pedant queh", "while xxxxxh"], ["pedant que", "while"], ["Pedant", "yyyyyyyyyy"], ["queh", "xxxxxh"], ["que", "xxxx"], [" ", " "]] Dim $translateMe = "Pedant que que pedant queh" ;expected: while xxxx yyyyyy xxxxh Dim $result = "" $pos = 1 While 1 For $i = 0 To UBound($dic)-1 $len = StringLen($dic[$i][0]) If StringMid($translateMe, $pos, $len) = $dic[$i][0] Then $result &= $dic[$i][1] $pos += $len ExitLoop EndIf Next If $pos >= StringLen($translateMe) Then ExitLoop EndIf WEnd ConsoleWrite($result & @CRLF) github.com/jvanegmond
meisandy Posted October 22, 2010 Posted October 22, 2010 Thanks, but your right (it is undesirable) especially when your reading a dictionary from a file and/or the text that needs translating my vary; I mean in the example I gave it was pedant queh at the end, but I could of been que queh, etc! I guess I could work around it if there was absolutley no other way? But right now, I find hard to see how, especially without adding more than double the entries - which intime would slow it down alot! ???
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now