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

language fall back problem #128

Open
zeginis opened this issue Aug 16, 2018 · 6 comments
Open

language fall back problem #128

zeginis opened this issue Aug 16, 2018 · 6 comments

Comments

@zeginis
Copy link
Contributor

zeginis commented Aug 16, 2018

Language fall back does work properly:

  1. When :schema-label-language en and dataset label = no language
    The query return no results:
{cubiql{
datasets {
   title
uri
}
}}

The SPARQL produced is:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX qb: <http://purl.org/linked-data/cube#>
PREFIX dcterms: <http://purl.org/dc/terms/>
SELECT ?ds ?name ?title ?description ?licence ?issued ?modified ?publisher WHERE {
{ SELECT DISTINCT ?ds WHERE {  ?ds a qb:DataSet .} }
  ?ds <http://www.w3.org/2000/01/rdf-schema#label> ?name . 
 FILTER(LANG(?name) = "en")}
  1. When :schema-label-language en and measureProperty language = en
    The query return no label for measures although there is a label with @en
{cubiql{
dataset_employment {
  measures {
    enum_name
    label
    uri
  }  
}}}

The result is:

{
  "data": {
    "cubiql": {
      "dataset_employment": {
        "measures": [
          {
            "enum_name": "COUNT",
            "label": null,
            "uri": "http://statistics.gov.scot/def/measure/count"
          }
        ]
      }
    }
  }
}

The SPARQL created is:

PREFIX qb: <http://purl.org/linked-data/cube#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?mt ?label WHERE {  
<http://statistics.gov.scot/data/employment> qb:structure ?struct .  
?struct qb:component ?comp . 
 ?comp qb:measure ?mt .  
?mt a qb:MeasureProperty .  
OPTIONAL {    
?mt <http://www.w3.org/2000/01/rdf-schema#label> ?label .  
  FILTER(LANG(?label) = "")  }}
@lkitching
Copy link
Contributor

@zeginis - The schema-label-language configuration option and label fallback behaviour is only used when locating the labels used to generate the GraphQL schema. When actually querying for labels the language has to match exactly. Not specifying a language means only literals without a language will be returned. Applying the fallback behaviour when querying could be confusing since e.g. lang_preference: "de" would return german and english labels along with any without a language tag.

Would you prefer the fallback behaviour to apply when querying? Or would you like a different fallback behaviour (.e.g just the matching language and any literals without a language)?

@zeginis
Copy link
Contributor Author

zeginis commented Aug 30, 2018

@lkitching I thought that the language fallback worked also for querying, but it is ok.

However the point 2 is a bug then.

When :schema-label-language en and measureProperty language = en
The query return no label for measures although there is a label with @en

@lkitching
Copy link
Contributor

@zeginis - If you don't specify a lang_preference in the GraphQL query it will only match labels with no language, so

{cubiql{
  dataset_employment {
    measures {
      enum_name
      label
      uri
  }  
}}}

would not match labels with an en language tag.
The query

{ cubiql(lang_preference: "en") { ... } }

should return the label.

Would you prefer it if the default returned all labels if no lang_preference is specified?

@zeginis
Copy link
Contributor Author

zeginis commented Aug 30, 2018

I see so lang_preference: "en" is for querying and :schema-label-language en is to build the schema.

What do you mean with "all labels"? E.g. if there are en and de labels return both of them as an array including their language tag?

@lkitching
Copy link
Contributor

@zeginis - Yes, the lang_preference parameter defines which language to fetch the results in. The schema-label-language and fallback behaviour is only used to find the labels used to build the GraphQL schema.

By "all labels" I meant we could return a list of all the labels for each dimension/measure, but thinking about it this might not be a great idea since we only expect a single label for each language and would require a change to the schema. We could apply the fallback behaviour in the case of no lang_preference being specified though i.e. schema-label-language -> en -> no language tag?

@zeginis
Copy link
Contributor Author

zeginis commented Aug 30, 2018

I agree that "all labels" is not a good option.

Yes we could apply also the fall back at querying using the order you mention.

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

2 participants