String Milestones¤
Class for handling text string milestones.
StringMilestones
pydantic-model
¤
Bases: BaseModel
String Milestones class.
Milestones object for text strings or spaCy Doc objects to be treated as strings.
Config:
arbitrary_types_allowed:Truejson_schema_extra:DocJSONSchema.schema()
Fields:
-
doc(Doclike) -
patterns(str | list[str]) -
case_sensitive(bool) -
flags(Enum) -
_spans(list)
Source code in lexos/milestones/string_milestones.py
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 144 145 146 147 | |
spans: list[StringSpan]
property
¤
Return the Spans.
Returns:
| Type | Description |
|---|---|
list[StringSpan]
|
list[StringSpan]: A list of StringSpans. |
__init__(**data) -> None
¤
Set regex flags and milestone IOB extensions after initialization.
Source code in lexos/milestones/string_milestones.py
__iter__() -> Iterator
¤
Make the class iterable.
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
Iterator
|
A generator containing the object's spans. |
set(patterns: Optional[str | list[str]] = None, case_sensitive: Optional[bool] = None) -> None
¤
Return the milestones.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
patterns
|
Optional[str | list[str]]
|
The pattern(s) used to match milestones. |
None
|
case_sensitive
|
bool
|
Whether to perform case-sensitive searches. Defaults to True. |
None
|
Note
If no parameters are set, the method will use the object's current patterns and case sensitivity.
Source code in lexos/milestones/string_milestones.py
__init__(**data) -> None
¤
Set regex flags and milestone IOB extensions after initialization.
Source code in lexos/milestones/string_milestones.py
__iter__() -> Iterator
¤
Make the class iterable.
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
Iterator
|
A generator containing the object's spans. |
spans: list[StringSpan]
property
¤
Return the Spans.
Returns:
| Type | Description |
|---|---|
list[StringSpan]
|
list[StringSpan]: A list of StringSpans. |
_set_case_sensitivity(case_sensitive: Optional[bool] = None) -> None
¤
Set the object's case sensitivity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
case_sensitive
|
(optional, bool)
|
Whether or not to use case-sensitive searching. |
None
|
Source code in lexos/milestones/string_milestones.py
set(patterns: Optional[str | list[str]] = None, case_sensitive: Optional[bool] = None) -> None
¤
Return the milestones.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
patterns
|
Optional[str | list[str]]
|
The pattern(s) used to match milestones. |
None
|
case_sensitive
|
bool
|
Whether to perform case-sensitive searches. Defaults to True. |
None
|
Note
If no parameters are set, the method will use the object's current patterns and case sensitivity.
Source code in lexos/milestones/string_milestones.py
StringSpan
pydantic-model
¤
Bases: BaseModel
StringSpan class.
A Pydantic model containing the milestone text, and the start and character indices of the milestone in the original text.
Fields:
-
text(str) -
start(int) -
end(int)