comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@on2.com (Matthew Heaney)
Subject: Re: Thanks guys..my project and my many problems
Date: 25 Feb 2003 09:31:33 -0800
Date: 2003-02-25T17:31:33+00:00	[thread overview]
Message-ID: <1ec946d1.0302250931.2fe67884@posting.google.com> (raw)
In-Reply-To: 3E5A2381.21FD3F14@bton.ac.uk

Paul Gregory <pg16@bton.ac.uk> 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



  parent reply	other threads:[~2003-02-25 17:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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
replies disabled

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