diff --git a/app/conf/dgc.conf b/app/conf/dgc.conf index d8ec53e..11a3bcf 100644 --- a/app/conf/dgc.conf +++ b/app/conf/dgc.conf @@ -12,3 +12,4 @@ # categories = PATH_PREFIX/share/utt/cats.dgc grammar = PATH_PREFIX/share/utt/gram.dgc +outputfile = PATH_PREFIX/share/utt/gram.dgp diff --git a/app/conf/dgp.conf b/app/conf/dgp.conf new file mode 100644 index 0000000..938affa --- /dev/null +++ b/app/conf/dgp.conf @@ -0,0 +1,18 @@ +# ************************************************************ +# * This file was created automatically during installation. * +# * If you don't need do not change it. * +# * * +# * UAM Text Tools * +# * Adam Mickiewicz University, Poland * +# * http://utt.amu.edu.pl * +# ************************************************************ +# +# All lines must looks like: +# parameter_name [=] value +# + +grammar = PATH_PREFIX/share/utt/gram.dgp +process = W +process = BOS +process = EOS +info = d diff --git a/app/conf/gph.conf b/app/conf/gph.conf new file mode 100644 index 0000000..796c7c7 --- /dev/null +++ b/app/conf/gph.conf @@ -0,0 +1,16 @@ +# ************************************************************ +# * This file was created automatically during installation. * +# * If you don't need do not change it. * +# * * +# * UAM Text Tools * +# * Adam Mickiewicz University, Poland * +# * http://utt.amu.edu.pl * +# ************************************************************ +# +# All lines must looks like: +# parameter_name [=] value +# +process = W +process = BOS +process = EOS +reset = BOS diff --git a/app/src/dgp/cmdline_dgp.ggo b/app/src/dgp/cmdline_dgp.ggo index 3d99432..c59786d 100644 --- a/app/src/dgp/cmdline_dgp.ggo +++ b/app/src/dgp/cmdline_dgp.ggo @@ -2,7 +2,7 @@ package "dgp" version "0.1" option "grammar" g "Grammar file" - string typestr="filename" default="dgp.dgp" + string no typestr="filename" option "long" l "Long output" flag off diff --git a/app/src/dgp/dgc b/app/src/dgp/dgc index daf873a..ab32035 100755 --- a/app/src/dgp/dgc +++ b/app/src/dgp/dgc @@ -37,13 +37,13 @@ foreach $file ($systemconfigfile, $userconfigfile){ s/\s+$//; next unless length; my ($name, $value) = split(/\s*=\s*/, $_, 2); - if(($name eq "catfile")or($name eq "c")){ + if(($name eq "categories")or($name eq "c")){ $catfile=$value; } - elsif(($name eq "dicfile")or($name eq "d")){ + elsif(($name eq "dictionary")or($name eq "d")){ $dicfile=$value; } - elsif(($name eq "gramfile")or($name eq "g")){ + elsif(($name eq "grammar")or($name eq "g")){ $gramfile=$value; } elsif(($name eq "outputfile")or($name eq "o")){ @@ -60,21 +60,28 @@ foreach $file ($systemconfigfile, $userconfigfile){ ######################################################### GetOptions("help|h" => \$help, - "catfile|c=s" => \$catfile, - "dicfile|d=s" => \$dicfile, - "gramfile|g=s" => \$gramfile, + "categories|c=s" => \$catfile, + "dictionary|d=s" => \$dicfile, + "grammar|g=s" => \$gramfile, "outputfile|o=s" => \$outputfile); +my $homedir = $ENV{'HOME'}; +$catfile =~ s/~/$homedir/; +$dicfile =~ s/~/$homedir/; +$gramfile =~ s/~/$homedir/; +$outputfile =~ s/~/$homedir/; + + if($help) { print <<'END' Usage: dgc [OPTIONS] Options: - --catfile -c filename List of syntactic categories. - --dicfile -d filename Dictionary. - --gramfile -g filename List of grammar rules. - --outputfile -o filename Output filename. + --categories -c filename List of syntactic categories. + --dictionary -d filename Dictionary. + --grammar -g filename List of grammar rules. + --outputfile -o filename Output file name. --help -h Help. END ; diff --git a/app/src/dgp/grammar.hh b/app/src/dgp/grammar.hh index d2286b8..75d6807 100644 --- a/app/src/dgp/grammar.hh +++ b/app/src/dgp/grammar.hh @@ -17,7 +17,7 @@ class Grammar // enum CONSTR { SGL, OBL, LEFT, RIGHT, INIT, NONINIT, FIN, NONFIN }; - Grammar() : types_sz(0), cats_sz(0) { } ; + Grammar() : types_sz(0), cats_sz(0) {} ; int types_sz; int cats_sz; diff --git a/app/src/dgp/main.cc b/app/src/dgp/main.cc index 8cc7e07..b29171e 100644 --- a/app/src/dgp/main.cc +++ b/app/src/dgp/main.cc @@ -19,6 +19,8 @@ char segment[MAXSEGMENTS][MAXLINE]; int segcount=0; char seg_mnode[MAXSEGMENTS]; +char grammarfile[255]; + Grammar grammar; MGraph mgraph; @@ -40,18 +42,13 @@ main(int argc, char* argv[]) process_config_files(&args,argv[0]); process_common_options(&args,argv[0]); -// if(args.help_given) cmdline_parser_print_help (); + if(!args.grammar_given) + fprintf(stderr,"dgp: no grammar given\n"); -// if(args.input_given) -// if(!(inputf=fopen(args.input_arg,"r"))) -// fprintf(stderr,"dgp: input file not found: %s.\n", args.input_arg), exit(1); + expand_path(args.grammar_arg,grammarfile); -// if(args.output_given) -// if(!(outputf=fopen(args.output_arg,"w"))) -// fprintf(stderr,"dgp: cannot open output file: %s.\n", args.output_arg), exit(1); - - if(!(grammarf=fopen(args.grammar_arg,"r"))) - fprintf(stderr,"dgp: grammar file not found: %s.\n", args.grammar_arg), exit(1); + if(!(grammarf=fopen(grammarfile,"r"))) + fprintf(stderr,"dgp: grammar file not found: %s.\n", grammarfile), exit(1); if(args.debug_given) debug=true; diff --git a/app/src/dgp/mgraph.cc b/app/src/dgp/mgraph.cc index 9f314bd..adc9d41 100644 --- a/app/src/dgp/mgraph.cc +++ b/app/src/dgp/mgraph.cc @@ -22,8 +22,11 @@ int MGraph::add_node(char* seg) while(*cat!=',' && *cat ) ++cat; if(*cat) ++cat; - Cat::add(cat); - nodes[n].cat=cat; +// Cat::add(cat); + if(Cat::index(cat)>0) + nodes[n].cat=cat; + else + nodes[n].cat="NULL"; nodes[n].pred.clear(); diff --git a/app/src/gph/gph b/app/src/gph/gph index 64c2e4f..3f739c8 100755 --- a/app/src/gph/gph +++ b/app/src/gph/gph @@ -79,11 +79,11 @@ if($help) Usage: gph [OPTIONS] Options: - -p tag Process segments with this tag as nodes. - -r tag Start new graph at this tag. - -f filename Input file. - -o filename Output file. - -i Toggle interactive mode (default=off). + --process=TYPE -p TYPE Process segments of type TYPE. + --reset=TYPE -r TYPE Start new graph at tags of type TYPE. + --inputfile=FILE -f FILE Input file. + --outputfile=FILE -o FILE Output file. + --interactive -i Toggle interactive mode (default=off). END ; exit 0;