我在互联网上找到了 William Whitaker 的这本词典,我喜欢其解析功能。但输出不适合我。
问题(对我来说是挑战):
给定一个输入形式,例如“audiam”,程序返回以下输出(纯文本):
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;
但我只想收到以下文本输出(相同的输入:audiam):
audiam=audio, audire, audivi, auditus
也就是说:
InputWord=Dictionary_Forms
所以有些信息对我来说是不必要的。
如何通过修改Ada代码来改变这个程序的输出?
我没有任何Ada知识,但我了解Delphi/Pascal,所以很容易理解代码,不是吗? ?所以导致文本输出的部分似乎是 TEXT_IO.PUT(...)
语句,对吗?它们都在 list_package.adb 中调用,因此这可能是要查看的源文件。
特别需要改变什么?
该程序的完整 Ada 95 源代码可在此页面获取。
我希望你们中的一些人能够理解 Ada 95 代码。预先非常感谢您!
我的编译问题:
为了在Windows机器上使用,我下载了MinGW并尝试使用“MinGW Shell”编译源文件。但这是我的输入和 shell 的响应:
使用最新的 Cygwin 版本进行编译:
当我使用最新版本的 Cygwin 编译程序时,没有错误消息:
甚至还有创建的 .exe 文件。其大小为 1.6 MB(1,682,616 字节)。但当我打开它时,它立即关闭。出了什么问题?
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:
Compiling with the latest Cygwin version:
When I compile the program using the latest version of Cygwin, there is no error message:
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?
发布评论
评论(3)
William Whitaker's Words 是一个方便的工具。您也许可以找到已为您的平台构建的版本。我没有更改代码,但您可以使用各种参数更改一些内容。它甚至在线托管。如果您有 Ada 编译器,我已经包含了我使用的最后一个
Makefile
。它的抽象有点薄弱,但它包括编译程序和实用程序的基本步骤,以及构建字典的步骤。附录:一种方法是在 Ubuntu 10.04 上使用 gcc 4.4.3 以及上面更新的
Makefile
。为了方便起见,我使用 VirtualBox 来托管 Linux 实例。这是一个使用我第二喜欢的段落标题的快速测试,来自 Catulli Carmina。
附录:一旦运行起来,修改它的问题仍然存在。
Put_Line\(
的grep
显示 629 个命中;大多数位于line_stuff
和list*
中。这就是我的位置当您开始学习 Ada 时,有一些很好的教程 此处。另请参阅whitakers-words,它说明了一些增强功能。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.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.Here's a quick test using the title of my second favorite passage from Catulli Carmina.
Addendum: Once you've got it running, the problem of modifying it remains. A
grep
forPut_Line\(
shows 629 hits; most are inline_stuff
andlist*
. That's where I'd start. As you are learning Ada, there are several good tutorials here. See also whitakers-words, which illustrates several enhancements.尽管我非常喜欢 Ada,并且会鼓励您学习按照您想要的方式破解它所需的最少知识...
实际上,您需要一个简单的数据过滤器,通过管道传输您的数据可以很容易地完成它输出到 awk。如果您在任何版本的 Linux 上运行,您已经拥有 awk(并且确实应该学习使用它)。如果您使用的是 Windows,您可以从 MinGW 获取 awk 和各种其他有用的东西,这是一个无论如何,您需要去的地方才能获得 Ada 编译器。
如果您确实想要 Windows Ada 编译器,我建议从那里获取 GNAT/GCC。其他两种可用的版本 GNAT/GPL 和 GNAT/PRO 可从 AdaCore(维护者)获得。但是,必须购买 GNAT/PRO,并且 GNAT/GPL 会呈现使用 GPL 编译的任何程序的发行版。我想你可能不介意将 GPL 应用于你的程序,但我猜这还不足以迫切需要商业支持。
如果您使用的是 Linux,GNAT Ada 编译器应该可以与 GCC 作为一个选项(如果默认情况下未安装)。当然,如果您愿意,也可以使用 AdaCore 中的其他两个选项。
好吧,您询问了学习 Ada。确实,如果您熟悉其他编译过程语言(例如:C/C++、Java、Pascal、Modula-2 等),那么您应该不会有太多的困难来掌握它。 此问题涵盖 Ada 书籍。对于我自己来说,我通常只使用 官方 LRM 作为一个参考。与大多数语言不同,Ada 拥有国际标准化的语言参考手册,可免费在线获取。就目前情况而言,它也非常具有可读性。
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.
关于编译:可以使用GNAT。它支持 Ada83、Ada95 和 Ada05。要告诉它使用 Ada95,请使用 -gnat95 开关。
您可以在 http://libre.adacore.com/ 上获取它
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/