1) dgp nie wysypuje sie na nieznanych kategoriach

2) dodane i uzupelnione konfigi



git-svn-id: svn://atos.wmid.amu.edu.pl/utt@49 e293616e-ec6a-49c2-aa92-f4a8b91c5d16
This commit is contained in:
obrebski 2008-05-09 08:38:46 +00:00
parent 9b57c4d68c
commit 3748bd1db4
9 changed files with 71 additions and 29 deletions

View File

@ -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

18
app/conf/dgp.conf Normal file
View File

@ -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

16
app/conf/gph.conf Normal file
View File

@ -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

View File

@ -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

View File

@ -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
;

View File

@ -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;

View File

@ -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;

View File

@ -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();

View File

@ -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;