source: app/src/dgp/mgraph.cc @ b3179eb

help
Last change on this file since b3179eb was 0214596, checked in by pawelk <pawelk@…>, 17 years ago

Dodalismy do pakietu utt komponent dgp (brak configow i innych bajerow).

git-svn-id: svn://atos.wmid.amu.edu.pl/utt@24 e293616e-ec6a-49c2-aa92-f4a8b91c5d16

  • Property mode set to 100644
File size: 921 bytes
Line 
1
2#include "mgraph.hh"
3#include "thesymbols.hh"
4#include "const.hh"
5#include "common.h"
6
7#include <stdio.h>
8
9int MGraph::add_node(char* seg)
10{
11  nodes[n].clear();
12 
13  char field1[80], field3[80], descr[256], gph[256];
14  char* cat;
15 
16  getfield(seg,"1",field1);
17  nodes[n].pos=atoi(field1);
18
19  getfield(seg,"3",field3);
20  if(!getfield(seg,"lem",descr)) strcpy(descr,"?,?");
21
22  cat=descr;
23  while(*cat!=',' && *cat ) ++cat;
24  if(*cat) ++cat;
25 
26  Cat::add(cat);
27  nodes[n].cat=cat;
28 
29  nodes[n].pred.clear();
30 
31  char* tok;
32  int previd;
33 
34  if(!getfield(seg,"gph",gph))
35  {
36    fprintf(stderr,"No gph field. Aborting (sorry).\n");
37    exit(1);
38  }
39
40  char* ids=strtok(gph,":");
41  if(n!=atoi(ids)){fprintf(stderr,"Invalid node id in line ?. Program aborted.\n"); exit(1); }
42 
43  char *preds;
44  while(preds=strtok(NULL,","))
45  {
46    previd=atoi(preds);
47    nodes[n].pred.push_back(&nodes[previd]);
48  }
49
50  return n++;
51}
52
Note: See TracBrowser for help on using the repository browser.