• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

generate/H10-Nov-2021-8475

src/H10-Nov-2021-912762

README.mdH A D10-Nov-20212.1 KiB7550

generate.gprH A D10-Nov-2021484 2212

stemmer_config.gprH A D10-Nov-20212.3 KiB8461

stemwords.gprH A D10-Nov-2021496 2212

README.md

1# Ada Target for Snowball
2
3The Ada Snowball generator generates an Ada child package for each Snowball algorithm.
4The parent package is named `Stemmer` and it provides various operations used by the generated code.
5The `Stemmer` package contains the Ada Snowball runtime available either in `ada/src` directory
6or from https://github.com/stcarrez/ada-stemmer.
7
8The generated child package declares the `Context_Type` tagged type and the `Stem` procedure:
9
10```Ada
11package Stemmer.<Algorithm-name> is
12   type Context_Type is new Stemmer.Context_Type with private;
13   procedure Stem (Z : in out Context_Type; Result : out Boolean);
14private
15   type Context_Type is new Stemmer.Context_Type with record
16      ...
17   end record;
18end Stemmer.<Algorithm-name>;
19```
20
21It is possible to use directly the generated operation or use it through the `Stemmer.Factory` package.
22
23## Usage
24
25To generate Ada source for a Snowball algorithm:
26```
27$ snowball path/to/algorithm.sbl -ada -P <algorithm-name> -o src/stemmer-<algorithm>
28```
29
30### Ada specific options
31
32`-P <Algorithm-name>` the child package name used in the generated Ada file (defaults to `snowball`).
33It must be a valid Ada identifier.
34
35## Code Organization
36
37`compiler/generator_ada.c` has the Ada code generation logic
38
39`ada/src` contains the default Ada Snowball runtime support which is also
40available at https://github.com/stcarrez/ada-stemmer
41
42`ada/algorithms` location where the makefile generated code will end up
43
44## Using the Generated Stemmers
45
46To use the generated stemmer, import the Ada generated package, declare an instance
47of the generated `Context_Type` and call the `Stem_Word` procedure.
48
49```
50with Stemmer.English;
51
52  Ctx : Stemmer.English.Context_Type;
53  Result : Boolean;
54
55  Ctx.Stem_Word ("zealously", Result);
56  if Result then
57     Ada.Text_IO.Put_Line (Ctx.Get_Result);
58  end if;
59```
60
61You can use the context as many times as you want.
62
63## Testing
64
65To run the tests, you will need an Ada compiler such as GNAT as well as the `gprbuild` build tool.
66
67Only the existing Snowball algorithms have been used for testing.  This does not exercise all features of the language.
68
69Run:
70
71```
72$ make check_ada
73```
74
75