-
Notifications
You must be signed in to change notification settings - Fork 0
/
ccInd.C
48 lines (44 loc) · 1.15 KB
/
ccInd.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "ccInd.h"
#include "InputTree.h"
#include "Term.h"
int
ccIndFromTree(InputTree* tree)
{
InputTreesIter subTreeIter = tree->subTrees().begin();
ECString trm = tree->term();
bool sawComma = false;
int numTrm = 0;
int pos = 0;
for( ; subTreeIter != tree->subTrees().end() ; subTreeIter++ )
{
InputTree* subTree = *subTreeIter;
if(pos != 0 && (subTree->term() == "CC" || subTree->term() == "CONJP"))
return 1;
if(subTree->term() == trm) numTrm++;
if(pos != 0 && (subTree->term() == "," || subTree->term() == ":"))
sawComma = true;
pos++;
}
/* counts NP -> NP, NP as a conjuncion ??? */
if(sawComma && numTrm >= 2) return 1;
return 0;
}
int
ltocc(int lspec, int ccInd)
{
static int npcc = -1;
static int vpcc = -1;
static int scc = -1;
if(npcc < 0)
{
npcc = Term::get(ECString("G1"))->toInt();
vpcc = Term::get(ECString("G2"))->toInt();
scc = Term::get(ECString("G3"))->toInt();
}
if(!ccInd) return lspec;
ECString nm = Term::fromInt(lspec)->name();
if(nm == "NP") return npcc;
else if(nm == "VP") return vpcc;
else if(nm == "S") return scc;
else return lspec;
}