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

Optionally have ldpath return RDF::Literals instead of Strings #16

Open
elrayle opened this issue Nov 19, 2019 · 2 comments · May be fixed by #18
Open

Optionally have ldpath return RDF::Literals instead of Strings #16

elrayle opened this issue Nov 19, 2019 · 2 comments · May be fixed by #18

Comments

@elrayle
Copy link
Contributor

elrayle commented Nov 19, 2019

Description

An ldpath program can request a result in a specific language, but if language is not specified, all literals will be returned for all languages. Since the results are returned as strings, the language tagging is lost. This prevents the caller from processing the results based on language.

This can be ameliorated by allowing the #evaluate method to have an optional parameter requesting that results be returned as RDF::Literals instead of Strings.

Rationale

Callers of ldpath may want to get all possible values for all languages and have language specific processing in the calling app.

Use Case

Ldpath is used to get values for two related properties. Each property's values are sorted by language making the two sets of property results align by language.

The values can be requested by language, but that assumes you know in advance all the possible languages.

NOTE: This sorting is happening in the calling app. Without language tagging, this type of sorting cannot be done.

Desired Ordering

term = ["dried milk", "getrocknete Milch", "lait en poudre"]
desc = ["powdery", "Pulverförmig", "poudreux"]

Undesired Ordering

term = ["dried milk", "getrocknete Milch", "lait en poudre"]
desc = ["poudreux", "powdery", "Pulverförmig"]

Expected Results

results = ldpath_program.evaluate(subject_uri, context: graph, limit_to_context: true, literal_results: true)
results # [RDF::Literal<"milk"@en>, RDF::Literal<"milche"@de>, RDF::Literal<"lait"@fr>]

Actual Results

literal_results is not a parameter in the current implementation

results = ldpath_program.evaluate(subject_uri, context: graph, limit_to_context: true)
results # ["milk", "milche", "lait"]
@elrayle
Copy link
Contributor Author

elrayle commented Nov 19, 2019

@cbeer How hard do you think it would be to do this? I took a quick look and it wasn't apparent to me where results are converted from RDF::Literals to Strings.

@elrayle
Copy link
Contributor Author

elrayle commented Nov 19, 2019

Looks like the conversion from RDF::Literal to String happens in field_mapping #transform_value

@elrayle elrayle linked a pull request Nov 20, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant