RDF Validation Deployment commited on
Commit
c14e337
Β·
1 Parent(s): 954b0c9

Update RDF examples, move Examples section to top, and use handcuff emoji for SHACL theme

Browse files

- Fixed SAMPLE_VALID_RDF with complete Work+Instance structure
- Fixed SAMPLE_INVALID_RDF to trigger SHACL violations without XML errors
- Moved Examples & Tools section from bottom to top for better UX
- Changed emoji from πŸ” to πŸ”— (handcuffs) as clever SHACL/shackle pun
- Updated app title to use handcuff emoji theme

Files changed (2) hide show
  1. README.md +1 -1
  2. app.py +77 -19
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
  title: Mcp4rdf
3
- emoji: πŸš€
4
  colorFrom: blue
5
  colorTo: purple
6
  sdk: gradio
 
1
  ---
2
  title: Mcp4rdf
3
+ emoji: πŸ”—
4
  colorFrom: blue
5
  colorTo: purple
6
  sdk: gradio
app.py CHANGED
@@ -106,33 +106,92 @@ def get_openai_client():
106
  SAMPLE_VALID_RDF = '''<?xml version="1.0" encoding="UTF-8"?>
107
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
108
  xmlns:bf="http://id.loc.gov/ontologies/bibframe/"
 
109
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
110
 
111
  <bf:Work rdf:about="http://example.org/work/1">
112
  <rdf:type rdf:resource="http://id.loc.gov/ontologies/bibframe/Text"/>
113
  <bf:title>
114
  <bf:Title>
115
- <bf:mainTitle>Sample Monograph Title</bf:mainTitle>
 
116
  </bf:Title>
117
  </bf:title>
118
  <bf:creator>
119
  <bf:Agent>
120
- <rdfs:label>Sample Author</rdfs:label>
 
121
  </bf:Agent>
122
  </bf:creator>
 
 
 
 
 
 
 
 
 
123
  </bf:Work>
124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  </rdf:RDF>'''
126
 
127
  SAMPLE_INVALID_RDF = '''<?xml version="1.0" encoding="UTF-8"?>
128
- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
129
- <!-- Missing namespace declarations -->
130
- <!-- Missing required properties -->
 
131
  <bf:Work rdf:about="http://example.org/work/1">
132
- <bf:title>Incomplete Title</bf:title>
133
- <!-- Missing rdf:type -->
134
- <!-- Missing proper title structure -->
 
 
 
 
135
  </bf:Work>
 
 
 
 
 
 
 
 
 
 
 
 
136
  </rdf:RDF>'''
137
 
138
  # MCP Server Tools (can be used independently)
@@ -516,7 +575,7 @@ def create_interface():
516
 
