language translation using pointers

My C programming teacher gave us one last bring home assignment, but really don't have any idea on what she's giving us, can someone help me on this?:

Using pointers, create a tagalog - english translation program that requires the user to input a sentence. Your program must output a rough English translation which should also be in a sentence form.

I just need the codes even if it's not tagalog language.

thanks in advance.

From newbie of C++
This is a simple lookup and replace.

You need a "dictionary", a list of words that match.

Our initial dictionary can be simple:

"kumusta" --> "how"
"ka"      --> "you"
"ngayon"  --> "now"


Given the sentence: "Kumusta ka ngayon?"
Apply your dictionary, word for word, and you'll get: "How you now?"

That's a pretty good approximation of what a native English speaker would say: "How are you today?"

There are other things you can do to refine the translation, but that is probably enough to do your assignment. You can read more advanced stuff here:
http://wiki.tcl.tk/10262



I'm not sure exactly how your teacher wants you to use pointers to accomplish this. There are a number of ways I can think of... The most simple would probably be to have an array of pairs -- or a pair of arrays -- that have the two sides.
1
2
3
4
5
6
7
8
9
10
11
12
13
typedef struct
  {
  const char* tagalog;
  const char* english;
  }
entry_t;

const entry_t[] =
  {
  { "kumusta", "how" },
  { "ka",      "you" },
  { "ngayon",  "now" }
  };

You will have to do some processing on your input also:
1. convert everything to lowercase
2. tokenize on whitespaces (to get individual words)
3. watch out for trailing punctuation
4. find the word and write the matching word in the output string
5. don't forget the punctuation
6. capitalize the first word in the final output string

Good luck!
thanks for the fast replay, trying my best to build the codes needed =)

thank you so much!
bad news, i have read the site you have given but understand nothing T_T she want us to pass it tomorrow deadline 12 midnight. btw, is there only limited word you can input?
It sounds like you should have been working on this for some time now...

Build yourself a dictionary like I suggested, where each Tagalog word is paired with its English equivalent, then read words from the user, find them in the dictionary, and print out the equivalent.

The other site is for the Tcl programming language, not C++. The important stuff is in understanding what is going on. You can safely ignore it because you don't really need the advanced stuff for your assignment.

Your program will be limited to the dictionary you build. That means that only certain phrases and sentences will be able to be translated by it. For example, the dictionary I built above is only really good for translating the phrase "how are you today?". Try for common sayings, like "hello" and "how are you doing?" and "my name is X" and "what is your name?".

Good luck!
Last edited on
could you make the codes for me? I really don't have idea on C++. please.
Topic archived. No new replies allowed.