4

I've found this dictionary by William Whitaker on the Internet and I like its parsing capabilities. But the output doesn't fit for me.

The issue (challenge for me):

Given an input form such as "audiam", the program returns the following output (plain text):

audi.am              V      4 1 PRES ACTIVE  SUB 1 S    
audi.am              V      4 1 FUT  ACTIVE  IND 1 S    
audio, audire, audivi, auditus  V (4th)   [XXXAO]  
hear, listen, accept, agree with; obey; harken, pay attention; be able to hear;

But I just want to receive the following text output (same input: audiam):

audiam=audio, audire, audivi, auditus

That is:

InputWord=Dictionary_Forms

So some pieces of information are needless for me.

How can I change the output of this program by modifying the Ada code?

I don't have any Ada knowledge, but I know Delphi/Pascal so it's quite easy to understand the code, isn't it? So the parts causing the text output seem to be the TEXT_IO.PUT(...) statements, right? They're all called in list_package.adb so this is probably the source file to look at.

What has to be changed in particular?

The full Ada 95 source code of this program is available on this page.

I hope some of you are able to understand Ada 95 code. Thank you very much in advance!

My compiling problems:

For use on a windows machine, I downloaded MinGW and tried to compile the source files using "MinGW Shell". But this was my input and the shell's reponse:

MinGW Shell reponse

Compiling with the latest Cygwin version:

When I compile the program using the latest version of Cygwin, there is no error message:

enter image description here

There is even an .exe file which is created. Its size is 1.6 MB (1,682,616 bytes). But when I open it, it closes right away. What has gone wrong?

AstroCB
  • 12,337
  • 20
  • 57
  • 73
caw
  • 30,999
  • 61
  • 181
  • 291
  • Should we assume the output is text ? is postprocessing the text not an option ? – NWS Apr 20 '11 at 08:48
  • I agree with @NWS, unless you're interested in learning Ada (and yes, a number of us here are able to understand Ada 95) I would just filter the output through some shell/Python/Perl/awk/whatever script. – Marc C Apr 20 '11 at 12:06
  • Thanks for these two comments :) Yes, the output is (plain) text. I added this information in the question above. And just filtering the output by some script (best: PHP) would be ok as well. But the better solution would - of course - be the modification of the Ada program. – caw Apr 20 '11 at 13:09
  • Filtering afterwards is quite a complex task as the output can have lots of different forms. So modifying the Ada code in advance to get the right output is by far more easy. And since I have average Delphi/Pascal knowledge, the Ada code is easy to understand. – caw Apr 22 '11 at 23:28
  • For reference, you can right-click on the shell window's title bar to mark text for copying. It's a little easier to redact that way. – trashgod Apr 25 '11 at 01:09

3 Answers3

3

As much as I like Ada and would encourage you to learn the minimal amount it would require to hack it the way you want...

Really, you are asking for a simple data filter, which it would be quite easy to accomplish by piping your output to awk. If you are running on any flavor of Linux you have awk already (and really should learn to use it). If you are on Windows, you can get awk and all sorts of other useful goodies from MinGW, which is one of the places you'd need to go to get an Ada compiler anyway.

If you do want a Windows Ada compiler, I'd suggest getting GNAT/GCC from there. The two other flavors available, GNAT/GPL and GNAT/PRO are available from AdaCore (the maintainers). However, GNAT/PRO must be purchased and GNAT/GPL renders distributions of any program compiled using it GPL. You might not mind the GPL applying to your program I suppose, but I'm guessing this isn't a serious enough need to spring for commercial support.

If you are on Linux, the GNAT Ada compiler should be available with GCC as an option (if not installed by default). The same two other options from AdaCore are available there too of course, if you like.


Well, you asked about learning Ada. Really, if you are familiar with other compiled procedural languages (eg: C/C++, Java, Pascal, Modula-2, etc.) you shouldn't have too much trouble picking it up. This question covers Ada books. For myself, I generally just use the official LRM as a reference. Unlike most languages, Ada has an internationally standardized Language Reference Manual that is available online for free. It is also quite readable, as such things go.

Community
  • 1
  • 1
