Span Milestones¤
Class for handling multi-token milestones.
SpanMilestones
pydantic-model
¤
Bases: BaseModel
Span Milestones class.
- Referencing the Milestones instance yields an iterator of the spans in the Doc.
- Referencing Milestones.spans returns an indexed list of spans in the Doc.
- Referencing milestones.doc.spans["milestones"] returns a SpanGroup.
Config:
default:validation_config
Fields:
-
doc(Doc | Span) -
nlp(str)
Source code in lexos/milestones/span_milestones.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
spans: list[Span]
property
¤
Return the milestone Spans.
Returns:
| Type | Description |
|---|---|
list[Span]
|
list[Span]: A list of spaCy Spans. |
__init__(**data) -> None
¤
Set regex flags and milestone IOB extensions after initialization.
Source code in lexos/milestones/span_milestones.py
__iter__() -> Iterator
¤
Make the class iterable.
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
Iterator
|
A generator containing the object's spans. |
__init__(**data) -> None
¤
Set regex flags and milestone IOB extensions after initialization.
Source code in lexos/milestones/span_milestones.py
__iter__() -> Iterator
¤
Make the class iterable.
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
Iterator
|
A generator containing the object's spans. |
spans: list[Span]
property
¤
Return the milestone Spans.
Returns:
| Type | Description |
|---|---|
list[Span]
|
list[Span]: A list of spaCy Spans. |
_assign_token_attributes(spans: list[Span], max_label_length: int = 20) -> None
¤
Assign token attributes in the doc based on spans.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spans
|
list[Span]
|
A list of spaCy Spans. |
required |
max_label_length
|
int
|
The maximum number of characters to include in the label. |
20
|
Source code in lexos/milestones/span_milestones.py
_get_list(*, strip_punct: Optional[bool] = True) -> list[dict]
¤
Get a list of milestone dicts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strip_punct
|
Optional[bool]
|
Strip single punctation mark at the end of the character string. |
True
|
Source code in lexos/milestones/span_milestones.py
_reset() -> None
¤
SentenceMilestones
pydantic-model
¤
Bases: SpanMilestones
Sentence Milestones class.
- Referencing the Milestones instance yields an iterator of the spans in the Doc.
- Referencing Milestones.spans returns an indexed list of spans in the Doc.
- Referencing milestones.doc.spans["milestones"] returns a SpanGroup.
Fields:
-
nlp(str) -
doc(Doc | Span)
Source code in lexos/milestones/span_milestones.py
spans: list[Span]
property
¤
Return the milestone Spans.
Returns:
| Type | Description |
|---|---|
list[Span]
|
list[Span]: A list of spaCy Spans. |
__init__(**data) -> None
¤
Set regex flags and milestone IOB extensions after initialization.
Source code in lexos/milestones/span_milestones.py
__iter__() -> Iterator
¤
Make the class iterable.
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
Iterator
|
A generator containing the object's spans. |
reset()
¤
set(*, step: Optional[int] = 1, max_label_length: Optional[int] = 20) -> None
¤
Generate spans with n sentences per span.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
Optional[int]
|
The number of sentences to group under a single milestone |
1
|
max_label_length
|
Optional[int]
|
The maximum number of characters to include in the label. |
20
|
Source code in lexos/milestones/span_milestones.py
to_list(*, strip_punct: Optional[bool] = True) -> list[dict]
¤
Get a list of milestone dicts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strip_punct
|
Optional[bool]
|
Strip single punctation mark at the end of the character string. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of milestone dicts. |
Source code in lexos/milestones/span_milestones.py
__init__(**data) -> None
¤
Set regex flags and milestone IOB extensions after initialization.
Source code in lexos/milestones/span_milestones.py
reset()
¤
set(*, step: Optional[int] = 1, max_label_length: Optional[int] = 20) -> None
¤
Generate spans with n sentences per span.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
Optional[int]
|
The number of sentences to group under a single milestone |
1
|
max_label_length
|
Optional[int]
|
The maximum number of characters to include in the label. |
20
|
Source code in lexos/milestones/span_milestones.py
to_list(*, strip_punct: Optional[bool] = True) -> list[dict]
¤
Get a list of milestone dicts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strip_punct
|
Optional[bool]
|
Strip single punctation mark at the end of the character string. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of milestone dicts. |
Source code in lexos/milestones/span_milestones.py
LineMilestones
pydantic-model
¤
Bases: SpanMilestones
Line Milestones class.
- Referencing the Milestones instance yields an iterator of the spans in the Doc.
- Referencing Milestones.spans returns an indexed list of spans in the Doc.
- Referencing milestones.doc.spans["milestones"] returns a SpanGroup.
Fields:
-
nlp(str) -
doc(Doc | Span)
Source code in lexos/milestones/span_milestones.py
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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | |
spans: list[Span]
property
¤
Return the milestone Spans.
Returns:
| Type | Description |
|---|---|
list[Span]
|
list[Span]: A list of spaCy Spans. |
__init__(**data) -> None
¤
Set regex flags and milestone IOB extensions after initialization.
Source code in lexos/milestones/span_milestones.py
__iter__() -> Iterator
¤
Make the class iterable.
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
Iterator
|
A generator containing the object's spans. |
reset()
¤
set(pattern: Optional[str] = '\n', *, step: Optional[int] = 1, remove_linebreak: Optional[bool] = True, max_label_length: Optional[int] = 20) -> list[Span]
¤
Generate spans based on line breaks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
Optional[str]
|
The string or regex pattern to use to identify the milestone. |
'\n'
|
step
|
Optional[int]
|
The number of lines to include in the spans. By default, all lines are included. |
1
|
remove_linebreak
|
Optional[bool]
|
Whether or not to remove the linebreak character. |
True
|
max_label_length
|
Optional[int]
|
The maximum number of characters to include in the label. |
20
|
Returns:
| Type | Description |
|---|---|
list[Span]
|
list[Span]: A list of spaCy spans. |
Source code in lexos/milestones/span_milestones.py
to_list(*, strip_punct: Optional[bool] = True) -> list[dict]
¤
Get a list of milestone dicts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strip_punct
|
Optional[bool]
|
Strip single punctation mark at the end of the character string. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of milestone dicts. |
Source code in lexos/milestones/span_milestones.py
__init__(**data) -> None
¤
Set regex flags and milestone IOB extensions after initialization.
Source code in lexos/milestones/span_milestones.py
reset()
¤
set(pattern: Optional[str] = '\n', *, step: Optional[int] = 1, remove_linebreak: Optional[bool] = True, max_label_length: Optional[int] = 20) -> list[Span]
¤
Generate spans based on line breaks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
Optional[str]
|
The string or regex pattern to use to identify the milestone. |
'\n'
|
step
|
Optional[int]
|
The number of lines to include in the spans. By default, all lines are included. |
1
|
remove_linebreak
|
Optional[bool]
|
Whether or not to remove the linebreak character. |
True
|
max_label_length
|
Optional[int]
|
The maximum number of characters to include in the label. |
20
|
Returns:
| Type | Description |
|---|---|
list[Span]
|
list[Span]: A list of spaCy spans. |
Source code in lexos/milestones/span_milestones.py
to_list(*, strip_punct: Optional[bool] = True) -> list[dict]
¤
Get a list of milestone dicts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strip_punct
|
Optional[bool]
|
Strip single punctation mark at the end of the character string. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of milestone dicts. |
Source code in lexos/milestones/span_milestones.py
CustomMilestones
pydantic-model
¤
Bases: SpanMilestones
Custom Milestones class.
- Referencing the Milestones instance yields an iterator of the spans in the Doc.
- Referencing Milestones.spans returns an indexed list of spans in the Doc.
- Referencing milestones.doc.spans["milestones"] returns a SpanGroup.
Fields:
-
nlp(str) -
doc(Doc | Span)
Source code in lexos/milestones/span_milestones.py
spans: list[Span]
property
¤
Return the milestone Spans.
Returns:
| Type | Description |
|---|---|
list[Span]
|
list[Span]: A list of spaCy Spans. |
__init__(**data) -> None
¤
Set regex flags and milestone IOB extensions after initialization.
Source code in lexos/milestones/span_milestones.py
__iter__() -> Iterator
¤
Make the class iterable.
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
Iterator
|
A generator containing the object's spans. |
reset()
¤
set(spans: list[Span], *, step: Optional[int] = 1, max_label_length: Optional[int] = 20) -> list[Span]
¤
Generate spans based on a custom list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spans
|
list[Span]
|
A list of spaCy spans. |
required |
step
|
Optional[int]
|
The number of spans to group into each milestone span. By default, all spans are included. |
1
|
max_label_length
|
Optional[int]
|
The maximum number of characters to include in the label. |
20
|
Returns:
| Type | Description |
|---|---|
list[Span]
|
list[Span]: A list of spaCy spans. |
Source code in lexos/milestones/span_milestones.py
to_list(*, strip_punct: Optional[bool] = True) -> list[dict]
¤
Get a list of milestone dicts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strip_punct
|
Optional[bool]
|
Strip single punctation mark at the end of the character string. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of milestone dicts. |
Source code in lexos/milestones/span_milestones.py
__init__(**data) -> None
¤
Set regex flags and milestone IOB extensions after initialization.
Source code in lexos/milestones/span_milestones.py
reset()
¤
set(spans: list[Span], *, step: Optional[int] = 1, max_label_length: Optional[int] = 20) -> list[Span]
¤
Generate spans based on a custom list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spans
|
list[Span]
|
A list of spaCy spans. |
required |
step
|
Optional[int]
|
The number of spans to group into each milestone span. By default, all spans are included. |
1
|
max_label_length
|
Optional[int]
|
The maximum number of characters to include in the label. |
20
|
Returns:
| Type | Description |
|---|---|
list[Span]
|
list[Span]: A list of spaCy spans. |
Source code in lexos/milestones/span_milestones.py
to_list(*, strip_punct: Optional[bool] = True) -> list[dict]
¤
Get a list of milestone dicts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strip_punct
|
Optional[bool]
|
Strip single punctation mark at the end of the character string. |
True
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of milestone dicts. |