Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: implementation of xsd:integer() #1281

Open
egonw opened this issue Feb 16, 2024 · 6 comments
Open

feature request: implementation of xsd:integer() #1281

egonw opened this issue Feb 16, 2024 · 6 comments

Comments

@egonw
Copy link

egonw commented Feb 16, 2024

As for example in this Scholia query:

# tool: scholia
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT
  (xsd:integer(?count_) AS ?count)
  (CONCAT("Total chemicals with ", ?description_) AS ?description)
WHERE {
  BIND("haswbstatement:P31=Q113145171|P31=Q59199015" AS ?constraint)
  VALUES (?description_ ?property_query_term) {
    ("or without stereochemistry" "")
    ("fully defined stereochemistry" "P31=Q113145171")
    ("undefined stereochemistry" "P31=Q59199015")
    ("CAS registry number" "P231")
    ("canonical SMILES" "P233")
    ("InChI" "P234")
    ("InChIKey" "P235")
    ("chemical formula" "P274")
    # ("ChEMBL ID" "P592") # limit IDs
    # ("ChemSpider ID" "P661") # limit IDs
    ("PubChem ID" "P662")
    # ("KEGG ID" "P665") # limit IDs
    ("ChEBI ID" "P683")
    ("found in taxon" "P703")
    ("isomeric SMILES" "P2017")
    # ("ZINC ID" "P2084") # limit IDs
    ("crystal structure" "haswbstatement:P3636|P11375")
    ("safety classification and labelling" "P4952")
    ("mass spectrum" "haswbstatement:P4964|P6689")
    # ("SMARTS notation" "P8533") # not for now
    ("NMR spectrum" "P9405")
    # hacky way to get quantity properties.
    ("pKa" "linksto:Property:P1117")
    ("mass" "linksto:Property:P2067")
    ("solubility" "linksto:Property:P2177")
    ("melting point" "linksto:Property:P2101")
    ("boiling point" "linksto:Property:P2102")
    ("electric dipole moment" "linksto:Property:P2201")
    ("ionization energy" "linksto:Property:P2260")
    # ("minimum explosive concentration" "linksto:Property:P2204") # safety
    # ("time-weighted average exposure limit" "linksto:Property:P2404") # safety
    # ("ceiling exposure limit" "linksto:Property:P2405") # safety
    # ("maximum peak exposure limit" "linksto:Property:P2406") # safety
    # ("short-term exposure limit" "linksto:Property:P2407") # safety
    # ("solubility product constant" "linksto:Property:P11813") # less than 5 statements
  }
  BIND(CONCAT(?property_query_term, " ", ?constraint) AS ?search_query)
  SERVICE wikibase:mwapi {
    bd:serviceParam wikibase:endpoint "www.wikidata.org" ; 
                    wikibase:api "Search" ; 
                    wikibase:limit "once" ; 
                    mwapi:srsearch ?search_query;
                    mwapi:srlimit "1".
    ?count_ wikibase:apiOutput "//searchinfo[1]/@totalhits".
  }
}
ORDER BY DESC(?count)
@hannahbast
Copy link
Member

@egonw Thanks for the example query. Can you explain the use/need of xsd:integer here`? There are three questions:

  1. Why xsd:integer (which stands for integers of arbitrary size, rarely needed) and not xsd:int (integers with normal 8-byte precision)?
  2. Why any conversion at all? Is the ?count_ returned by the SERVICE clause a string?
  3. What does the SERVICE query do? it does not work, even on the WSQD: try it.

@egonw
Copy link
Author

egonw commented Feb 17, 2024

Can you explain the use/need of xsd:integer here`?

No, but the first sounds arbitrary. The wikibase:mwapi is using a special index, making it faster enough, and can possibly be removed from the Qlever version, being much faster.

I only filed it because the methods was not implemented and someone else also asked about it. I have started generalizing the Scholia code to run on the Qlever Wikidata endpoint, but running into a mix of issues.

Do you have an overview of things not implemented yet, but known? So that I know it's on your team's radar already?

@egonw
Copy link
Author

egonw commented Feb 17, 2024

  1. What does the SERVICE query do? it does not work, even on the WDQS

It does, not before the filling in of the search_query value, a combination of a property and the haswbstatement:P31=Q113145171|P31=Q59199015 value. So, for example like this.

@joka921
Copy link
Member

joka921 commented May 3, 2024

#1332 Was just merged, which adds the functions xsd:int[eger] that convert strings to ints.
They will currently however wrongly convert values that are already numeric to undefined, so I am leaving this issue open for now, until these functions are fully implemented.

@1ec5
Copy link

1ec5 commented May 20, 2024

Did #1332 regress? I’m getting this error when querying for places and their populations in OSM:

Not supported: Function "<http://www.w3.org/2001/XMLSchema#int>" is currently not supported by QLever.

@hannahbast
Copy link
Member

hannahbast commented May 20, 2024

@1ec5 I have built a new index over the weekend (for the latest planet-240513.osm.pbf) and inadvertently started it with a version of QLever from a month ago. It's now the latest version again. Thanks for pointing this out to us.

PS: We are currently running some experiments on the machine hosting https://qlever.cs.uni-freiburg.de/osm-planet . So queries will be slower than usual for some periods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants