@@ -170,6 +170,48 @@ def __init__(
170
170
super ().__init__ (kwargs )
171
171
172
172
173
+ class ChunkingSettings (AttrDict [Any ]):
174
+ """
175
+ :arg strategy: (required) The chunking strategy: `sentence` or `word`.
176
+ Defaults to `sentence` if omitted.
177
+ :arg max_chunk_size: (required) The maximum size of a chunk in words.
178
+ This value cannot be higher than `300` or lower than `20` (for
179
+ `sentence` strategy) or `10` (for `word` strategy). Defaults to
180
+ `250` if omitted.
181
+ :arg overlap: The number of overlapping words for chunks. It is
182
+ applicable only to a `word` chunking strategy. This value cannot
183
+ be higher than half the `max_chunk_size` value. Defaults to `100`
184
+ if omitted.
185
+ :arg sentence_overlap: The number of overlapping sentences for chunks.
186
+ It is applicable only for a `sentence` chunking strategy. It can
187
+ be either `1` or `0`. Defaults to `1` if omitted.
188
+ """
189
+
190
+ strategy : Union [str , DefaultType ]
191
+ max_chunk_size : Union [int , DefaultType ]
192
+ overlap : Union [int , DefaultType ]
193
+ sentence_overlap : Union [int , DefaultType ]
194
+
195
+ def __init__ (
196
+ self ,
197
+ * ,
198
+ strategy : Union [str , DefaultType ] = DEFAULT ,
199
+ max_chunk_size : Union [int , DefaultType ] = DEFAULT ,
200
+ overlap : Union [int , DefaultType ] = DEFAULT ,
201
+ sentence_overlap : Union [int , DefaultType ] = DEFAULT ,
202
+ ** kwargs : Any ,
203
+ ):
204
+ if strategy is not DEFAULT :
205
+ kwargs ["strategy" ] = strategy
206
+ if max_chunk_size is not DEFAULT :
207
+ kwargs ["max_chunk_size" ] = max_chunk_size
208
+ if overlap is not DEFAULT :
209
+ kwargs ["overlap" ] = overlap
210
+ if sentence_overlap is not DEFAULT :
211
+ kwargs ["sentence_overlap" ] = sentence_overlap
212
+ super ().__init__ (kwargs )
213
+
214
+
173
215
class ClassificationInferenceOptions (AttrDict [Any ]):
174
216
"""
175
217
:arg num_top_classes: Specifies the number of top class predictions to
@@ -1617,11 +1659,7 @@ class InnerHits(AttrDict[Any]):
1617
1659
DefaultType ,
1618
1660
]
1619
1661
seq_no_primary_term : Union [bool , DefaultType ]
1620
- fields : Union [
1621
- Union [str , InstrumentedField ],
1622
- Sequence [Union [str , InstrumentedField ]],
1623
- DefaultType ,
1624
- ]
1662
+ fields : Union [Sequence [Union [str , InstrumentedField ]], DefaultType ]
1625
1663
sort : Union [
1626
1664
Union [Union [str , InstrumentedField ], "SortOptions" ],
1627
1665
Sequence [Union [Union [str , InstrumentedField ], "SortOptions" ]],
@@ -1656,11 +1694,7 @@ def __init__(
1656
1694
DefaultType ,
1657
1695
] = DEFAULT ,
1658
1696
seq_no_primary_term : Union [bool , DefaultType ] = DEFAULT ,
1659
- fields : Union [
1660
- Union [str , InstrumentedField ],
1661
- Sequence [Union [str , InstrumentedField ]],
1662
- DefaultType ,
1663
- ] = DEFAULT ,
1697
+ fields : Union [Sequence [Union [str , InstrumentedField ]], DefaultType ] = DEFAULT ,
1664
1698
sort : Union [
1665
1699
Union [Union [str , InstrumentedField ], "SortOptions" ],
1666
1700
Sequence [Union [Union [str , InstrumentedField ], "SortOptions" ]],
0 commit comments