Ada 95: Modifying output of dictionary program

后端 未结 3 1006
鱼传尺愫
鱼传尺愫 2021-01-13 15:25

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

相关标签:
3条回答
  • 2021-01-13 15:34

    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.

    0 讨论(0)
  • 2021-01-13 15:38

    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/

    0 讨论(0)
  • 2021-01-13 15:55

    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.

    0 讨论(0)
提交回复
热议问题