Prefixes (Semantic Web Library), variables and values with first capital letter

Hello.

I have a problem using prefixes in the Semantic Web Library.

I can’t use variables, if I want to assert a triple, if the value after the prefix starts with a capital letter. Usually, in this case a single quotation mark before and after that value helps. But not when the rdf_assert predicate (I assume also with other predicates) contains a variable at that point.

I also tried the var_prefix flag, and atom/string conversion, to no avail.

Could you give an example?

Sorry, I was a bit vague. Meanwhile I’ve figured it out myself. For my purpose the following construction helps (“Vater” = German for “father”, “fr” = “family relations”):

A1 = 'Vater', atom_concat('fr:\'', A1, A2), atom_concat(A2, '\'', A3), term_to_atom(A4, A3), rdf_assert(A4, rdf:type, owl:'Class').

Or a bit shorter, with the var_prefix flag:

_A1 = 'Vater', atom_concat('fr:', _A1, _A2), term_to_atom(_A3, _A2), rdf_assert(_A3, rdf:type, owl:'Class').

Rather complicated, IMO. Without that or a similar construction the triples do not incorporate the IRIs that the prefixes are standing for.

As you do it, yes. I think this is exactly the same as simply

?- rdf_assert(fr:'Vater', rdf:type, owl:'Class').

Having some strings, creating a Prolog text and than parsing it is something that should never be needed. I guess I’m missing some of your intend, but this really must be a one-liner or worst case two calls, but surely should not involve atom_concat/3 or term_to_atom/2. From the first mail, I gather we are dealing with dynamic data. It turns out this does not work:

?- C = ‘Vater’, rdf_assert(fr:C, rdf:type, owl:‘Class’).

This does and is probably what you want.

?- C = fr:‘Vater’, rdf_assert(C, rdf:type, owl:‘Class’).

The one above should probably also work. In older versions the arguments to rdf_assert/3 were required to be atoms (IRIs), either passed through a variable, literally appearing in the code or written as e.g. rdf:type. The last form is expanded at compile time to avoid the relatively expansive atom concatenation at runtime. Probably it should also leave non-ground terms using the Prefix:Local terms to the runtime system.

Thank you for your extensive response. My intent using e.g. “Vater” instead of directly “fr:‘Vater’” was to avoid double-entries. One entry for the predicate (vater) that does the inference job, one entry for the triples. I searched for an elegant way to avoid that. For the time being I convert the first letter of the predicate to a capital letter (as in German those terms are in capital), then add the prefix and the single quotation marks to it for triple creation. With that I can have one predicate for a query of all the family relations that uses lists with all the relations, the latter being identical with the particular predicates, and also use those lists for the triples.