Skip to content

Commit c9a2064

Browse files
committed
enhance: add property func for AnalyzeToken (milvus-io#2704)
Signed-off-by: aoiasd <[email protected]>
1 parent 0e08218 commit c9a2064

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
@@ -1096,6 +1096,33 @@ def __init__(
10961096
if with_hash:
10971097
self.dict["hash"] = token.hash
10981098

1099+
@property
1100+
def token(self):
1101+
return self.dict["token"]
1102+
1103+
@property
1104+
def start_offset(self):
1105+
return self.dict["start_offset"]
1106+
1107+
@property
1108+
def end_offset(self):
1109+
return self.dict["end_offset"]
1110+
1111+
@property
1112+
def position(self):
1113+
return self.dict["position"]
1114+
1115+
@property
1116+
def position_length(self):
1117+
return self.dict["position_length"]
1118+
1119+
@property
1120+
def hash(self):
1121+
return self.dict["hash"]
1122+
1123+
def __getitem__(self, key: str):
1124+
return self.dict[key]
1125+
10991126
def __str__(self):
11001127
return str(self.dict)
11011128

@@ -1109,9 +1136,7 @@ def __init__(
11091136
if not with_detail and not with_hash:
11101137
self.tokens = [token.token for token in info.tokens]
11111138
else:
1112-
self.tokens = [
1113-
AnalyzeToken(token, with_hash, with_detail).dict for token in info.tokens
1114-
]
1139+
self.tokens = [AnalyzeToken(token, with_hash, with_detail) for token in info.tokens]
11151140

11161141
def __str__(self) -> str:
11171142
return str(self.tokens)

0 commit comments

Comments
 (0)