| |
|
|
| |
|
|
| 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) |
|
|
| |
| def Init(self, buf, pos): |
| self._tab = flatbuffers.table.Table(buf, pos) |
|
|
| |
| 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 |
|
|
| |
| 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 |
|
|
| |
| 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 |
|
|
| |
| 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 |
|
|
| |
| def CapturingGroupLength(self): |
| o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) |
| if o != 0: |
| return self._tab.VectorLen(o) |
| return 0 |
|
|
| |
| def CapturingGroupIsNone(self): |
| o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) |
| return o == 0 |
|
|
| |
| 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 |
|
|
| |
| 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 |
|
|
| |
| 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() |
|
|