From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c3155860644be062,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-02-24 06:41:13 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!server3.netnews.ja.net!newshost.central.susx.ac.uk!news.bton.ac.uk!not-for-mail From: Paul Gregory Newsgroups: comp.lang.ada Subject: Thanks guys..my project and my many problems Date: Mon, 24 Feb 2003 13:52:01 +0000 Organization: University of Brighton Message-ID: <3E5A2381.21FD3F14@bton.ac.uk> NNTP-Posting-Host: cs202c3.it.bton.ac.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: saturn.bton.ac.uk 1046094315 16371 193.62.172.42 (24 Feb 2003 13:45:15 GMT) X-Complaints-To: news@bton.ac.uk NNTP-Posting-Date: 24 Feb 2003 13:45:15 GMT X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:34512 Date: 2003-02-24T13:45:15+00:00 List-Id: 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