Sentence
A sentence that is broken down into its individual constituents and their associated metadata. This object utilizes caching to avoid performing expensive computations redundantly.
Source code in src/limes/sentence.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 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 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
barriers
property
All barriers contained in the sentence, as detected by the Analyzer
attached to this sentence.
local_complexities
property
A list of syntactically coherent phrases that constitute the given sentence, as well as their respective calculated syntactic complexities. You can sum the local complexities to get a sound heuristic for the complexity of the complete sentence.
__init__(sent, analyzer)
Create a Sentence object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sent
|
DocumentProtocol
|
A sentence, as parsed by a |
required |
analyzer
|
Analyzer
|
The analyzer that is to be used for actual barrier analysis. |
required |
Source code in src/limes/sentence.py
__str__()
__iter__()
Iterate over all TokenProtocols contained in the given sentence. The
type of returned TokenProtocol subclass depends on the Parser with
which this sentence was created.
Source code in src/limes/sentence.py
__getitem__(i)
Return the i-th TokenProtocol in the given sentence. The type of
returned TokenProtocol subclass depends on the Parser with which
this sentence was created.
global_complexity(heuristic=ComplexityAlgorithm.AGGREGATED_LOCAL)
The complexity of the sentence as a whole.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
heuristic
|
ComplexityAlgorithm
|
Determines which heuristic to use to calculate the complexity. |
AGGREGATED_LOCAL
|
Source code in src/limes/sentence.py
find(word, pos, dehyphenate=False, consider_fallback_tags=True)
All instances of the given word contained in the Sentence, if any. The
function builds an index on first run, yielding a lookup of O(n).
Subsequent lookups occur in constant time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
word
|
str
|
The word to be searched for. You can pass in surface forms of words but using its lemma is suggested to reduce false negatives. |
required |
pos
|
PartOfSpeechTag
|
The part-of-speech tag of the word you are looking for. |
required |
dehyphenate
|
bool(Optional)
|
Whether or not to strip hyphens from tokens in the provided |
False
|
consider_fallback_tags
|
bool(optional)
|
Whether to consider alternative POS tags in cases where the
language-specific |
True
|
Returns:
| Type | Description |
|---|---|
A list of tokens contained in the `Sentence` that match the provided
|
|
details about the searched-for word. If no tokens in the `Sentence`
|
|
match, returns None.
|
|