Last change
on this file since b242df2 was
e7de6cc,
checked in by Tomasz Obrebski <to@…>, 13 years ago
|
new version of dgp
added dgc, tre and compdic components
compiledic renamed to compdic_utf8
./configure updated
|
-
Property mode set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[5f4d9c3] | 1 | |
---|
| 2 | #include "mgraph.hh" |
---|
| 3 | #include "thesymbols.hh" |
---|
| 4 | #include "const.hh" |
---|
| 5 | |
---|
[e7de6cc] | 6 | #include <cstdio> |
---|
[5f4d9c3] | 7 | |
---|
| 8 | int MGraph::add_node(char* seg) |
---|
| 9 | { |
---|
[e7de6cc] | 10 | MNode newnode; |
---|
| 11 | newnode.clear(); |
---|
[5f4d9c3] | 12 | |
---|
[e7de6cc] | 13 | char field1[80], field3[80], field4[256], descr[256], gph[256]; |
---|
[5f4d9c3] | 14 | char* cat; |
---|
| 15 | |
---|
| 16 | getfield(seg,"1",field1); |
---|
[e7de6cc] | 17 | newnode.pos=atoi(field1); |
---|
[5f4d9c3] | 18 | |
---|
| 19 | getfield(seg,"3",field3); |
---|
[e7de6cc] | 20 | |
---|
| 21 | getfield(seg,"4",field4); |
---|
| 22 | strcpy(newnode.form,field4); |
---|
| 23 | |
---|
[5f4d9c3] | 24 | if(!getfield(seg,"lem",descr)) strcpy(descr,"?,?"); |
---|
| 25 | |
---|
| 26 | cat=descr; |
---|
| 27 | while(*cat!=',' && *cat ) ++cat; |
---|
| 28 | if(*cat) ++cat; |
---|
| 29 | |
---|
| 30 | if(Cat::index(cat)>0) |
---|
[e7de6cc] | 31 | newnode.cat=cat; |
---|
[5f4d9c3] | 32 | else |
---|
[e7de6cc] | 33 | newnode.cat="NULL"; |
---|
[5f4d9c3] | 34 | |
---|
[e7de6cc] | 35 | newnode.pred.clear(); |
---|
[5f4d9c3] | 36 | |
---|
| 37 | char* tok; |
---|
| 38 | int previd; |
---|
| 39 | |
---|
| 40 | if(!getfield(seg,"gph",gph)) |
---|
| 41 | { |
---|
| 42 | fprintf(stderr,"No gph field. Aborting (sorry).\n"); |
---|
| 43 | exit(1); |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | char* ids=strtok(gph,":"); |
---|
[e7de6cc] | 47 | if(size() != atoi(ids)) {fprintf(stderr,"Invalid node id in line ?. Program aborted.\n"); exit(1); } |
---|
[5f4d9c3] | 48 | |
---|
| 49 | char *preds; |
---|
| 50 | while(preds=strtok(NULL,",")) |
---|
| 51 | { |
---|
| 52 | previd=atoi(preds); |
---|
[e7de6cc] | 53 | newnode.pred.push_back(previd); |
---|
[5f4d9c3] | 54 | } |
---|
| 55 | |
---|
[e7de6cc] | 56 | nodes.push_back(newnode); |
---|
| 57 | return nodes.size()-1; |
---|
[5f4d9c3] | 58 | } |
---|
| 59 | |
---|
Note: See
TracBrowser
for help on using the repository browser.