T.E.D.
  • 44,016
  • 10
  • 73
  • 134
  • "GNAT/GPL renders any program compiled using it GPL" - this statement is false. you only have to respect this if you distribute it in binary form. – Rommudoh Apr 20 '11 at 14:30
  • 2
    @oenone - Well, its a matter of how you look at it. The GPL only puts burdens on you when you try to distribute a program. I'll try to make it clearer. – T.E.D. Apr 20 '11 at 15:22
  • IIUC, versions compiled from the [FSF](http://gcc.gnu.org/) retain the [GMGPL](http://en.wikipedia.org/wiki/GNAT_Modified_General_Public_License) exception. – trashgod Apr 20 '11 at 23:50
  • +1 for post-processing. I really like the program, but the interface is idiosyncratic. – trashgod Apr 20 '11 at 23:51
  • @trashgod - That's basically what I'm calling "GNAT/GCC" (Is "GNAT/FSF" a better name?) On Windows, you can get binaries from the MinGW folks. – T.E.D. Apr 21 '11 at 13:08
  • D'oh, I completely forgot about MinGW; thanks for the reminder! I'm not sure about the best naming; `gcc --version` shows the FSF copyright, which is where I picked up the habit. – trashgod Apr 21 '11 at 14:18
  • Thank you for this detailed information about Ada compilers :) I chose "MinGW" for use on my windows machine. But there are some problems while compiling. It would be great if you could have a second look at my question. – caw Apr 22 '11 at 23:32
  • So I definitely want to learn that "minimal amout" of Ada in order to modify this program. Post-processing is not the option I would like to choose. I don't care whether the compiled program has to be distributed under the GPL or not. So GNAT/GPL would be ok for me as well. – caw Apr 24 '11 at 18:14
  • Thanks for the edit so that I have interesting links for learning Ada now. – caw Apr 26 '11 at 09:21
  • @Marco W. - I'd also suggest trying out some of the links in SO's Ada tag ( http://stackoverflow.com/tags/ada/info ). There's lots of good stuff in there. – T.E.D. Apr 27 '11 at 12:50
3

William Whitaker's Words is a handy tool. You may be able to find a version already built for your platform. I've not changed the code, but you can alter some things using various parameters. It's even hosted online. If you get an Ada compiler, I've included the last Makefile I used. It's a little thin on abstraction, but it includes the essential steps to compile the program and utilities, along with the steps to build the dictionaries.

TARG = words
ARGS = -O

$(TARG): *.ad[bs]
    gnatmake $(TARG) $(ARGS)

all: $(TARG)
    gnatmake makedict $(ARGS)
    gnatmake makeinfl $(ARGS)
    gnatmake makestem $(ARGS)
    gnatmake makeefil $(ARGS)
    @echo Please make the dicitionary
    @echo ./makedict DICTLINE.GEN
    @echo ./makestem STEMLIST.GEN
    @echo ./makeefil EWDSLIST.GEN
    @echo ./makeinfl INFLECTS.GEN

debug:
    gnatmake -g $(TARG)

clean:
    rm -f *.o *.ali b~* core

cleaner: clean
    rm -f *.s makedict makeinfl makestem makeefil

cleanest: cleaner
    rm -f $(TARG)

Addendum: One approach is to use gcc 4.4.3 on Ubuntu 10.04 with the updated Makefile above. For convenience, I used VirtualBox to host the linux instance.

$ gcc --version
gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Here's a quick test using the title of my second favorite passage from Catulli Carmina.

$ ./words odi et amo
odi                  V      6 1 PRES ACTIVE  IMP 2 S    
odeo, odire, odivi(ii), -  V TRANS   [EXXCW]    Later
od.i                 V      4 1 PRES ACTIVE  IMP 2 S    
odio, odire, odivi, -  V (4th) TRANS   [FXXCF]    Medieval
hate; dislike; be disinclined/reluctant/adverse to; (usu. PREFDEF);
odi                  N      2 4 GEN S N                   Early   
odium, odi(i)  N (2nd) N   [XXXAO]  
hate/hatred/dislike/antipathy; odium, unpopularity; boredom/impatience;
hatred (manifested by/towards group), hostility; object of hate/odium;
od.i                 V      3 1 PERF ACTIVE  IND 1 S    
odi, odisse, osus  V (3rd) PERFDEF   [XXXBX]  
hate (PERF form, PRES force), dislike; be disinclined/reluctant/adverse to;

et                   CONJ                               
et  CONJ   [XXXAX]  
and, and even; also, even;  (et ... et = both ... and);

am.o                 V      1 1 PRES ACTIVE  IND 1 S    
amo, amare, amavi, amatus  V (1st)   [XXXAO]  
love, like; fall in love with; be fond of; have a tendency to;

Addendum: Once you've got it running, the problem of modifying it remains. A grep for Put_Line\( shows 629 hits; most are in line_stuff and list*. That's where I'd start. As you are learning Ada, there are several good tutorials here.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • Thanks for this answer :) The four links you mentioned first are interesting, but I know them all, of course ;) I've tried that already. There is no "official" version which does what I need. But could you help me compiling it? That would be great. As you can see in my question, there are some difficulties for me. – caw Apr 22 '11 at 23:35
  • I get the same result with MinGW gcc 4.5.2, but not Mac OS gcc 4.3.4. Using the compiler option `-gnatl` shows that it finishes compiling, but `-S` dies after writing a single line of assembler source. I'm nonplussed. – trashgod Apr 23 '11 at 04:29
  • I don't know if you got me right: I want to compile this program for use on Windows with the output changed to the format I described. A version running on UNIX would be even better, but this isn't necessary. A version like this would be OK: http://users.erols.com/whitaker/wordswin.htm – caw Apr 23 '11 at 22:04
  • 1
    The same source compiles on Mac OS (gcc 4.3.4) and Ubuntu (gcc 4.4.3), shown above. AFAIK, the failure with MinGW (gcc 4.5.2) is a compiler bug; I don't know of a work around. Did you try [Cygwin](http://www.cygwin.com/)? – trashgod Apr 23 '11 at 22:30
  • 1
    Good news! It builds and runs fine with [Cygwin gcc 3.4.4](http://cygwin.com/packages/gcc-ada). – trashgod Apr 24 '11 at 05:45
  • Thank you very much for supporting me and testing cygwin. Where can I get it? On that page which you linked to there is no download link. Just text information about the releases. – caw Apr 24 '11 at 18:15
  • I've now downloaded Cygwin from . The results of my compilation attempt are described in my question above. It still doesn't work correctly, but I got one step further :) – caw Apr 24 '11 at 18:46
  • 1
    Now do `make all` to get the four dictionary utilities and a list of the four commands required to build the dictionaries. More [here](http://users.erols.com/whitaker/wordsdev.htm). – trashgod Apr 24 '11 at 21:03
  • Thank you very much, trashgod! Everything works now :) The only problem left is that I don't know which passages to modify. – caw Apr 25 '11 at 15:26
  • Nor do I, but I've elaborated above. – trashgod Apr 25 '11 at 17:21
  • Your answer is obviously the best one. Thank you very much! – caw Apr 26 '11 at 09:21
  • You are very welcome. I've long enjoyed the Algol-PL/1-Pascal-Modula-Ada family of languages, and the participants here are always helpful as new questions arise. You may also like [comp.lang.ada](https://groups.google.com/forum/#!forum/comp.lang.ada). – trashgod Apr 26 '11 at 12:05
1

About compiling: you can use GNAT. It supports Ada83, Ada95, and Ada05. To tell it to use Ada95, use the -gnat95 switch.

You can get it on http://libre.adacore.com/

Rommudoh
  • 1,844
  • 10
  • 11
  • Also, gnatmake is freely available on linux type platforms. – NWS Apr 20 '11 at 09:41
  • 1
    Isn't gnat a standard part of the gcc install now? I know I get it with Mingw. – T.E.D. Apr 20 '11 at 12:56
  • gnatmake is part of gnat. I wouldnt call it part of standard gcc install, since it mostly comes as own package. There are differences between gcc-gnat and gnat gpl, you might want to look at them. – Rommudoh Apr 20 '11 at 14:29
  • Yup, although I believe mostly in the tools department. For example, `addr2line.lib` only exists as part of gnat gpl, so you can't (easily) do symbolic tracebacks from inside a running program with gnat gcc. – T.E.D. Apr 20 '11 at 15:27