Package: mguesser
Version: 0.2-5
Severity: wishlist
Tags: patch
X-Debbugs-Cc: [EMAIL PROTECTED]
The -p option is somewhat hard to use without root access, since you
need to add your generated language models to /usr/share/mguesser/ for
them to be of any use.
Attached please find a patch to implement a -d option which allows you
to specify multiple lm directories on the command line.
I'm afraid my m4d C 5|<1llz show through here -- please feel invited to
fix any unidiomatic or unobvious code.
As you can see I'm on Ubuntu, but the substance of the Ubuntu package
should be the same as the Debian version, apart from the fix for #353309
which I had to reinvent independently in order to get this to compile
:-)
-- System Information:
Debian Release: testing/unstable
APT prefers dapper-updates
APT policy: (500, 'dapper-updates'), (500, 'dapper-security'), (500,
'dapper-$Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.15-27-686
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8)
Versions of packages mguesser depends on:
ii libc6 2.3.6-0ubuntu20 GNU C Library: Shared
libraries an
mguesser recommends no packages.
-- no debconf information
/* era */
--
If this were a real .signature, it would suck less. Well, maybe not.
* Implement -d option to specify language map directories at run time
* Add a FILES section to the manual page
diff -rN -u old-mguesser/debian/mguesser.1 new-mguesser/debian/mguesser.1
--- old-mguesser/debian/mguesser.1 2006-11-26 14:30:48.000000000 +0200
+++ new-mguesser/debian/mguesser.1 2006-11-26 14:30:48.000000000 +0200
@@ -3,7 +3,7 @@
mguesser \- guess language
.SH SYNOPSIS
.B mguesser
-.RI "[-n maxhits] < FILENAME"
+.RI "[-n maxhits] [-d directory:directory...] < FILENAME"
.br
.B mguesser
.RI "-p -c charset -l language < FILENAME"
@@ -15,7 +15,7 @@
because the original program does not have a manual page.
.PP
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
-.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
+.\" \fI<whatever>\fP escape sequences to invoke bold face and italics,
.\" respectively.
\fBmguesser\fP is for guessing languages.
.SH OPTIONS
@@ -30,6 +30,13 @@
.B \-v
Be verbose.
.TP
+.B \-d directory[:directory...]
+Specify director(ies) to search for language maps in.
+This overrides the default directory
+.IR /usr/share/mguesser ;
+if you want to include that directory,
+you have to specify it.
+.TP
.B \-p
Print (for creating a new language map).
.TP
@@ -39,6 +46,15 @@
.B \-l language
Define language (for creating a new language map).
.br
+.SH BUGS
+The
+.B \-d
+option is a Debian-specific addition
+and is not present in the upstream sources.
+.SH FILES
+.TP
+.I /usr/share/mguesser/*.lm
+Language definition files
.SH AUTHOR
This manual page was written by Gürkan Sengün <[EMAIL PROTECTED]>,
for the Debian GNU/Linux system (but may be used by others).
diff -rN -u old-mguesser/guesser.c new-mguesser/guesser.c
--- old-mguesser/guesser.c 2006-11-26 14:30:48.000000000 +0200
+++ new-mguesser/guesser.c 2006-11-26 14:30:48.000000000 +0200
@@ -121,7 +121,7 @@
char name[1024]="";
int res=0;
- Env->LangMapList.nmaps=0;
+ /* Env->LangMapList.nmaps=0; */
dir=opendir(mapdir);
if(!dir)return 0;
@@ -382,10 +382,27 @@
void usage(){
printf("mguesser %s\n\n",MGUESSER_VERSION);
printf("To guess use:\n");
- printf("\tmguesser [-n maxhits] < FILENAME\n\n");
+ printf("\tmguesser [-n maxhits] [-d directory:directory:...] < FILENAME\n\n");
printf("To create new language map use:\n");
printf("\tmguesser -p -c charset -l language < FILENAME\n");
-}
+}
+
+char ** get_directories(char * optarg){
+ int i;
+ char * p;
+ char ** directories;
+
+ /* XXX TODO: fix ugliness */
+ directories=malloc(strlen(optarg)*sizeof(char **)/sizeof(char));
+ directories[0]=optarg;
+ for(i=1;(p=strchr(optarg,(int)':'));++i,optarg=p+1){
+ *p='\0';
+ directories[i]=p+1;
+ }
+ realloc(directories,(i+2)*sizeof(char **));
+ directories[i+1]=(char *)NULL;
+ return directories;
+}
int main(int argc,char ** argv){
int ch;
@@ -393,12 +410,14 @@
int print=0;
int n=1000;
char buf[1024]="";
+ char ** directories = (char **) NULL;
+ int d=0;
UDM_ENV env;
UDM_LANGMAP mchar;
char * charset=NULL;
char * lang=NULL;
- while((ch=getopt(argc,argv,"pv?c:l:n:"))!=-1){
+ while((ch=getopt(argc,argv,"pv?c:l:n:d:"))!=-1){
switch(ch){
case 'n':
n=atoi(optarg);
@@ -415,6 +434,9 @@
case 'v':
verbose++;
break;
+ case 'd':
+ directories = get_directories(optarg);
+ break;
case '?':
default:
usage();
@@ -428,15 +450,24 @@
memset(&env,0,sizeof(env));
memset(&mchar,0,sizeof(mchar));
+ if (!directories){
+ directories=malloc(2*sizeof(char **));
+ directories[0]=LMDIR;
+ directories[1]=(char *) NULL;
+ }
+
if(!print){
- /* Load all available lang ngram maps */
- if(verbose){
- fprintf(stderr,"Loading language maps from '%s'\n",LMDIR);
- }
- UdmLoadLangMapList(&env,LMDIR);
- if(env.errcode){
- printf("Error: '%s'\n",env.errstr);
- return 1;
+ env.LangMapList.nmaps=0;
+ for(d=0;directories[d];++d){
+ /* Load all available lang ngram maps */
+ if(verbose){
+ fprintf(stderr,"Loading language maps from '%s'\n",directories[d]);
+ }
+ UdmLoadLangMapList(&env,directories[d]);
+ if(env.errcode){
+ printf("Error: '%s'\n",env.errstr);
+ return 1;
+ }
}
if(verbose){