1
2
3
4
5
6
7
8
9
10
11
12
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
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
//! The FIVE columns a [`DetectedLanguage`] spans, and the two facts that follow from them.
//!
//! ```text
//! SEGMENTS <the identity's four, FLATTENED>, confidence
//! Carrier ?, ?, ?, ?, ?
//! MongoCarrier the identity's four KEYS, then confidence — one document, five keys
//! ```
//!
//! # The identity is FLATTENED rather than nested, which is what keeps the column names flat
//!
//! [`ColumnShape::Composite`] carries an optional field name, and the difference between naming it
//! and leaving it out is one path segment per column. A detection at `detected` reaches
//! `detected_language`, `detected_script`, `detected_region`, `detected_rest` and
//! `detected_confidence` — five columns, one prefix. Naming the composite's own field would have
//! given `detected_language_language`, which says the same word twice and buys nothing: a detection
//! holds exactly one identity, so there is nothing for that segment to disambiguate.
//!
//! # There is no `Assemble` and no `CursorValue` here, and both absences are the same one
//!
//! [`LanguageId`](super::super::LanguageId) has both because a column of identities is a thing a
//! declaration holds and a page walks. A DETECTION is a member of a `Vec` — see this type's
//! [`DefaultVecMarker`](crate::DefaultVecMarker) row — so what a row holds is the collection, and
//! reading one out of a row and paging past one are both questions asked of the collection's own
//! storage rather than of the element. The day a declaration holds a BARE detection, both rows are
//! written the way `LanguageId`'s are.
//!
//! **The two WRITE rows are here anyway, and that is not an inconsistency.** A decode and a cursor
//! are questions asked ABOUT A COLUMN, so an element that occupies none has neither; a bind and a
//! document form are what one VALUE looks like, which an element has whether or not it is the whole
//! of a field. `Carrier` has always been here for that reason, and `MongoCarrier` joins it under it.
use crate::;
use ;
// The identity's own sub-document reader, shared rather than re-derived — see this file's
// `MongoExtract` row for why a detection reads the SAME four keys `LanguageId`'s own row does.
use document_seats;
/// The confidence column's segment — the one this type adds to the identity's four.
pub const CONFIDENCE: &FieldName = new;
/// **The five columns a detection spans**: the identity's four, flattened, then the confidence.
///
/// `confidence` rather than `score`, which is what a CLASSIFIER's degree column is called where one
/// is declared. The two hold the same type and the names differ because the two rulings named them
/// differently — a classifier's is a SCORE, a detector's is a CONFIDENCE. It is recorded rather than
/// quietly unified because a schema with both words in it is a thing a client reads, and whichever
/// way it is eventually settled should be settled deliberately.
pub const SEGMENTS: & = &;
/// **The STORAGE half of the width** — five columns, and the identity's four are its own.
/// **One leaf, and it is the value.** A detected language means its identity then its confidence, as declared.
// A detection is one column value when the identity and the confidence both are — the same
// pairing this type's own `PartialEq` already reads: the same language at a different confidence
// is a different detection.
column_eq!
/// **The DECLARED half — FIVE words, of which the identity's FOUR are read off its own row.**
///
/// The identity's entry above is [`flattened::<LanguageId>()`](crate::flattened), which lends no
/// name but spans four columns all the same, so four of the five words are that type's and this row
/// indexes them rather than restating that a language identity is text four times over. The fifth is
/// the confidence, whose word is [`Score`](crate::Score)'s — a `Confidence<f32>`, declared at the
/// width it measures in.
/// **THE ADMISSION**, written by the declaration because the declaration is the only party that
/// knows.
///
/// [`CollectionElement`](crate::CollectionElement) states one fact a width cannot: whether this type
/// is itself MANY. A detection is a language identity and a number, so it is not — and this row is
/// what says so, exactly as [`Timestamp`](crate::Timestamp)'s does one file over. A record declaring
/// `Vec<DetectedLanguage>` sees two token trees and could not have told.
///
/// It is the first admitted element whose own parts NEST. The identity is
/// [`flattened`](crate::flattened) above, so this element's columns are five LEAVES rather than two
/// parts, and the edge table writes the five under the collection's path — `heard_language`,
/// `heard_script`, `heard_region`, `heard_rest`, `heard_confidence` — which is the same list the
/// DIRECT column of a detection already occupies. That is the whole of what admitting a nested
/// element took: the names were never a second convention, only a walk that had to descend.
/// **N BINDS OUT** — the identity's four placeholders, then the confidence.
///
/// The identity writes its own three commas, which is the arrangement
/// [`Carrier`](crate::Carrier) documents: how many columns a value spans is the value's own
/// answer, so a composite pushes several placeholders with its own separators and the caller counts
/// FIELDS.
/// **THE DOCUMENT'S FORM: FIVE KEYS AT ONE LEVEL** — the identity's four, then the confidence.
///
/// ```text
/// { "language": "zh", "script": "Hans", "region": null, "rest": null, "confidence": 0.94 }
/// ```
///
/// # The identity is SPLICED here and NESTED when it is a field of its own, and that is one rule
///
/// [`LanguageId`]'s own row writes a sub-document, because MongoDB's default for a composite IS the
/// nested one — its declaration block has no `flatten` word at all, there being no rendered prefix
/// to drop. What decides the shape here is not a second policy but the SEGMENTS above: the identity's
/// entry is [`flattened::<LanguageId>()`](crate::flattened), which lends NO NAME, and a key set is
/// built out of names. There is no key to nest under, so its four join this document's own — which is
/// the same thing the SQL side does with the same entry, in the spelling that family has for it.
///
/// It is also the addressing the comparison next door already writes.
/// [`SqlDetectedLanguageComparison`](super::SqlDetectedLanguageComparison) applies the identity at
/// `at` UNCHANGED and pushes one segment for the confidence, so a detection at `heard` is asked about
/// as `heard_language` and `heard_confidence` in a table and would be asked as `heard.language` and
/// `heard.confidence` in a document. Nesting the identity under a name would have made those
/// `heard.language.language` — the doubled word this file's `SEGMENTS` note already refused once, in
/// the other family's spelling.
///
/// # The CONFIDENCE is a `Double`, through the width's own row
///
/// [`Score`](crate::Score) is a `Confidence<f32>` and the register's confidence row carries every
/// width that has one: BSON's only binary float is 64 bits, and an `f32` widens into it exactly. The
/// `[0.0, 1.0]` invariant is the DOMAIN's rather than the column's, so nothing about it is encoded —
/// which is the same sentence the SQL bind makes by binding the wrapped float.
///
/// # What SPENDS this row today, stated rather than implied
///
/// No operand of [`DetectedLanguageFilter`](super::DetectedLanguageFilter) is a whole detection —
/// the identity axis crosses on a [`LanguageIdOperand`](super::super::LanguageIdOperand) and the
/// confidence on a threshold — so nothing in this family's own filter compares against the shape
/// below. What it states is what a DOCUMENT holding a detection looks like, which is the fact a
/// `Vec<DetectedLanguage>` field needs and the one a comparison over a whole collection would bind.
/// It is written now for the reason the whole family's faces are: a shape decided beside its own
/// SEGMENTS is a shape one authority produced, and a shape decided later is one invented twice.
///
/// As with every other row here, this is the FILTER OPERAND's form and not a serde row — see
/// [`LanguageId`]'s, where the `E0277` a bare column earns at the declaration is named.
/// **THE READ: the identity's four keys back through their own door, then the confidence** —
/// [`MongoCarrier`](crate::MongoCarrier)'s mirror, splicing where that row splices and nowhere
/// nesting where it does not.
///
/// # The four identity keys are [`document_seats`]'s, unchanged
///
/// The write above builds a detection's document by taking the identity's OWN document and adding
/// one key, because there is no key to nest the identity under. The read takes the same document
/// ONCE and reads five keys out of it: the same [`document_seats`] `LanguageId`'s own row calls,
/// handed the whole document rather than a sub-document of it, and then `confidence` beside it.
/// Nothing here re-derives what a key means or what refuses it — a `script` holding the wrong BSON
/// type is refused by the exact same sentence whether it arrived on a bare identity or a detection.
///
/// # The CONFIDENCE reads through [`Score`](crate::Score)'s own row, which already exists
///
/// [`Score`](crate::Score) is [`Confidence<f32>`](crate::Confidence) and the register's generic
/// `MongoExtract` row for [`Confidence`](crate::Confidence) already covers it — an out-of-domain
/// double is refused the same way any other confidence's is. Nothing new is written for this key;
/// it is read exactly as a bare `Score` column would be.