Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Linux MacOS Ubuntu string Bash , +
I am making a sort of Stereotypical english to russian translator, when I do:
read -p 'Wanna learn russian? Type in an english phrase!: ' ENG
echo $ENG | sed 's/ //g'
It echoes the sentence perfectly fine with no spaces in the sentence. But when I try to do this:
read -p 'You wanna learn russian? then type in an english phrase!:' ENG
ENG=$ENG | sed 's/ //g'
ENG=$ENG | sed 's/a//g'
ENG=$ENG | sed 's/A//g'
ENG=$ENG | sed 's/e//g'
ENG=$ENG | sed 's/E//g'
ENG=$ENG | sed 's/i//g'
ENG=$ENG | sed 's/I//g'
ENG=$ENG | sed 's/o//g'
ENG $ENG | sed 's/O//g'
ENG=$ENG | sed 's/u//g'
ENG=$ENG | sed 's/U//g'
ENG=$ENG | sed 's/y//g'
ENG=$ENG | sed 's/Y//g'
echo $ENG
It echoes:
: bad variable name
ENG: not found
 
: not found
: not found
Please help thanks in advance.
-Jordan
Posted 7-May-12 7:56am
Sicppy1.4K
Edited 7-May-12 8:08am
v2
Comments
SAKryukov at 7-May-12 14:23pm
   
I am just curious: what approach do you want to use to translate into Russian? So far, I never saw a translator which would cope with the job even in simplest cases...
--SA
Sicppy at 7-May-12 14:32pm
   
It's not an actual translator, it just removes all the vowels and spaces.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Out of curiosity, I tried to see how your sample phrase is translated into Russian, in your original form (slightly fixed) and also its equivalent in formally correct English:
 
Wanna learn Russian? Type in an English phrase!
or
Do you want to learn Russian?
Type in an English phrase!
and also
Type an English phrase!
 
I tried to use Google Translate and Bing Translator:
http://translate.google.com[^],
http://www.microsofttranslator.com/[^].
 
In all cases cases, the translation was ridiculously incorrect! In certain cases, even the sense of the second phrase was not recognized. In particular, Bing Translator interpreted "type" in the last clause not as using a keyboard but as "type of something". In all cases, none of the translators could cope with coordination of world forms. The results look comical, "my not understanding yours say what" kind of speech. In Russia, the result of such "translations" and even spelling suggestions is the endless source of jokes. I remember MS World could not recognize correct Russian spelling of the word "multichannel" and suggested a "correction" which could look in back translation like "anal animation" (!!!).
 
No, this is ridiculous. Russian language is too complex for such things. When it comes to Russian, I can foresee some reasonable results in computer translation only when at least yet another generation in linguistic and computer science changes, not sooner. Let's see.
 
—SA
  Permalink  
Comments
Sicppy at 7-May-12 14:46pm
   
First of all, it's not an actual translator, it's a stereotypical translator, meaning, instead of translating it to russian, it translates it to a russian stereotype or what americans see russian as. All this translator is supposed to do is take out all the vowels and spaces in a sentence. Second of all, that wasn't a sample phrase, that was just the question phrase, it's what pops up when the program first starts that tells you it wants input.
SAKryukov at 7-May-12 17:53pm
   
It's getting wonderfuller and wonderfuller, curiouser and curiouser... :-)
Yes, I got it, about non sample. It does not matter -- I just used it as a sample to test the translator with amazingly pathetic failure of both translators.
 
But I'm really curious now: in what sense the behavior you are explaining can be called a "translator", and what would be the purpose of it?
You still offers a user the prompts: "Wanna learn Russian? Type in an English phrase!" Is it a joke or what? How could it possibly help learning Russian? Or English? :-)
 
--SA
Sicppy at 7-May-12 20:47pm
   
Yes, it is a joke, and it's translating English to Stereotypical Russian, even if it's not translating from English to actual Russian, it's still a translator.
 
If you actually do know how to program in bash, I would like some help getting the program to work, so please run this code on your mac/linux distro and see if you can't get it to work.
 
-Jordan
SAKryukov at 8-May-12 12:44pm
   
I don't have an installation in my hands right now, but ENG=$ENG looks suspecious, as ENG was already defined above. If first define a variable without '$' and later refer to it with '$', that's the normal pattern. You probably need to introduce another variable on left. I would actually prefer scripting in Python, which is readily available in all distro. The problem is very simple...
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Instead of:
ENG=$ENG | sed 's/ //g'
 
try:
ENG=`echo $ENG | sed 's/ //g'`
Note that this uses back-quotes after the equal sign and the last character.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.140821.2 | Last Updated 8 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100