package iskra // SetEntry is one element of the sentence-as-set abstraction: Role + Atom + // Morph + Class + Mark + OblRole + Head + ModKind. extract.mx SetEntry. type SetEntry struct { Role int32 Atom string Morph uint16 Class uint8 Mark uint8 OblRole uint8 Head int16 ModKind uint8 } // Clause is one predication in a Discourse. type Clause struct { Set []SetEntry Relation uint8 Parent int16 HostIdx int16 } // ExtractResult is one extraction: pattern, slots, roles and the clause set. type ExtractResult struct { Pattern []byte Slots []string Roles []int32 DeepPat []uint8 Set []SetEntry Discourse []Clause } // UntranslatedMarker stands in for an atom with no cross-language link. const UntranslatedMarker = "[missing]" // SetsEqualCross compares two sets on the language-independent fields. func SetsEqualCross(a, b []SetEntry) bool { if len(a) != len(b) { return false } for i := range a { if a[i].Role != b[i].Role || a[i].Atom != b[i].Atom || a[i].Morph != b[i].Morph || a[i].OblRole != b[i].OblRole || a[i].Head != b[i].Head || a[i].ModKind != b[i].ModKind { return false } } return true } // DiscoursesEqual compares two clause lists. func DiscoursesEqual(a, b []Clause) bool { if len(a) != len(b) { return false } for i := range a { if a[i].Relation != b[i].Relation || a[i].Parent != b[i].Parent || a[i].HostIdx != b[i].HostIdx { return false } if !SetsEqualCross(a[i].Set, b[i].Set) { return false } } return true } // FlatSetFromDiscourse concatenates every clause's entries. func FlatSetFromDiscourse(d []Clause) []SetEntry { var out []SetEntry for _, c := range d { out = append(out, c.Set...) } return out }