apache / apache/jena

Add support for literals with language tags to the GenericRuleReasoner's rules syntax

Open
#3,042 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
1.4k
Forks
712
Avg merge
15h 41m
Merged PRs (30d)
53

Description

### Version

5.3.0

### Feature

Loading the following rule with the [`Rule.parseRules(...)`](https://github.com/apache/jena/blob/a50f0fe179c96e1e4e34ee7d7bab681bb94be8e6/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/Rule.java#L689) method gives an error.

```
-> ( "Человек-паук"@ru) .
```

```
org.apache.jena.reasoner.rulesys.Rule$ParserException: Triple with 4 nodes!
At '-> ( " Человек-паук " @ru ) '
at org.apache.jena.reasoner.rulesys.Rule$Parser.parseClause(Rule.java:1016)
at org.apache.jena.reasoner.rulesys.Rule$Parser.doParseRule(Rule.java:1081)
at org.apache.jena.reasoner.rulesys.Rule$Parser.parseRule(Rule.java:1046)
at org.apache.jena.reasoner.rulesys.Rule.parseRules(Rule.java:664)
at org.apache.jena.reasoner.rulesys.Rule.parseRules(Rule.java:678)
at org.apache.jena.reasoner.rulesys.Rule.parseRules(Rule.java:690)
...
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
```

After checking [the source](https://github.com/apache/jena/blob/a50f0fe179c96e1e4e34ee7d7bab681bb94be8e6/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/Rule.java#L920-L950) it seems like literals with language tags are not supported by the current Rule syntax.

We ran into this issue because we are trying to convert a string with RDF in turtle format into a string with every triple converted into the following Apache Jena's rule format:

```
-> ( ) .
```

The lack of support for language tags is currently not blocking for us.

### Are you interested in contributing a solution yourself?

Perhaps?

Contributor guide

Open the contributing guide

Research direction

Start in jena-core/src/main/java/org/apache/jena/reasoner/rulesys/Rule.java, especially the parser code around the referenced lines and Rule.parseRules(...). Trace how the example rule is tokenized and parsed, then verify that a language-tagged literal such as "Человек-паук"@ru is accepted by the rules syntax.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.