Ada 95: changing dictionary program output

I found this William Whitaker dictionary on the Internet and I like its parsing capabilities . But the exit is not suitable for me.

Problem (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 get the following text output (same input: audiam):

 audiam=audio, audire, audivi, auditus 

I.e:

 InputWord=Dictionary_Forms 

So, I do not need some pieces of information.

How to change the output of this program by changing the Ada code?

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

What needs to be changed in particular?

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

I hope some of you can understand the Ada 95 code. Thank you so much in advance!

My compilation issues:

For use on a Windows computer, I downloaded MinGW and tried to compile the source files using the "MinGW Shell". But this was my contribution and shell response:

MinGW Shell reponse

Compiling with the latest version of Cygwin:

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

enter image description here

There is even a .exe file that is created. Its size is 1.6 MB (1,682,616 bytes). But when I open it, it closes immediately. Something went wrong?

+4
source share
3 answers

William Whitaker Words is a handy tool. You can find the version already created for your platform. I have not changed the code, but you can change some things using various parameters. He even posted online . If you get the Ada compiler, I included the last Makefile that I used. It is a little subtle in abstraction, but includes the basic steps for compiling a program and utilities, as well as steps for creating 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) 

Addition: 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 name of my second favorite excerpt 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 SN 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 run it, the problem of changing it remains. A grep for Put_Line\( showing 629 hits; most of them are in line_stuff and list* . This is where I will start. When you study Ada, there are some good tutorials here .

+3
source

As much as I like Ada and will encourage you to find out the minimum amount that will be required to crack, the way you want ...

Indeed, you are asking for a simple data filtering that would be fairly easy to do by sending your output to awk . If you are using any flavor of Linux, you already have awk (and really need to learn how to use it). If you are on Windows, you can get awk and all sorts of other useful properties from MinGW , which is one of the places, d need to go to get the Ada compiler anyway.

If you need a Windows Ada compiler, I would suggest getting GNAT / GCC from there. Two other options available: GNAT / GPL and GNAT / PRO are available from AdaCore (maintainers). However, GNAT / PRO must be purchased, and the GNAT / GPL provides distributions of any program compiled using the GPL. You may not mind the GPL applied to your program, but I assume this is not a serious enough need for spring for commercial support.

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


Well, you asked about Ada training . Indeed, if you are familiar with other compiled procedural languages ​​(for example, C / C ++, Java, Pascal, Modula-2, etc.), you should not worry too much about choosing it. This question covers the books of Ada . For myself, I generally just use the official LRM as a link. Unlike most languages, Ada has an internationally standardized language reference guide that is available online for free. It is also quite readable as such things go.

+3
source

About compilation: you can use GNAT. It supports Ada83, Ada95 and Ada05. To say that to use Ada95, use the -gnat95 switch.

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

+1
source

Source: https://habr.com/ru/post/1383470/


All Articles