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 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-02-25 09:31:33 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mheaney@on2.com (Matthew Heaney) Newsgroups: comp.lang.ada Subject: Re: Thanks guys..my project and my many problems Date: 25 Feb 2003 09:31:33 -0800 Organization: http://groups.google.com/ Message-ID: <1ec946d1.0302250931.2fe67884@posting.google.com> References: <3E5A2381.21FD3F14@bton.ac.uk> NNTP-Posting-Host: 66.162.65.162 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1046194293 31697 127.0.0.1 (25 Feb 2003 17:31:33 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 25 Feb 2003 17:31:33 GMT Xref: archiver1.google.com comp.lang.ada:34569 Date: 2003-02-25T17:31:33+00:00 List-Id: Paul Gregory wrote in message news:<3E5A2381.21FD3F14@bton.ac.uk>... > > 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). You could use Charles, which contains data structures that are exactly suited to your problem. package Translation_Tables is new Charles.Maps.Sorted.Strings.Unbounded (Element_Type => Charles.Strings.Unbounded.Container_Type); E2F : Translation_Tables.Container_Type; Insert (E2F, "big", Element => To_Container ("grand")); Insert (E2F, ...); procedure Lookup (E : String) is I : constant Iterator_Type := Find (E2F, Key => E); begin if I = Back (E2F) then --not found else declare F : Element_Subtype renames To_Access (I); --no copy --or F : constant Element_Subtype := Element (I); --copy begin --do something with F end; end if; end Lookup; The string map above accepts a key comparison operator as a generic formal subprogram, so you could plug one in that provides a case-insensitive compare. There's also a map version implemented as a hash table, and there's a hash function provided for type String. (The sorted version is implemented as a red-black tree.) I used the new Charles string container as the map element, but you could just as easily use any other non-limited type, such as Ada.Strings.Unbounded. A string pointer would also suffice, too. http://home.earthlink.net/~matthewjheaney/charles/ The most recent release occurred on 18 Feb 2003. Drop me a line if you have any questions. Matt