Test: Difference between revisions

From MaRDI portal
No edit summary
No edit summary
Line 6: Line 6:


{{#sparql:
{{#sparql:
SELECT ?a ?b ?c WHERE {
PREFIX mdb: <https://mardi4nfdi.de/mathmoddb#>
  ?a wdt:P582 wd:Q3842 .
SELECT ?Name ?Unit ?Symbol ?Task (?Type AS ?Dependency_Type) WHERE {
  ?a wdt:P29 ?b .
  # Starting from the central item
  ?a wdt:P3 ?c.
  wd:Q810 wdt:P557 ?centralItem .
  ?centralItem wdt:P31 wd:Q68663;
                wdt:P188 ?url;
                rdfs:label ?Label.
 
  # Service query to get tasks and connect them to quantities
  SERVICE <https://sparql.mtsr2024.m1.mardi.ovh/mathalgodb/query> {
        ?url mdb:appliedByTask ?task .
        ?task rdfs:label ?Task .
       
        # Define type based on connection type (Input or Output)
        {
            ?task mdb:containsInput ?item .
            ?item rdfs:label ?Name .
            BIND("independent" AS ?Type)
        }
        UNION
        {
            ?task mdb:containsOutput ?item .
            ?item rdfs:label ?Name .
            BIND("dependent" AS ?Type)
        }
       
        # Filter results to only show defining statements that match the current quantity label
        OPTIONAL {
            ?task mdb:containsFormulation ?formulation .
            ?formulation mdb:inDefiningFormulation ?definingStatement .
 
            # Convert definingStatement to a plain string to strip off datatype markup
            BIND(STR(?definingStatement) AS ?plainStatement)
 
            # Clean up spaces around commas, making the format consistent
            BIND(REPLACE(?plainStatement, "\\s*,\\s*", ",") AS ?cleanedStatement)
 
            # Extract symbol and quantity label
            BIND(STRBEFORE(?cleanedStatement, ",") AS ?Symbolraw)
            BIND(STRAFTER(?cleanedStatement, ",") AS ?quantityLabel)
           
            BIND(REPLACE(?Symbolraw, "\\$", "") AS ?cleanSymbol)
            BIND(CONCAT("&lt;math&gt;", ?cleanSymbol, "&lt;/math&gt;") AS ?Symbol)
         
        }
        BIND(STR(?Name) AS ?plainItemLabel)
        FILTER(?quantityLabel = ?plainItemLabel)     
       
    }
    # Initialize the Unit variable as empty
    BIND("" AS ?Unit)
}
}
LIMIT 3
ORDER BY ?taskLabel ?itemLabel
| templates=Test
| chart=bordercloud.visualization.DataTable
| chart=bordercloud.visualization.DataTable
}}
}}

Revision as of 12:15, 31 October 2024

Test

E=mc2

{{#sparql: PREFIX mdb: <https://mardi4nfdi.de/mathmoddb#> SELECT ?Name ?Unit ?Symbol ?Task (?Type AS ?Dependency_Type) WHERE {

  # Starting from the central item
  wd:Q810 wdt:P557 ?centralItem .
  ?centralItem wdt:P31 wd:Q68663;
               wdt:P188 ?url;
               rdfs:label ?Label.
  # Service query to get tasks and connect them to quantities
  SERVICE <https://sparql.mtsr2024.m1.mardi.ovh/mathalgodb/query> {
       ?url mdb:appliedByTask ?task .
       ?task rdfs:label ?Task .
       
       # Define type based on connection type (Input or Output)
       {
           ?task mdb:containsInput ?item .
           ?item rdfs:label ?Name .
           BIND("independent" AS ?Type)
       }
       UNION
       {
           ?task mdb:containsOutput ?item .
           ?item rdfs:label ?Name .
           BIND("dependent" AS ?Type)
       }
       
       # Filter results to only show defining statements that match the current quantity label
       OPTIONAL {
           ?task mdb:containsFormulation ?formulation .
           ?formulation mdb:inDefiningFormulation ?definingStatement .
           # Convert definingStatement to a plain string to strip off datatype markup
           BIND(STR(?definingStatement) AS ?plainStatement)
           # Clean up spaces around commas, making the format consistent
           BIND(REPLACE(?plainStatement, "\\s*,\\s*", ",") AS ?cleanedStatement)
           # Extract symbol and quantity label
           BIND(STRBEFORE(?cleanedStatement, ",") AS ?Symbolraw)
           BIND(STRAFTER(?cleanedStatement, ",") AS ?quantityLabel)
           
           BIND(REPLACE(?Symbolraw, "\\$", "") AS ?cleanSymbol)
           BIND(CONCAT("<math>", ?cleanSymbol, "</math>") AS ?Symbol)
          
       }
       BIND(STR(?Name) AS ?plainItemLabel)
       FILTER(?quantityLabel = ?plainItemLabel)       
       
   }
   # Initialize the Unit variable as empty
   BIND("" AS ?Unit)

} ORDER BY ?taskLabel ?itemLabel | chart=bordercloud.visualization.DataTable }}


{{#sparql: select (YEAR(?date) as ?year) (CONCAT('<a href=\,?link,'\'>',?label,'</a>') as ?html) ?video

                   where {
                   ?object wdt:P31 wd:Q11424 ;
                   wdt:P577 ?date ;
                   wdt:P10 ?video ;
                   rdfs:label ?label .
                   FILTER (langMatches(lang(?label), 'fr'))
                   BIND(replace( xsd:string(?object),
                   'http://www.wikidata.org/entity/',
                   'https://www.wikidata.org/wiki/Special:GoToLinkedPage/frwiki/') as ?link)
                   }
                   ORDER BY ASC(?date)
                   LIMIT 5

| config=http://www.wikidata.org | templates= Test | chart=bordercloud.visualization.DataTable }}

{{#sparql: select (YEAR(?date) as ?year) (CONCAT('<a href=\,?link,'\'>',?label,'</a>') as ?html) ?video

                   where {
                   ?object wdt:P31 wd:Q11424 ;
                   wdt:P577 ?date ;
                   wdt:P10 ?video ;
                   rdfs:label ?label .
                   FILTER (langMatches(lang(?label), 'fr'))
                   BIND(replace( xsd:string(?object),
                   'http://www.wikidata.org/entity/',
                   'https://www.wikidata.org/wiki/Special:GoToLinkedPage/frwiki/') as ?link)
                   }
                   ORDER BY ASC(?date)
                   LIMIT 5

| config=http://www.wikidata.org | templates= Test | chart=bordercloud.visualization.DataTable }}

{{#sparql: SELECT ?taskLabel ?description WHERE {

 wd:Q3784 wdt:P847 ?task .
 ?task wdt:P3 wd:Q3843 .
 ?task rdfs:label ?taskLabel .
 ?task schema:description ?description .

} LIMIT 1 | templates=Test | endpoint=http://query.staging.mardi4nfdi.org/proxy/wdqs/bigdata/namespace/wdq/sparql | log=2 }}

{{#sparql: PREFIX : <https://mardi4nfdi.de/mathmoddb#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT DISTINCT ?answer ?label ?quote WHERE {

               ?answer a :MathematicalModel .
               OPTIONAL {?answer rdfs:label ?labelraw .
                                    FILTER (lang(?labelraw) = 'en')}
               BIND(COALESCE(?labelraw, "No Label Provided!") AS ?label)
               OPTIONAL {?answer rdfs:comment ?quoteraw.
                                   FILTER (lang(?quoteraw) = 'en')}
               BIND(COALESCE(?quoteraw, "No Description Provided!") AS ?quote)
              }

GROUP BY ?answer ?label ?quote LIMIT 5 | endpoint=https://sparql.mtsr2024.m1.mardi.ovh/mathalgodb/query | log=2 }}