Hauptseite
Aus SemanticGlossar
This wiki demonstrates possibilities and benefits of semantically annotated texts, specifically for the IPCC AR6 climate report. Use the table below to identify relevant texts via the word clouds or search for a text.
Text | Keywords | Wikibase | Total annotations |
---|---|---|---|
intro | Item:Q2322 | 112 | |
responses | Item:Q2436 | 212 | |
impacts | Item:Q2651 | 123 |
Textanzeige
Analytics
<html lang="en"> <head>
<meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Add Item to Wikibase</title> <script> async function getCsrfToken() { const apiUrl = 'http://swb.local/api.php'; // Replace with your Wikibase API URL
// Log in if required (replace with actual credentials) const loginData = new URLSearchParams(); loginData.append('action', 'login'); loginData.append('lgname', 'wkadmin'); // Replace with your username loginData.append('lgpassword', '7kKq4gxBtV'); // Replace with your password loginData.append('format', 'json');
await fetch(apiUrl, { method: 'POST', body: loginData, headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, credentials: 'include' // Include cookies in the request });
// Get the CSRF token const tokenData = new URLSearchParams(); tokenData.append('action', 'query'); tokenData.append('meta', 'tokens'); tokenData.append('format', 'json');
const response = await fetch(apiUrl + '?' + tokenData.toString(), { method: 'GET', credentials: 'include' // Include cookies in the request });
const data = await response.json(); return data.query.tokens.csrftoken; }
async function addItem(event) { event.preventDefault();
const name = document.getElementById('name').value; const description = document.getElementById('description').value; const subCategoryOf = document.getElementById('subCategoryOf').value; const token = await getCsrfToken();
const apiUrl = 'http://swb.local/api.php?action=wbeditentity&new=item&format=json'; // Replace with your Wikibase API URL
const formData = new URLSearchParams(); formData.append('action', 'wbeditentity'); //formData.append('new', 'item'); formData.append('token', token); formData.append('format', 'json');
formData.append('data', JSON.stringify( { "labels":{"en":{"language":"en","value":"term_"+name}}, "descriptions":{"en":{"language":"en","value":description}},"datatype":"string", "claims":[ {"mainsnak":{"snaktype":"value","property":"P3","datavalue":{"value":name,"type":"string"}},"type":"statement","rank":"normal"}, {"mainsnak":{"snaktype":"value","property":"P1","datavalue":{"value":"Term","type":"string"}},"type":"statement","rank":"normal"}, {"mainsnak":{"snaktype":"value","property":"P10","datavalue": {"value": {"entity-type": "item","id": subCategoryOf},"type": "wikibase-entityid"}},"type": "statement","rank": "normal"} ] }
));
try { const response = await fetch(apiUrl, { method: 'POST', body: formData, headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, credentials: 'include' // Include cookies in the request });
const data = await response.json(); if (data.success) { alert('Item added successfully!'); } else { alert('Error adding item: ' + JSON.stringify(data)); } } catch (error) { alert('Error: ' + error.message); } } </script>
</head> <body>
Add Item to Wikibase
<form id="addItemForm" onsubmit="addItem(event)"> <input type="text" id="name" name="name" required>
<input type="text" id="description" name="description" required>
<select id="subCategoryOf" name="subCategoryOf" required> <option value="term_term">Term</option> <option value="Q940">Acronym</option> <option value="term_qualifier">Qualifier</option> </select>
<input type="submit" value="Add Item"> </form>
</body> </html>