mdld-parse 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -1
- package/dist/.nojekyll +0 -0
- package/dist/CNAME +1 -0
- package/dist/README.md +425 -0
- package/dist/docs/API.md +397 -0
- package/dist/docs/Architecture.md +190 -0
- package/dist/docs/Guide.md +322 -0
- package/dist/docs/LLM-MDLD-Inducer.md +550 -0
- package/dist/docs/Parser.md +654 -0
- package/dist/docs/Performance.md +238 -0
- package/dist/docs/Spec-render.md +1439 -0
- package/dist/docs/Subject.md +180 -0
- package/dist/docs/Syntax.md +463 -0
- package/dist/docs/TodoList.md +215 -0
- package/dist/docs/Use-Cases.md +354 -0
- package/dist/docs/index.html +108 -0
- package/dist/docs/index.md +56 -0
- package/dist/docs/origin.md +459 -0
- package/dist/docs/polarity.md +586 -0
- package/dist/docs/primary-subject.md +199 -0
- package/dist/docs/statements.md +226 -0
- package/dist/docs/tokenization-performance-report.md +164 -0
- package/dist/examples/Cookbook.md +32 -0
- package/dist/examples/Status-SHACL.md +33 -0
- package/dist/examples/demo/index.md +35 -0
- package/dist/examples/demo/journal.md +18 -0
- package/dist/examples/demo/minimal.md +11 -0
- package/dist/examples/demo/project.md +15 -0
- package/dist/examples/demo/recipe.md +31 -0
- package/dist/examples/demo/research.md +46 -0
- package/dist/examples/demo/space-mission.md +48 -0
- package/dist/examples/dogfood.md +288 -0
- package/dist/examples/few-shot.md +309 -0
- package/dist/examples/graph/rdf-graph.html +473 -0
- package/dist/examples/graph/rdf_force_graph_web_component.html +506 -0
- package/dist/examples/index.md +45 -0
- package/dist/examples/llm-time-workflow.md +173 -0
- package/dist/examples/prov-o.md +2367 -0
- package/dist/examples/rdf.md +827 -0
- package/dist/examples/shacl.md +3399 -0
- package/dist/examples/statements.md +43 -0
- package/dist/examples/workflow.md +150 -0
- package/dist/index.html +2827 -0
- package/dist/index.js +1548 -0
- package/dist/logo.svg +7 -0
- package/dist/spec/Spec-compact.md +363 -0
- package/dist/spec/Spec-ultra.md +221 -0
- package/dist/spec/Spec.md +1068 -0
- package/dist/spec/index.md +46 -0
- package/package.json +13 -8
- package/src/constants.js +0 -31
- package/src/generate.js +0 -245
- package/src/index.js +0 -13
- package/src/locate.js +0 -23
- package/src/merge.js +0 -157
- package/src/parse.js +0 -765
- package/src/render.js +0 -576
- package/src/shared.js +0 -577
- package/src/utils.js +0 -430
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
# MDLD Few-Shot Induction
|
|
2
|
+
|
|
3
|
+
## MENTAL MODEL
|
|
4
|
+
|
|
5
|
+
Annotations generate RDF triples.
|
|
6
|
+
Text outside annotations is free form and is ignored by the graph.
|
|
7
|
+
Subject context persists until next {=...} declaration or explicit `{=}` reset marker
|
|
8
|
+
|
|
9
|
+
## STRICT GRAMMAR
|
|
10
|
+
```
|
|
11
|
+
Prefixes:
|
|
12
|
+
[my] <tag:myemail@example.com,2026:>
|
|
13
|
+
[folded] <my:folded:>
|
|
14
|
+
|
|
15
|
+
Subjects:
|
|
16
|
+
=IRI # Full IRI, persists
|
|
17
|
+
=#fragment # Relative to current subject, replaces current fragment
|
|
18
|
+
|
|
19
|
+
Predicates:
|
|
20
|
+
p # Literal property
|
|
21
|
+
?p # Object property
|
|
22
|
+
!p # Reverse property
|
|
23
|
+
|
|
24
|
+
Objects:
|
|
25
|
+
+iri # Object for local ?/! predicates
|
|
26
|
+
+#fragment # Soft fragment, replaces current fragment
|
|
27
|
+
|
|
28
|
+
Classes:
|
|
29
|
+
.Class # S rdf:type schema:Class
|
|
30
|
+
|
|
31
|
+
Inline value carriers:
|
|
32
|
+
[value] # Literal span
|
|
33
|
+
**value** # Bold span
|
|
34
|
+
`value` # Code span
|
|
35
|
+
[value](url) # Link
|
|
36
|
+
 # Image
|
|
37
|
+
|
|
38
|
+
Block value carriers:
|
|
39
|
+
```value``` # Code block
|
|
40
|
+
> value # Quote
|
|
41
|
+
# value # Headings
|
|
42
|
+
- value # List item
|
|
43
|
+
|
|
44
|
+
Datatypes:
|
|
45
|
+
^^datatypeIRI # Typed data
|
|
46
|
+
@lang # Language tag
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## RULES
|
|
50
|
+
|
|
51
|
+
- {=IRI} sets subject
|
|
52
|
+
- {+IRI} introduces object
|
|
53
|
+
- ?p forward object property
|
|
54
|
+
- !p inverse property
|
|
55
|
+
- literals come only from value carriers
|
|
56
|
+
|
|
57
|
+
## Invariants (strict)
|
|
58
|
+
|
|
59
|
+
- Every triple must come from an annotation
|
|
60
|
+
- Every literal must come from a value carrier
|
|
61
|
+
- {=} always sets the current subject
|
|
62
|
+
- {+IRI} creates a new node reference
|
|
63
|
+
- List headers apply only to immediate list items
|
|
64
|
+
- Do not invent predicates or prefixes
|
|
65
|
+
- No blank nodes - all nodes must be IRIs
|
|
66
|
+
- never use example.org prefix - prefer `tag:myemail@example.com,2026:` as per RFC 4151
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
## Default context
|
|
70
|
+
|
|
71
|
+
The following prefixes are assumed available: `rdf`, `rdfs`, `xsd`, `sh`, `prov`.
|
|
72
|
+
|
|
73
|
+
## Examples
|
|
74
|
+
|
|
75
|
+
### Example 0
|
|
76
|
+
|
|
77
|
+
```plaintext
|
|
78
|
+
Alice knows Bob.
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
```ttl
|
|
82
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
|
|
83
|
+
@prefix my: <tag:alice@example.com,2026:>.
|
|
84
|
+
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
|
|
85
|
+
|
|
86
|
+
my:alice foaf:knows my:bob.
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
```mdld
|
|
90
|
+
[my] <tag:alice@example.com,2026:>
|
|
91
|
+
[foaf] <http://xmlns.com/foaf/0.1/>
|
|
92
|
+
|
|
93
|
+
[Alice] {=my:alice} knows [Bob] {+my:bob ?foaf:knows}.
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Example 1
|
|
97
|
+
|
|
98
|
+
```plaintext
|
|
99
|
+
Today was a good day. I was happy and the weather was sunny. I went to Central Park. It felt peaceful and the park was beautiful. I met Sam there. I had my coffee in the morning, so I went straight to dinner.
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
```ttl
|
|
103
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
|
|
104
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
|
|
105
|
+
@prefix my: <tag:alice@example.com,2026:>.
|
|
106
|
+
@prefix j: <tag:alice@example.com,2026:journal:>.
|
|
107
|
+
|
|
108
|
+
j:2026-02-27 a j:Record;
|
|
109
|
+
j:date "2026-02-27"^^xsd:date;
|
|
110
|
+
rdfs:label "A nice day in the park";
|
|
111
|
+
j:mood "happy";
|
|
112
|
+
j:energyLevel 8^^xsd:integer;
|
|
113
|
+
my:location my:central-park;
|
|
114
|
+
my:weather "Sunny";
|
|
115
|
+
j:emotionalState "peaceful";
|
|
116
|
+
j:comment "beautiful";
|
|
117
|
+
j:met my:sam;
|
|
118
|
+
my:central-park a my:Place;
|
|
119
|
+
rdfs:label "Central Park"@en.
|
|
120
|
+
my:sam a my:Person.
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
```mdld
|
|
124
|
+
[my] <tag:alice@example.com,2026:>
|
|
125
|
+
[j] <my:journal:>
|
|
126
|
+
|
|
127
|
+
# 2026-02-27 {=j:2026-02-27 .j:Record j:date ^^xsd:date}
|
|
128
|
+
|
|
129
|
+
## A nice day in the park {label}
|
|
130
|
+
|
|
131
|
+
With a [happy] {j:mood} mood and quite high energy [8] {j:energyLevel ^^xsd:integer} I went to the [Central Park] {+my:central-park ?my:location .my:Place label @en}. The weather was [Sunny] {my:weather}. I felt [peaceful] {j:emotionalState} and the park was [beautiful] {j:comment}.
|
|
132
|
+
|
|
133
|
+
In the park I met [Sam] {+my:sam .my:Person ?j:met}.
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Example 2
|
|
137
|
+
|
|
138
|
+
```plaintext
|
|
139
|
+
Project Alpha has 3 tasks - Design schema, Implement parser and Write documentation.
|
|
140
|
+
Design schema is done, Implement parser is done and Write documentation is in process - we need to add API reference.
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
```ttl
|
|
144
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
|
|
145
|
+
|
|
146
|
+
@prefix ex: <http://example.org/>.
|
|
147
|
+
|
|
148
|
+
ex:ProjectAlpha a ex:Project;
|
|
149
|
+
ex:hasTask <http://example.org/ProjectAlpha#task1>, <http://example.org/ProjectAlpha#task2>, <http://example.org/ProjectAlpha#task3>.
|
|
150
|
+
<http://example.org/ProjectAlpha#task1> a ex:Task;
|
|
151
|
+
rdfs:label "Design schema";
|
|
152
|
+
ex:status ex:done.
|
|
153
|
+
<http://example.org/ProjectAlpha#task2> a ex:Task;
|
|
154
|
+
rdfs:label "Implement parser";
|
|
155
|
+
ex:status ex:done.
|
|
156
|
+
<http://example.org/ProjectAlpha#task3> a ex:Task;
|
|
157
|
+
rdfs:label "Write documentation";
|
|
158
|
+
ex:subTask <http://example.org/ProjectAlpha#subtask3a>;
|
|
159
|
+
ex:status ex:in-process.
|
|
160
|
+
<http://example.org/ProjectAlpha#subtask3a> a ex:Task;
|
|
161
|
+
rdfs:label "API reference";
|
|
162
|
+
ex:status ex:todo.
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
```mdld
|
|
168
|
+
[ex] <http://example.org/>
|
|
169
|
+
|
|
170
|
+
# Project Alpha {=ex:ProjectAlpha .ex:Project}
|
|
171
|
+
|
|
172
|
+
Project includes tasks: {}
|
|
173
|
+
|
|
174
|
+
- Design schema {+#task1 ?ex:hasTask .ex:Task label}
|
|
175
|
+
- Implement parser {+#task2 ?ex:hasTask .ex:Task label}
|
|
176
|
+
- Write documentation {=#task3 ?ex:hasTask .ex:Task label}
|
|
177
|
+
with a subtask of {}
|
|
178
|
+
- API reference {+#subtask3a ?ex:subTask .ex:Task label}
|
|
179
|
+
|
|
180
|
+
# Tasks
|
|
181
|
+
|
|
182
|
+
**Design schema** {=#task1} is [ready] {?ex:status +ex:done}, **parser** {=#task2} is also [done] {?ex:status +ex:done}, but **documentation** {=#task3} is still [in process] {?ex:status +ex:in-process} - we are starting documenting the **API** {=#subtask3a} - it's still a [to do] {?ex:status +ex:todo}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Example 3
|
|
186
|
+
|
|
187
|
+
```plaintext
|
|
188
|
+
A lab observation recording a firmware update and resulting system state performed by Dr. Lena Ortiz.
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
```ttl
|
|
192
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
|
|
193
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
|
|
194
|
+
@prefix prov: <http://www.w3.org/ns/prov#>.
|
|
195
|
+
@prefix lab: <tag:lab@example.com,2026:>.
|
|
196
|
+
|
|
197
|
+
lab:obsLab1 a rdf:Statement, prov:Entity;
|
|
198
|
+
rdf:subject lab:calibBot;
|
|
199
|
+
rdf:predicate lab:performedUpdate;
|
|
200
|
+
rdf:object lab:spectrometerFW;
|
|
201
|
+
lab:confidence 0.97;
|
|
202
|
+
prov:wasGeneratedBy lab:actLab1.
|
|
203
|
+
lab:obsLab2 a rdf:Statement, prov:Entity;
|
|
204
|
+
rdf:subject lab:spectrometerFW;
|
|
205
|
+
rdf:predicate lab:hasStatus;
|
|
206
|
+
rdf:object lab:stable;
|
|
207
|
+
lab:confidence 0.90;
|
|
208
|
+
prov:wasGeneratedBy lab:actLab1.
|
|
209
|
+
lab:actLab1 a prov:Activity;
|
|
210
|
+
prov:wasAssociatedWith lab:lenaOrtiz;
|
|
211
|
+
prov:endedAtTime "2026-02-18T06:42:00Z"^^xsd:dateTime.
|
|
212
|
+
lab:lenaOrtiz a prov:Agent.
|
|
213
|
+
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
```mdld
|
|
217
|
+
[lab] <tag:lab@example.com,2026:>
|
|
218
|
+
|
|
219
|
+
# Lab journal
|
|
220
|
+
|
|
221
|
+
## System update {=lab:obsLab1 .rdf:Statement .prov:Entity}
|
|
222
|
+
|
|
223
|
+
While reviewing the overnight logs, I confirmed that [the calibration bot] {+lab:calibBot ?rdf:subject} successfully [updated] {+lab:performedUpdate ?rdf:predicate} the [spectrometer firmware] {+lab:spectrometerFW ?rdf:object}.
|
|
224
|
+
The change looked routine, but I still recorded the provenance carefully. I assign a confidence of [0.97] {lab:confidence ^^xsd:decimal} to this observation.
|
|
225
|
+
|
|
226
|
+
## System status {=lab:obsLab2 .rdf:Statement .prov:Entity}
|
|
227
|
+
|
|
228
|
+
I also noted that the [spectrometer firmware] {+lab:spectrometerFW ?rdf:subject} remained in [stable condition] {+lab:stable ?rdf:object} according to the [reported status] {+lab:hasStatus ?rdf:predicate}. I assign a confidence of [0.90] {lab:confidence ^^xsd:decimal} to this observation.
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
## Verification activity {=lab:actLab1 .prov:Activity}
|
|
232
|
+
|
|
233
|
+
Has 2 observations stated:
|
|
234
|
+
- System update {+lab:obsLab1 !prov:wasGeneratedBy}
|
|
235
|
+
- System status {+lab:obsLab2 !prov:wasGeneratedBy}
|
|
236
|
+
|
|
237
|
+
The check was performed by [Dr. Lena Ortiz] {+lab:lenaOrtiz .prov:Agent ?prov:wasAssociatedWith} during the early shift, finishing at [2026-02-18T06:42:00Z] {prov:endedAtTime ^^xsd:dateTime}.
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
### Example 4
|
|
242
|
+
|
|
243
|
+
```plaintext
|
|
244
|
+
A product validation SHACL shape defining mandatory name and positive price.
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
```ttl
|
|
248
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
|
|
249
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
|
|
250
|
+
@prefix sh: <http://www.w3.org/ns/shacl#>.
|
|
251
|
+
@prefix ex: <http://example.org/>.
|
|
252
|
+
|
|
253
|
+
ex:ProductValidationShape a sh:NodeShape;
|
|
254
|
+
rdfs:label "Product Validation Shape";
|
|
255
|
+
sh:targetClass ex:Product;
|
|
256
|
+
sh:property <http://example.org/#productName>, <http://example.org/#productPrice>.
|
|
257
|
+
<http://example.org/#productName> a sh:PropertyShape;
|
|
258
|
+
sh:path rdfs:label;
|
|
259
|
+
sh:minCount 1^^xsd:integer;
|
|
260
|
+
sh:maxCount 1^^xsd:integer;
|
|
261
|
+
sh:message "Product must have exactly one label".
|
|
262
|
+
<http://example.org/#productPrice> a sh:PropertyShape;
|
|
263
|
+
sh:path ex:price;
|
|
264
|
+
sh:message "Product price must be positive";
|
|
265
|
+
sh:minInclusive 0.01^^xsd:decimal.
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
```mdld
|
|
269
|
+
[ex] <http://example.org/>
|
|
270
|
+
|
|
271
|
+
The **Product Validation Shape** {=ex:ProductValidationShape .sh:NodeShape label} targets all [Products] {+ex:Product ?sh:targetClass} to validate core product requirements.
|
|
272
|
+
|
|
273
|
+
**Product Name Rule** {=ex:#productName .sh:PropertyShape ?sh:property} requires the [label] {+label ?sh:path} property to have exactly [1] {sh:minCount sh:maxCount ^^xsd:integer} value.
|
|
274
|
+
|
|
275
|
+
> Product must have exactly one label {sh:message}
|
|
276
|
+
|
|
277
|
+
We MUST repeat the subject for the second propertyShape to connect to the shape via ?sh:property - always rememeber about subject chaining:
|
|
278
|
+
|
|
279
|
+
{=ex:ProductValidationShape}
|
|
280
|
+
|
|
281
|
+
**Product Price Rule** {=ex:#productPrice .sh:PropertyShape ?sh:property} that requires the [price] {+ex:price ?sh:path} property to be at least [0.01] {sh:minInclusive ^^xsd:decimal}
|
|
282
|
+
|
|
283
|
+
> Product price must be positive {sh:message}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## ❌ Invalid patterns
|
|
287
|
+
|
|
288
|
+
INVALID:
|
|
289
|
+
`{ex:energy "8"^^xsd:integer}`
|
|
290
|
+
|
|
291
|
+
VALID:
|
|
292
|
+
`[8] {ex:energy ^^xsd:integer}`
|
|
293
|
+
|
|
294
|
+
## Pattern Summary:
|
|
295
|
+
|
|
296
|
+
Literal:
|
|
297
|
+
[value] {predicate}
|
|
298
|
+
|
|
299
|
+
Object:
|
|
300
|
+
[value] {+IRI ?predicate}
|
|
301
|
+
|
|
302
|
+
Statement:
|
|
303
|
+
{=stmt .rdf:Statement}
|
|
304
|
+
[A] {+S ?rdf:subject} [B] {+P ?rdf:predicate} [C] {+O ?rdf:object}
|
|
305
|
+
|
|
306
|
+
Activity:
|
|
307
|
+
{=act .prov:Activity}
|
|
308
|
+
[Agent] {+A .prov:Agent ?prov:wasAssociatedWith}
|
|
309
|
+
[time] {prov:endedAtTime ^^xsd:dateTime}
|