[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [LOCALE] Hjælp til frekvensanalyse



Jacob Sparre Andersen skrev:
> Ole Laursen skrev:

> > Jeg sidder med oversættelsen af Gnome Online Keyboard (til
> > bl.a. handicappede) som skal bruge de to følgende
> > tegnfølger sorteret efter brug:
[...]
> Jeg har brugt Korpus 90' frekvensordbog til følgende
> optælling af tegnhyppigheder:

Når Peter nu inkluderer kode til at løse opgaven baseret på
en rå tekst, så må jeg hellere også inkludere koden til at
løse opgaven baseret på en frekvensordbog.  Inddata er er en 
tabulatorsepareret liste med ord og deres hyppigheder.  
Uddata er en tabulatorsepareret liste med bogstaver og deres 
hyppigheder.

with Ada.Characters.Latin_1;
with Ada.Long_Integer_Text_IO;
with Ada.Strings.Unbounded;
with Ada.Text_IO;
with UStrings;

procedure Ordfrekvenser_Til_Bogstavfrekvenser is
   use Ada.Long_Integer_Text_IO;
   use Ada.Strings.Unbounded;
   use Ada.Text_IO;
   use UStrings;

   Bogstavfrekvenser : array (Character) of Long_Integer := (others => 0);

   Linje     : UString;
   Skiller   : Natural;
   Ord       : UString;
   Hyppighed : Long_Integer;
begin
   while not End_Of_File loop
      Get_Line (Linje);
      Skiller := Index (Linje, (1 => Ada.Characters.Latin_1.HT));

      if Skiller = 0 then
         Ord := Linje;
         Hyppighed := 1;
      else
         Ord := U (Slice (Linje, 1, Skiller - 1));
         Hyppighed := Long_Integer'Value (Slice (Linje, Skiller + 1, Length (Linje)));
      end if;

      for Indeks in 1 .. Length (Ord) loop
         declare
            Bogstav : Character renames Element (Ord, Indeks);
         begin
            Bogstavfrekvenser (Bogstav) := Bogstavfrekvenser (Bogstav) + Hyppighed;
         end;
      end loop;
   end loop;

   for Bogstav in Bogstavfrekvenser'Range loop
      if Bogstavfrekvenser (Bogstav) > 0 then
         Put (Item => Bogstav);
         Put (Item => Ada.Characters.Latin_1.HT);
         Put (Item => Bogstavfrekvenser (Bogstav));
         New_Line;
      end if;
   end loop;
end Ordfrekvenser_Til_Bogstavfrekvenser;

Jacob
-- 
"Those who will not reason, are bigots,
 those who cannot, are fools, and
 those who dare not, are slaves."



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:54 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *