Main Page: Difference between revisions

From wikibase
Tag: Reverted
No edit summary
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
<strong>Bienvenue sur le référentiel des <i>Bibliothèques Virtuelles Humanistes</i>.</strong>
<strong>Bienvenue sur le référentiel des <i>Bibliothèques Virtuelles Humanistes</i>.</strong>
=== Statistiques des entités ===
=== Statistiques des entités ===
<div id="entity-counts-container" style="background: #f0f8ff; padding: 15px; border: 1px solid #add8e6; border-radius: 5px; margin: 10px 0;">
    Chargement des statistiques...
</div>
<script>
// Liste des types d'entités à compter
const entityTypes = ["Q2", "Q5", "Q6", "Q7", "Q8"];
const results = {};
const apiUrl = window.location.origin + "/w/api.php";
// Fonction pour compter les entités via wbgetentities
async function countEntities() {
    const container = document.getElementById('entity-counts-container');
    if (!container) {
        console.error("Conteneur introuvable !");
        return;
    }
    // Étape 1: Récupérer toutes les entités dans le namespace Item (ID: 120)
    const allPagesUrl = `${apiUrl}?action=query&list=allpages&apnamespace=120&aplimit=500&format=json`;
    const allPagesResponse = await fetch(allPagesUrl);
    const allPagesData = await allPagesResponse.json();
    const entityIds = [];
    if (allPagesData.query?.allpages) {
        allPagesData.query.allpages.forEach(page => {
            const match = page.title.match(/^Item:(Q\d+)$/);
            if (match) entityIds.push(match[1]);
        });
    }
    if (entityIds.length === 0) {
        container.innerHTML = "<p style='color: orange;'>Aucune entité trouvée dans le namespace Item (ID: 120).</p>";
        return;
    }
    container.innerHTML = `<p>Trouvé ${entityIds.length} entités. Comptage en cours...</p>`;
    // Étape 2: Compter les entités par type (P1)
    const counts = {};
    entityTypes.forEach(type => counts[type] = 0);
    // Traiter par lots de 50 (limite de wbgetentities)
    for (let i = 0; i < entityIds.length; i += 50) {
        const batch = entityIds.slice(i, i + 50);
        const batchUrl = `${apiUrl}?action=wbgetentities&ids=${batch.join('|')}&format=json&props=claims`;
        const batchResponse = await fetch(batchUrl);
        const batchData = await batchResponse.json();
        if (batchData.entities) {
            for (const [id, entity] of Object.entries(batchData.entities)) {
                if (entity.claims?.P1) {
                    entity.claims.P1.forEach(claim => {
                        const targetId = claim.mainsnak?.datavalue?.value?.id;
                        if (targetId && entityTypes.includes(targetId)) {
                            counts[targetId]++;
                        }
                    });
                }
            }
        }
    }
    // Afficher les résultats
    let html = '<ul style="list-style: none; padding: 0; margin: 0;">';
    for (const [type, count] of Object.entries(counts)) {
        html += `<li style="margin: 5px 0;"><b>Type ${type}:</b> ${count} éléments</li>`;
    }
    const total = Object.values(counts).reduce((a, b) => a + b, 0);
    html += `<li style="margin: 5px 0; font-weight: bold;"><b>Total:</b> ${total} éléments</li></ul>`;
    container.innerHTML = html;
}
// Lancer le comptage quand la page est chargée
document.addEventListener('DOMContentLoaded', countEntities);
</script>


== Consulter le référentiel ==
== Consulter le référentiel ==
* [[Special:ListProperties|Propriétés]]
* [[Special:ListProperties|Propriétés]]
* [[Special:AllPages| Entités]]
* [[Special:AllPages| Entités]]
* [https://query.bvh.univ-tours.fr/embed.html#SELECT%20%3FCategorie%20%28COUNT%28%3Fitem%29%20AS%20%3FNombre%29%0AWHERE%20%7B%0A%20%20VALUES%20%28%3Ftype%20%3FCategorie%29%20%7B%0A%20%20%20%20%28wd%3AQ6%20%22Personnes%22%29%0A%20%20%20%20%28wd%3AQ7%20%22Collectivit%C3%A9s%22%29%0A%20%20%20%20%28wd%3AQ8%20%22Familles%22%29%0A%20%20%20%20%28wd%3AQ2%20%22Lieux%22%29%0A%20%20%20%20%28wd%3AQ5%20%22Agents%22%29%0A%20%20%7D%0A%0A%20%20%3Fitem%20wdt%3AP1%20%3Ftype%20.%0A%7D%0AGROUP%20BY%20%3FCategorie Décomptes]
* [[Requetes_sparql | Requêtes SPARQL]]
* [[Requetes_sparql | Requêtes SPARQL]]



Latest revision as of 08:08, 20 May 2026

Bienvenue sur le référentiel des Bibliothèques Virtuelles Humanistes.

Consulter le référentiel

Contribuer au référentiel

Démarrer avec Wikibase

Consult the User's Guide for information on using the wiki software.