roles.go raw
1 package iskra
2
3 // Role histogram indices, pattern.mx RoleHist.
4 const (
5 HistTopic = 0
6 HistSubject = 1
7 HistObject = 2
8 HistVerb = 3
9 HistModifier = 4
10 HistScope = 5
11 HistOperator = 6
12 HistComplement = 7
13 )
14
15 // Oblique roles. Language-independent thematic relations.
16 const (
17 ORNone uint8 = 0
18 ORGoal uint8 = 1
19 ORLoc uint8 = 2
20 ORSource uint8 = 3
21 ORLimit uint8 = 4
22 ORInstr uint8 = 5
23 ORComit uint8 = 6
24 ORBenef uint8 = 7
25 ORAgent uint8 = 8
26 ORRecip uint8 = 9
27 ORPart uint8 = 10
28 ORCompare uint8 = 11
29 )
30
31 // Modification kinds. A SetEntry with Head=-1 is a top-level argument;
32 // otherwise it modifies the entry at Head.
33 const (
34 MKNone uint8 = 0
35 MKPoss uint8 = 1
36 MKAttr uint8 = 2
37 MKCop uint8 = 3
38 MKAdv uint8 = 4
39 MKCoord uint8 = 5
40 MKRel uint8 = 6
41 MKApp uint8 = 7
42 MKAdj uint8 = 8
43 )
44
45 // Clause relations.
46 const (
47 ClauseRoot = 0
48 ClauseAnd = 1
49 ClauseOr = 2
50 ClauseBut = 3
51 ClauseIf = 4
52 ClauseBecause = 5
53 ClauseRel = 6
54 )
55
56 // RoleEquiv is the cross-language role equivalence used for atom alignment:
57 // Topic counts as Subject on the first pass.
58 func RoleEquiv(a, b int32) bool {
59 if a == b {
60 return true
61 }
62 return normalizeRole(a) == normalizeRole(b)
63 }
64
65 func normalizeRole(r int32) int32 {
66 if r == HistTopic {
67 return HistSubject
68 }
69 return r
70 }
71