comp.lang.ada
 help / color / mirror / Atom feed
* Thanks guys..my project and my many problems
@ 2003-02-24 13:52 Paul Gregory
  2003-02-24 15:12 ` Preben Randhol
                   ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: Paul Gregory @ 2003-02-24 13:52 UTC (permalink / raw)


Thank-you Larry and Preban for your kind help.

I'm literally new to ADA and I'm finding it quite difficult if anybody
can help I would be so grateful its untrue!!.

I'm getting really stressed by this - I suppose when you were novices
you were pulling your hair out too ;-)
---------------------------------------------------------------------------------

My project is this

You are invited to design and implement a translation program which will

take an English sentence and translate it into French (and optionally
translate from French
to English).

Your program will use a simple dictionary containing the following
words:

                                                       English
                                                              French
                                                       big
                                                              grand
                                                       black
                                                              noir
                                                       cat
                                                              chat
                                                       dog
                                                              chien
                                                       is
                                                              est
                                                       small
                                                              petit
                                                       the
                                                              le
                                                       white
                                                              blanc


Example 1

Do you wish to add words to the dictionary?: N

Please enter a sentence:
The cat is white.

The French translation of your sentence is:
Le chat est blanc.

Example 2

Do you wish to add words to the dictionary?: N

Please enter a sentence:
The cat is dead.

I cannot translate that sentence.

Example 3

Do you wish to add words to the dictionary?: Y
English word: horse
Equivalent French word: cheval

Do you wish to add more words?: N

Please enter a sentence:
Le cheval est grand.

The English translation of your sentence is:
The horse is big.

______________________________________________________________
My code so far is this..

--
-- Read the English and translate it into French
--
-- Constant array.
--
with Ada.Text_io;
with Nice_IO; use Nice_IO;
with String_tokenizer; use String_tokenizer;
procedure translate6 is
  type English is
    (big, black, cat, dog, es, small, the, white);

  type French is (grand, noir, chat, chien, est, petit, le, blanc);

  English_to_French: constant array(English) of French:=
    ( big                 => grand,
      black          => noir,
      cat               => chat,
      dog => chien,
      es     => est,
      small             => petit,
      the => le,
      white        => blanc);

  S:       String(1..80);   -- Input string
  Last:    Integer;         -- Last character of input string
  S2:       string (1..2);
  First:   Integer;
  Eng:     English;
  my_token : String_tokenizer.Token;
  length : integer;
begin
loop
  Put ("Do you wish to add words to the dictionary? : ");
Ada.Text_IO.Get_Line (S, last);
    Put("Please enter a sentence: ");
    Ada.Text_io.Get_Line(S, Last);
    exit when Last = 0;
    set_string(s(1..Last));  -- this sets up the tokenizer
    while has_more_tokens loop
      my_token := next_token;  -- my_token has the next token in the
string

      length := my_token.token_string_length;  -- length has the length
of this token string
      Eng := English'Value(my_token.token_string(1..length));

    Put_Line ("The French translation of your sentence is: " &
French'Image(English_to_French(Eng)));

    end loop;
end loop;
exception
  when Constraint_Error =>
    Put_Line(S(1..Last) & " cannot be translated");
end translate6;
________________________________________________________________

My problems are the following (deadline Friday - I'm getting really
worried and stressed as I'm reading but finding it hard to understand /
get the information I want for these paticular circumstance...

Problem 1 - the UPPER CASE problem as stated before

(where about in the program would I insert the character.handling bit?)

Problem 2 - When the program translates the tokens it does it as
follows..

When the program translates the tokens it does it like this...

Please enter a sentence: the cat dog

The French translation is : LE
The French translation is: CHAT
The French translation is: CHIEN

----> instead of

The French translation is:  Le chat chien.

Any ideas how I can get round this ?

Problem 3

is that one of the words I have to translate is 'Is' but as this is a
reserved word it causes an error message everytime I run it.

Problem 4

Is that as you can see from the question I have to "add words to the
dictionary" - I'm not overly sure how to do this and presume I'd have to
write some sort of IF statement. Everytime I try and write one it raises
and untold amount of errors.

Basically if they say 'N' I want it to go straight to the translator bit
but if they say 'Y' then they must add a English word, then add the
French version of the word then if I type the added word in a sentennce
it must be able to recognise it....

Nurse...pass me the pills !!

Cheers,

PG






^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2003-03-05  9:22 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-24 13:52 Thanks guys..my project and my many problems Paul Gregory
2003-02-24 15:12 ` Preben Randhol
2003-02-24 15:38 ` Hyman Rosen
2003-02-24 18:08   ` Preben Randhol
2003-02-25  2:01     ` Hyman Rosen
2003-02-25  9:46       ` Preben Randhol
2003-02-25 16:07         ` Hyman Rosen
2003-02-24 18:37   ` Simon Wright
2003-02-24 22:55     ` Jano
2003-02-25 17:36       ` Matthew Heaney
2003-02-25 21:56     ` Simon Wright
2003-02-25  8:45   ` Rodrigo García
2003-02-25 17:34   ` Matthew Heaney
2003-02-25 18:03     ` Hyman Rosen
2003-02-26  8:14       ` Preben Randhol
2003-02-25 17:31 ` Matthew Heaney
2003-02-25 19:57   ` chris.danx
2003-02-25 21:17     ` Chad R. Meiners
2003-03-05  9:22       ` chris.danx
2003-02-26 14:06   ` Paul Gregory
2003-02-26 18:09     ` tmoran
2003-02-27 17:12     ` Update - PLEASE SOMEBODY HELP!!!! Paul Gregory
     [not found]       ` <bot2j-ei3.ln1@beastie.ix.netcom.com>
2003-02-28 10:16         ` Georg Bauhaus
2003-02-28 10:53           ` Paul Gregory
2003-02-28 16:47             ` Simon Wright

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox