Skip to content

Commit 60ecd05

Browse files
aoiasdAbdullah Ahmed
authored andcommitted
enhance: add property func for AnalyzeToken (milvus-io#2704)
Signed-off-by: aoiasd <[email protected]>
1 parent 4298f66 commit 60ecd05

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

pymilvus/client/types.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,33 @@ def __init__(
11151115
if with_hash:
11161116
self.dict["hash"] = token.hash
11171117

1118+
@property
1119+
def token(self):
1120+
return self.dict["token"]
1121+
1122+
@property
1123+
def start_offset(self):
1124+
return self.dict["start_offset"]
1125+
1126+
@property
1127+
def end_offset(self):
1128+
return self.dict["end_offset"]
1129+
1130+
@property
1131+
def position(self):
1132+
return self.dict["position"]
1133+
1134+
@property
1135+
def position_length(self):
1136+
return self.dict["position_length"]
1137+
1138+
@property
1139+
def hash(self):
1140+
return self.dict["hash"]
1141+
1142+
def __getitem__(self, key: str):
1143+
return self.dict[key]
1144+
11181145
def __str__(self):
11191146
return str(self.dict)
11201147

@@ -1128,9 +1155,7 @@ def __init__(
11281155
if not with_detail and not with_hash:
11291156
self.tokens = [token.token for token in info.tokens]
11301157
else:
1131-
self.tokens = [
1132-
AnalyzeToken(token, with_hash, with_detail).dict for token in info.tokens
1133-
]
1158+
self.tokens = [AnalyzeToken(token, with_hash, with_detail) for token in info.tokens]
11341159

11351160
def __str__(self) -> str:
11361161
return str(self.tokens)

0 commit comments

Comments
 (0)