parsing
Parser(config)
¶
Source code in langroid/parsing/parser.py
add_window_ids(chunks)
¶
Chunks may belong to multiple docs, but for each doc, they appear consecutively. Add window_ids in metadata
Source code in langroid/parsing/parser.py
chunk_tokens(text)
¶
Split a text into chunks of ~CHUNK_SIZE tokens, based on punctuation and newline boundaries. Adapted from https://github.com/openai/chatgpt-retrieval-plugin/blob/main/services/chunks.py
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
The text to split into chunks. |
required |
Returns:
Type | Description |
---|---|
List[str]
|
A list of text chunks, each of which is a string of tokens |
List[str]
|
roughly self.config.chunk_size tokens long. |
Source code in langroid/parsing/parser.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
|