Hey, i am new to python. I am making a translator in python 2.6 using basic commands. The translator is english to german. I need to use a i need to use a text file like this...

at an
brown braun
cat raze
etc.

so far i have created lists inside a list which i hope will help me. If anyone has any ideas if im on the right track or can tell me how to finish the code it would be appreciated

the code so far is...

fin = open("english2german.txt", "r")
data_list = fin.readlines()
fin.close()
data_list = [item.rstrip('\n') for item in data_list]
data_list = [item.split('\t') for item in data_list]
print data_list

this gives...

[['at', 'an'], ['brown', 'braun'], ['cat', 'raze'], ['dog', 'hund'], ['down', 'huegelland'], ['end', 'ende'], ['exit', 'abfahrt'], ['fever', 'fieber'], ['fox', 'fuchs'], ['he', 'er'], ['i', 'ich'], ['in', 'in'], ['is', 'ist'], ['it', 'es'], ['jumps', 'abspruenge'], ['lazy', 'lustig'], ['mainly', 'hauptsaechlich'], ['mat', 'matte'], ['not', 'nicht'], ['on', 'an'], ['over', 'uber'], ['plain', 'blanko'], ['quick', 'schnell'], ['rain', 'regen'], ['sat', 'sitz'], ['she', 'sie'], ['spain', 'spanien'], ['start', 'anfang'], ['the', 'der'], ['up', 'auf']]

Take a look at the approach taken in:
http://www.daniweb.com/forums/post1122938.html#post1122938

The word the will give you a real problem since it can translate to der, die or das

If you use lower case only:
the cat --> die katze
the dog --> der hund
the house --> das haus

dont worry about that, im just going to use der

what about using something to split words

Take a look at the approach taken in:
http://www.daniweb.com/forums/post1122938.html#post1122938

The word the will give you a real problem since it can translate to der, die or das

If you use lower case only:
the cat --> die katze
the dog --> der hund
the house --> das haus

Also den.

Google built a really good translator,
so I would use the API, in some way like this:
http://code.google.com/p/py-gtranslate/source/browse/trunk/gtrans.py

But it requires a connection to the internet to use, so I guess that's the main disadvantage.

this is actually part of an assignment. that is why der has to be used and the text file has to be used aswell. It would be preferred if i didnt import anything either at the start

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.