Changeset a15e59b for src


Ignore:
Timestamp:
03/13/12 17:07:34 (12 years ago)
Author:
Tomasz Obrebski <to@…>
Branches:
master
Children:
f4bf33e
Parents:
abd28d1
git-author:
Tomasz Obrebski <to@…> (03/13/12 17:07:34)
git-committer:
Tomasz Obrebski <to@…> (03/13/12 17:07:34)
Message:

dodana opcja --time w dgp, poprawione przesy�anie b�belk�w, obsluga &LEFT, &RIGHT

Location:
src/dgp
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/dgp/cmdline_dgp.ggo

    r5f4d9c3 ra15e59b  
    1111                                flag off 
    1212 
     13option  "time"          -       "Print parse time." 
     14                                flag off 
     15 
    1316option  "info"          -       "Print info.  
    14 h - heads         d - dependents 
    15 s - sets 
    16 c - constraints   n - node/arc counts   t - parse time 
    17 " 
     17                                       h - heads         d - dependents 
     18                                       s - sets 
     19                                       c - constraints    n - node/arc counts" 
    1820string no default="h" 
  • src/dgp/dgp1.cc

    re7de6cc ra15e59b  
    303303//==================================================================================================== 
    304304 
    305 bool check_boubbles_at_target(list<Boubble*> boubbles, int node) 
    306 { 
    307   for(list<Boubble*>::iterator b = boubbles.begin(); b != boubbles.end(); b++) 
    308     if( (*b)->is_at_target() && !grammar.check_longrel(sgraph.cat((*b)->src()), sgraph.cat(node), (*b)->rel())) 
    309       return false; 
     305// sprawdza czy te, spo¶ród b±bli, które dotar³y do celu node 
     306// daj± wynik prawdziwy, dodatkowo - usuwa je z listy boubbles 
     307 
     308bool check_boubbles_at_target(list<Boubble*>& boubbles, int node) 
     309{ 
     310  list<Boubble*>::iterator last; // ostatnio sprawdzany b±bel 
     311  bool remove=false;             // czy usun±æ ostatnio sprawdzany b±bel 
     312 
     313  for(list<Boubble*>::iterator b = boubbles.begin(); b != boubbles.end(); b = remove ? boubbles.erase(b) : ++b ) 
     314    if( (*b)->is_at_target() ) 
     315      if( grammar.check_longrel(sgraph.cat((*b)->src()), sgraph.cat(node), (*b)->rel()) ) 
     316        remove=true; 
     317      else 
     318        return false; 
     319    else 
     320      remove=false; 
     321       
    310322  return true; 
    311323} 
     324 
     325// bool check_boubbles_at_target(list<Boubble*> boubbles, int node) 
     326// { 
     327//   for(list<Boubble*>::iterator b = boubbles.begin(); b != boubbles.end(); ++b ) 
     328//     if( (*b)->is_at_target() && !grammar.check_longrel(sgraph.cat((*b)->src()), sgraph.cat(node), (*b)->rel()) ) 
     329//       return false; 
     330//   return true; 
     331// } 
    312332 
    313333//==================================================================================================== 
  • src/dgp/grammar.cc

    re7de6cc ra15e59b  
    187187  Prop::add("INIT"); 
    188188  Prop::add("FIN"); 
     189  Prop::add("LEFT"); 
     190  Prop::add("RIGHT"); 
    189191 
    190192  //<<< TU? 
  • src/dgp/grammar.hh

    re7de6cc ra15e59b  
    192192//---------------------------------------------------------------------------------------------------- 
    193193 
    194 inline 
    195 bool Grammar::check_constr(NodeProp& hprop, NodeProp& dprop, int dir, Role role)    // dir: 0-left 1-right 
    196 { 
    197   return  
    198     !hprop.forbidden[role] && 
    199     ( dir==1 || !right[role] ) && 
    200     ( dir==0 || !left[role]  ) && 
    201     ( dir==1 || (hprop.attached&init).none() ) && 
    202     ( dir==0 || (hprop.attached&fin).none() ) 
    203     ; 
    204 } 
     194// inline 
     195// bool Grammar::check_constr(NodeProp& hprop, NodeProp& dprop, int dir, Role role)    // dir: 0-left 1-right 
     196// { 
     197//   return  
     198//     !hprop.forbidden[role] && 
     199//     ( dir==1 || !right[role] ) && 
     200//     ( dir==0 || !left[role]  ) && 
     201//     ( dir==1 || (hprop.attached&init).none() ) && 
     202//     ( dir==0 || (hprop.attached&fin).none() ) 
     203//     ; 
     204// } 
    205205 
    206206//---------------------------------------------------------------------------------------------------- 
     
    211211  return  
    212212    !hprop.forbidden[link.role] && 
    213     ( dir==1 || !right[link.role] ) && 
    214     ( dir==0 || !left[link.role] ) && 
     213    ( dir==1 || (!right[link.role] && !link.props[Prop("RIGHT")]) ) &&  // ZREZYGNOWAÆ Z TABLICY right[<role>] 
     214    ( dir==0 || (!left[link.role] && !link.props[Prop("LEFT")]) ) && 
    215215    ( dir!=0 || !hprop.init_attached ) && 
    216216    ( dir!=1 || !hprop.fin_attached ) 
  • src/dgp/main.cc

    re7de6cc ra15e59b  
    66 * Author:      Tomasz Obrebski 
    77 */ 
     8 
     9#include <ctime> 
     10#include <sys/time.h> 
    811 
    912#include "global.hh" 
     
    1619 
    1720#define MAXSEGMENTS 500 
     21 
     22#define MICROSECONDSELAPSED(A,B) ((B.tv_sec - A.tv_sec)*1000000 + (B.tv_usec - A.tv_usec)) 
    1823 
    1924char segment[MAXSEGMENTS][MAXLINE]; 
     
    3035FILE* debugf=stdout; 
    3136unsigned int info=0U; 
     37 
     38bool printtimeinfo=false; 
    3239 
    3340void output(); 
     
    5360  if(args.debug_given) debug=true; 
    5461 
     62  if(args.time_given) printtimeinfo=true; 
     63 
    5564  for(char* c=args.info_arg; *c!='\0' ; ++c) 
    5665    switch(*c) 
     
    7079  // exit(0); 
    7180 
    72  
     81  struct timeval starttime,afterinput,afterparse,endtime; 
    7382 
    7483  mgraph.clear(); 
     
    7887  while (fgets(line, MAXLINE+1, inputf)) 
    7988  { 
     89    gettimeofday(&starttime,NULL); 
    8090    line[strlen(line)-1] = '\0'; 
    8191    strcpy(segment[segcount],line); 
     
    90100    if(strcmp(segtype,"EOS")==0) 
    91101    { 
     102      gettimeofday(&afterinput,NULL); 
    92103      dgp1(); // parametry!!! MGraph, SGraph, Grammar 
     104      gettimeofday(&afterparse,NULL); 
    93105      output(); 
     106      gettimeofday(&endtime,NULL); 
     107 
     108      if(printtimeinfo) 
     109        { 
     110          fprintf(stderr,"### INPUT  TIME: %10.2fms\n", (float)MICROSECONDSELAPSED(starttime,afterinput)/1000 ); 
     111          fprintf(stderr,"### PARSE  TIME: %10.2fms\n", (float)MICROSECONDSELAPSED(afterinput,afterparse)/1000 ); 
     112          fprintf(stderr,"### OUTPUT TIME: %10.2fms\n", (float)MICROSECONDSELAPSED(afterparse,endtime)/1000 ); 
     113          fprintf(stderr,"### TOTAL  TIME: %10.2fms\n", (float)MICROSECONDSELAPSED(starttime,endtime)/1000 ); 
     114        } 
    94115       
    95116      mgraph.clear(); 
  • src/dgp/sgraph.cc

    re7de6cc ra15e59b  
    148148      if(node.prop.forbidden[i]) buf+=sprintf(buf,"%s!%s",(cont++)?",":"",i.str()); 
    149149    for(Role i=1; i<=Role::count(); ++i) 
    150       if(node.prop.required[i]) buf+=sprintf(buf,"%s&%s",(cont++)?",":"",i.str()); 
     150      if(node.prop.required[i]) buf+=sprintf(buf,"%s-%s",(cont++)?",":"",i.str()); 
    151151    for(Role i=1; i<=Role::count(); ++i) 
    152152      if(node.prop.attached[i]) buf+=sprintf(buf,"%s+%s",(cont++)?",":"",i.str()); 
Note: See TracChangeset for help on using the changeset viewer.