# automatically generated by the FlatBuffers compiler, do not modify # namespace: GrammarModel_ import flatbuffers from flatbuffers.compat import import_numpy np = import_numpy() class RuleClassificationResult(object): __slots__ = ['_tab'] @classmethod def GetRootAsRuleClassificationResult(cls, buf, offset): n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) x = RuleClassificationResult() x.Init(buf, n + offset) return x @classmethod def RuleClassificationResultBufferHasIdentifier(cls, buf, offset, size_prefixed=False): return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x43\x32\x20", size_prefixed=size_prefixed) # RuleClassificationResult def Init(self, buf, pos): self._tab = flatbuffers.table.Table(buf, pos) # RuleClassificationResult def CollectionName(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) if o != 0: return self._tab.String(o + self._tab.Pos) return None # RuleClassificationResult def TargetClassificationScore(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) if o != 0: return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos) return 1.0 # RuleClassificationResult def PriorityScore(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) if o != 0: return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos) return 0.0 # RuleClassificationResult def CapturingGroup(self, j): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) if o != 0: x = self._tab.Vector(o) x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 x = self._tab.Indirect(x) from libtextclassifier3.CapturingGroup import CapturingGroup obj = CapturingGroup() obj.Init(self._tab.Bytes, x) return obj return None # RuleClassificationResult def CapturingGroupLength(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) if o != 0: return self._tab.VectorLen(o) return 0 # RuleClassificationResult def CapturingGroupIsNone(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) return o == 0 # RuleClassificationResult def SerializedEntityData(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) if o != 0: return self._tab.String(o + self._tab.Pos) return None # RuleClassificationResult def EnabledModes(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) if o != 0: return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) return 7 # RuleClassificationResult def EntityData(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16)) if o != 0: x = self._tab.Indirect(o + self._tab.Pos) from libtextclassifier3.EntityData import EntityData obj = EntityData() obj.Init(self._tab.Bytes, x) return obj return None def RuleClassificationResultStart(builder): builder.StartObject(7) def RuleClassificationResultAddCollectionName(builder, collectionName): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(collectionName), 0) def RuleClassificationResultAddTargetClassificationScore(builder, targetClassificationScore): builder.PrependFloat32Slot(1, targetClassificationScore, 1.0) def RuleClassificationResultAddPriorityScore(builder, priorityScore): builder.PrependFloat32Slot(2, priorityScore, 0.0) def RuleClassificationResultAddCapturingGroup(builder, capturingGroup): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(capturingGroup), 0) def RuleClassificationResultStartCapturingGroupVector(builder, numElems): return builder.StartVector(4, numElems, 4) def RuleClassificationResultAddSerializedEntityData(builder, serializedEntityData): builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(serializedEntityData), 0) def RuleClassificationResultAddEnabledModes(builder, enabledModes): builder.PrependInt32Slot(5, enabledModes, 7) def RuleClassificationResultAddEntityData(builder, entityData): builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(entityData), 0) def RuleClassificationResultEnd(builder): return builder.EndObject()