517
  gr.HTML(f"""
518
  <div class="header-text">
519
- <h1>πŸ” RDF Validation Server with AI</h1>
520
  <p>Validate RDF/XML against SHACL schemas with AI-powered suggestions and corrections</p>
521
  <p><strong>Status:</strong> {api_status}</p>
522
  <details><summary>Debug Info</summary><pre>{debug_info}</pre></details>
@@ -550,6 +609,15 @@ def create_interface():
550
  )
551
 
552
  validate_btn = gr.Button("πŸ” Validate RDF", variant="primary", size="lg")
 
 
 
 
 
 
 
 
 
553
 
554
  # Results section
555
  with gr.Row():
@@ -590,16 +658,6 @@ def create_interface():
590
  placeholder="Corrected RDF will appear here after validation..."
591
  )
592
 
593
- # Examples and controls
594
- with gr.Row():
595
- gr.Markdown("### πŸ“š Examples & Tools")
596
-
597
- with gr.Row():
598
- example1_btn = gr.Button("βœ… Valid RDF Example", variant="secondary")
599
- example2_btn = gr.Button("❌ Invalid RDF Example", variant="secondary")
600
- example3_btn = gr.Button("πŸ“– BibFrame Example", variant="secondary")
601
- clear_btn = gr.Button("πŸ—‘οΈ Clear All", variant="stop")
602
-
603
  # Event handlers
604
  validate_btn.click(
605
  fn=validate_rdf_interface,
 
106
  SAMPLE_VALID_RDF = '''<?xml version="1.0" encoding="UTF-8"?>
107
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
108
  xmlns:bf="http://id.loc.gov/ontologies/bibframe/"
109
+ xmlns:bflc="http://id.loc.gov/ontologies/bflc/"
110
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
111
 
112
  <bf:Work rdf:about="http://example.org/work/1">
113
  <rdf:type rdf:resource="http://id.loc.gov/ontologies/bibframe/Text"/>
114
  <bf:title>
115
  <bf:Title>
116
+ <bf:mainTitle>Complete Valid Monograph Title</bf:mainTitle>
117
+ <bf:subtitle>A Comprehensive Example for SHACL Validation</bf:subtitle>
118
  </bf:Title>
119
  </bf:title>
120
  <bf:creator>
121
  <bf:Agent>
122
+ <rdf:type rdf:resource="http://id.loc.gov/ontologies/bibframe/Person"/>
123
+ <rdfs:label>Valid Author Name</rdfs:label>
124
  </bf:Agent>
125
  </bf:creator>
126
+ <bf:subject>
127
+ <bf:Topic>
128
+ <rdfs:label>Library Science</rdfs:label>
129
+ </bf:Topic>
130
+ </bf:subject>
131
+ <bf:language>
132
+ <bf:Language rdf:about="http://id.loc.gov/vocabulary/languages/eng"/>
133
+ </bf:language>
134
+ <bf:hasInstance rdf:resource="http://example.org/instance/1"/>
135
  </bf:Work>
136
 
137
+ <bf:Instance rdf:about="http://example.org/instance/1">
138
+ <rdf:type rdf:resource="http://id.loc.gov/ontologies/bibframe/Print"/>
139
+ <bf:instanceOf rdf:resource="http://example.org/work/1"/>
140
+ <bf:title>
141
+ <bf:Title>
142
+ <bf:mainTitle>Complete Valid Monograph Title</bf:mainTitle>
143
+ </bf:Title>
144
+ </bf:title>
145
+ <bf:provisionActivity>
146
+ <bf:Publication>
147
+ <bf:date>2024</bf:date>
148
+ <bf:place>
149
+ <bf:Place>
150
+ <rdfs:label>Washington, DC</rdfs:label>
151
+ </bf:Place>
152
+ </bf:place>
153
+ <bf:agent>
154
+ <bf:Agent>
155
+ <rdfs:label>Sample Publisher</rdfs:label>
156
+ </bf:Agent>
157
+ </bf:agent>
158
+ </bf:Publication>
159
+ </bf:provisionActivity>
160
+ <bf:extent>
161
+ <bf:Extent>
162
+ <rdfs:label>256 pages</rdfs:label>
163
+ </bf:Extent>
164
+ </bf:extent>
165
+ </bf:Instance>
166
+
167
  </rdf:RDF>'''
168
 
169
  SAMPLE_INVALID_RDF = '''<?xml version="1.0" encoding="UTF-8"?>
170
+ <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
171
+ xmlns:bf="http://id.loc.gov/ontologies/bibframe/"
172
+ xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
173
+
174
  <bf:Work rdf:about="http://example.org/work/1">
175
+ <!-- Missing rdf:type - this should cause SHACL validation failure -->
176
+ <bf:title>
177
+ <!-- Missing bf:Title wrapper - improper title structure -->
178
+ <bf:mainTitle>Invalid Monograph Title Structure</bf:mainTitle>
179
+ </bf:title>
180
+ <!-- Missing required bf:creator property -->
181
+ <!-- Missing other required properties like bf:language -->
182
  </bf:Work>
183
+
184
+ <bf:Instance rdf:about="http://example.org/instance/1">
185
+ <rdf:type rdf:resource="http://id.loc.gov/ontologies/bibframe/Print"/>
186
+ <!-- Missing bf:instanceOf property - should link to Work -->
187
+ <bf:title>
188
+ <bf:Title>
189
+ <bf:mainTitle>Invalid Instance Title</bf:mainTitle>
190
+ </bf:Title>
191
+ </bf:title>
192
+ <!-- Missing required bf:provisionActivity -->
193
+ </bf:Instance>
194
+
195
  </rdf:RDF>'''
196
 
197
  # MCP Server Tools (can be used independently)
 
575
 
576
  gr.HTML(f"""
577
  <div class="header-text">
578
+ <h1>πŸ”— RDF Validation Server with AI</h1>
579
  <p>Validate RDF/XML against SHACL schemas with AI-powered suggestions and corrections</p>
580
  <p><strong>Status:</strong> {api_status}</p>
581
  <details><summary>Debug Info</summary><pre>{debug_info}</pre></details>
 
609
  )
610
 
611
  validate_btn = gr.Button("πŸ” Validate RDF", variant="primary", size="lg")
612
+
613
+ # Examples and controls
614
+ gr.Markdown("### πŸ“š Examples & Tools")
615
+
616
+ with gr.Row():
617
+ example1_btn = gr.Button("βœ… Valid RDF Example", variant="secondary")
618
+ example2_btn = gr.Button("❌ Invalid RDF Example", variant="secondary")
619
+ example3_btn = gr.Button("πŸ“– BibFrame Example", variant="secondary")
620
+ clear_btn = gr.Button("πŸ—‘οΈ Clear All", variant="stop")
621
 
622
  # Results section
623
  with gr.Row():
 
658
  placeholder="Corrected RDF will appear here after validation..."
659
  )
660
 
 
 
 
 
 
 
 
 
 
 
661
  # Event handlers
662
  validate_btn.click(
663
  fn=validate_rdf_interface,