LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   General (https://www.linuxquestions.org/questions/general-10/)
-   -   How do I create words.db from words.txt using gdbm? (https://www.linuxquestions.org/questions/general-10/how-do-i-create-words-db-from-words-txt-using-gdbm-690474/)

kline 12-14-2008 04:44 AM

How do I create words.db from words.txt using gdbm?
 
Hi Guys,

I'm working on updating and fixing a broken Makefile to create the rhyming dictionary. [[Originally pub domain from CMU]] Thru surfing all over I finally found the three missing *.txt files. The makefile doesn't give the instructions on howto create the three database files. It dies instantly when it can't find the first one.

I'm using the source rather than a pre-built binary for two reasons.
One, I'm a wool-died hacker; two, I want to port this to the Berkeley Unix distros. Some lexicographer put in a lot of effort in getting this (command-line) tool updated. I'd like to finish the build work.

Sorry for posting here; wasn't sure exactly *where*... .

CroMagnon 12-14-2008 05:28 AM

What sources are you using? I'm looking at the one in the Debian repo, and the db files are created by makedb. The source for this is included with the rhyme package, and is compiled and run by the makefile. The makefile is not broken, except for 'make test'. The db files are created from cmudict*, not the text files mentioned in the makefile.

kline 12-14-2008 02:21 PM

Quote:

Originally Posted by CroMagnon (Post 3374980)
What sources are you using? I'm looking at the one in the Debian repo, and the db files are created by makedb. The source for this is included with the rhyme package, and is compiled and run by the makefile. The makefile is not broken, except for 'make test'. The db files are created from cmudict*, not the text files mentioned in the makefile.

I'm using the file

880 -rw-r--r-- 1 kline 896013 2008-12-14 11:44 rhyme-0.9.tar.gz

that seems to be identical with the .zip file. Good to know that the cmudict stuff is used; unless there is an ``official'' Debian tarball, I'll untar this and give it a go.

Is makedb part of Ubuntu or do i need to fetch is? locate doesn't see it. I'll fess up further to not have done any programming on my Ubuntu desktop. (I did try "gcc x.c" when I was running the last LTS release and got some err output. Returned to my FreeBSD box.)

Be nice if this tarball just-worked, but then, you know how it goes, :-)

CroMagnon 12-14-2008 02:32 PM

makedb is part of rhyme - you should see makedb.c and makedb.h in the tarball. This is from the tarball obtained by "apt-get source rhyme".

kline 12-14-2008 03:12 PM

Quote:

Originally Posted by CroMagnon (Post 3375367)
makedb is part of rhyme - you should see makedb.c and makedb.h in the tarball. This is from the tarball obtained by "apt-get source rhyme".


Yeo, apt-get got the source, untarred, etc. But same or similar gotchas as before. This time I understand more. gcc can't see my #include headers. Probably more.

So, if this is too far OT, please let me know. Time to learn how to build stuff with gcc and g++. At a min. Hopefully, it is push-button.

If not, I'll put up a new post.

thanks much.

CroMagnon 12-14-2008 03:22 PM

What errors do you get? Do you have the gdbm dev library package installed?

kline 12-14-2008 04:39 PM

Quote:

Originally Posted by CroMagnon (Post 3375411)
What errors do you get? Do you have the gdbm dev library package installed?

I was minus the libgdbm-dev stuff; once installed, make worked to a point. I will paste the errs in and hope they cp as I see them:




main.c:5:22: error: readline.h: No such file or directory
main.c:6:21: error: history.h: No such file or directory
main.c: In function \xe2\x80\x98getWord\xe2\x80\x99:
main.c:15: warning: implicit declaration of function \xe2\x80\x98readline\xe2\x80\x99
main.c:15: warning: return makes pointer from integer without a cast
main.c:17: warning: return makes pointer from integer without a cast
main.c:19: warning: return makes pointer from integer without a cast
main.c: In function \xe2\x80\x98main\xe2\x80\x99:
main.c:36: warning: implicit declaration of function \xe2\x80\x98using_history\xe2\x80\x99
main.c:37: warning: implicit declaration of function \xe2\x80\x98rl_bind_key\xe2\x80\x99
main.c:37: error: \xe2\x80\x98rl_insert\xe2\x80\x99 undeclared (first use in this function)
main.c:37: error: (Each undeclared identifier is reported only once
main.c:37: error: for each function it appears in.)
main.c:54: warning: implicit declaration of function \xe2\x80\x98add_history\xe2\x80\x99
main.c:63: warning: implicit declaration of function \xe2\x80\x98clear_history\xe2\x80\x99
make: *** [rhyme] Error 1


Yep. Okay the hex triplets are the html "``" and "''"; I'm almost positive. This is fairly easy to resolve with tr or perl, &c.

Another thing is that the headers are just not seen. Note the first two lines. I also tried a dummy x.c with
#include <stdio.h>
main{
}

and

main()
{
putchar('\n');
}

gcc complained about not finding stdio.h in my first try. The second time, x.c compiled to a.out perfectly and printed a newline. Is is cpp that finds the header files? Or the linker?

CroMagnon 12-14-2008 04:59 PM

cpp finds the header files, as they are compiled like all other source code.

The failure with headers is interesting, but do you actually have readline.h? (readline dev libraries)

kline 12-14-2008 08:48 PM

Quote:

Originally Posted by CroMagnon (Post 3375497)
cpp finds the header files, as they are compiled like all other source code.

The failure with headers is interesting, but do you actually have readline.h? (readline dev libraries)

I only thought I did! And that sent me on yet other quests; I had no /usr/include/stdio.h either ... until some ~30 minutes ago. I just installed the entire g*-3.4 suite. Now everything works. Until your question, I'd assumed that Every 'Nix came with cc/gcc and header files installed. live and learn... .

thanks for your help!


All times are GMT -5. The time now is 04:03 AM.