diff --git a/Examples/r2.txt b/Examples/r2.txt new file mode 100644 index 0000000000000000000000000000000000000000..2c2c88a18cfe4c310a0dd155ac320bf6334e7e81 --- /dev/null +++ b/Examples/r2.txt @@ -0,0 +1,17 @@ +[D] +[S:R2] +{org:en} +The system displays a channel in green when it is in broadcast state. +{/org} +{unl} +agt(display(icl>show,equ>exhibit,agt>thing,obj>thing).@entry.@present,system(icl>group).@def) +mod(channel(icl>radiowave).@indef,green(icl>adj,iof>color)) +obj(display(icl>show,equ>exhibit,agt>thing,obj>thing).@entry.@present,channel(icl>radiowave).@indef) +tim(display(icl>show,equ>exhibit,agt>thing,obj>thing).@entry.@present,when(icl>how,com>always,tim<uw,obj>uw)) +aoj:01(be_in_a_state(aoj>thing,icl>be,obj>state).@entry.@present,channel(icl>radiowave).@indef) +plc:01(state(icl>attribute),broadcast(icl>message)) +obj:01(be_in_a_state(aoj>thing,icl>be,obj>state).@entry.@present,state(icl>attribute)) +obj(when(icl>how,com>always,tim<uw,obj>uw),:01) +{/unl} +[/S] +[/D] \ No newline at end of file diff --git a/rdf/src/main/java/fr/tetras_libre/unltools/rdf/vocabulary/UnlDocumentToRdfConverter.java b/rdf/src/main/java/fr/tetras_libre/unltools/rdf/vocabulary/UnlDocumentToRdfConverter.java index bcf097839990cb22d193f96820accfb6103c1ddf..6d6c08821b88e5440da55aa590a80947e6fb83fe 100644 --- a/rdf/src/main/java/fr/tetras_libre/unltools/rdf/vocabulary/UnlDocumentToRdfConverter.java +++ b/rdf/src/main/java/fr/tetras_libre/unltools/rdf/vocabulary/UnlDocumentToRdfConverter.java @@ -77,7 +77,7 @@ public class UnlDocumentToRdfConverter { var uw = (UniversalWordNode) sentenceNode; // Création de l'universalWord dans le dictionnaire - var universalWordIndividual = sentenceOntModel.createIndividual(String.format("%s#%s", uniqId, slugify(uw.getUniversalWord().toString())), UNL.UW_Lexeme); + var universalWordIndividual = sentenceOntModel.createIndividual(String.format("%s/%s#%s", DOMAIN, uniqId, slugify(uw.getUniversalWord().toString())), UNL.UW_Lexeme); universalWordIndividual.addLabel(uw.getUniversalWord().toString(), "fr/tetras_libre/unltools/unl"); // Création de l'occurence du l'universalWord @@ -92,41 +92,33 @@ public class UnlDocumentToRdfConverter { sentenceOntModel.add(universalWordOccurrence, UNL.has_attribute, attribute); } - for (var graphRefNode : sentencegraph.getNodes()) { - if (graphRefNode instanceof SubGraphReferenceNode) { - var scopeName = SubGraphReferenceNodeExtensions.getScopeNameFromSubGraphReferenceNode((SubGraphReferenceNode) graphRefNode); - var scopeIndividual = sentenceOntModel.createIndividual( - UtilGraphNodeUri.constructGraphNodeUri(sentenceNameSpace, graphRefNode), - UNL.UNL_Scope); - - scopeIndividual.addLabel(scopeName, "fr/tetras_libre/unltools/unl"); - this.setSuperstructureWithSubstructure(sentenceOntModel, sentenceIndividual, sentenceOntModel, scopeIndividual); - - /* - GraphExtensions.getRelationWithinScopeStream(scopeName, sentencegraph) - .forEach(relationWithinScope -> { - try { - var relationWithinScopeUri = RelationsUri.constructRelationUri(scopeName, relationWithinScope); - var relationWithinScopeObjectProperty = this.relationLabelToUnlPropertyConverter.getObjectProperty(relationWithinScope.getRelationLabel(), docModel); - sentenceOntModel.createIndividual(relationWithinScopeUri, relationWithinScopeObjectProperty); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - }); - */ - var relationsWithinScope = GraphExtensions.getRelationsWithinScope(scopeName, sentencegraph); - for (var relationWithinScope : relationsWithinScope) { - try { - var relationWithinScopeUri = RelationsUri.constructRelationUri(scopeName, relationWithinScope); - var relationWithinScopeObjectProperty = this.relationLabelToUnlPropertyConverter.getObjectProperty(relationWithinScope.getRelationLabel(), docModel); - sentenceOntModel.createIndividual(relationWithinScopeUri, relationWithinScopeObjectProperty); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - - } - } - } + sentencegraph + .getNodes() + .stream() + .filter(node -> node instanceof SubGraphReferenceNode) + .map(SubGraphReferenceNode.class::cast) + .forEach(graphRefNode -> { + var scopeName = SubGraphReferenceNodeExtensions.getScopeNameFromSubGraphReferenceNode(graphRefNode); + var scopeIndividual = sentenceOntModel.createIndividual( + UtilGraphNodeUri.constructGraphNodeUri(sentenceNameSpace, graphRefNode), + UNL.UNL_Scope); + + scopeIndividual.addLabel(scopeName, "fr/tetras_libre/unltools/unl"); + this.setSuperstructureWithSubstructure(sentenceOntModel, sentenceIndividual, sentenceOntModel, scopeIndividual); + + GraphExtensions.getRelationWithinScopeStream(graphRefNode.getReferenceNumber(), sentencegraph) + .forEach(relationWithinScope -> { + try { + var relationWithinScopeUri = RelationsUri.constructRelationUri(String.format("%s#", sentenceUri), relationWithinScope); + var relationWithinScopeObjectProperty = this.relationLabelToUnlPropertyConverter.getObjectProperty(relationWithinScope.getRelationLabel(), docModel); + var relationWithinScopeIndividual = sentenceOntModel.createIndividual(relationWithinScopeUri, relationWithinScopeObjectProperty); + sentenceOntModel.add(scopeIndividual, UNL.is_scope_of, relationWithinScopeIndividual); + sentenceOntModel.add(relationWithinScopeIndividual, UNL.has_scope, scopeIndividual); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + }); + }); for (var relation : sentencegraph.getRelations()) { var relationUri = RelationsUri.constructRelationUri(sentenceNameSpace, relation); diff --git a/unl-parser/unl-parser.iml b/unl-parser/unl-parser.iml index 7f41d813cfcf44270f577d9a8135613a17bd8c18..b78f1acf3931646f526879971d089604089918d3 100644 --- a/unl-parser/unl-parser.iml +++ b/unl-parser/unl-parser.iml @@ -6,7 +6,6 @@ <content url="file://$MODULE_DIR$"> <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> - <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" generated="true" /> <excludeFolder url="file://$MODULE_DIR$/target" /> </content> <orderEntry type="inheritedJdk" /> diff --git a/unl2rdf-app/src/test/java/unl2rdf/Unl2RdfTest.java b/unl2rdf-app/src/test/java/unl2rdf/Unl2RdfTest.java index 032e08a0ed3a64b75b5d89700b5a3f8daa9cd319..b0d28dac74dcde47cebdd1b36982e5ae9fa8de33 100644 --- a/unl2rdf-app/src/test/java/unl2rdf/Unl2RdfTest.java +++ b/unl2rdf-app/src/test/java/unl2rdf/Unl2RdfTest.java @@ -26,6 +26,12 @@ class Unl2RdfTest { Assertions.assertDoesNotThrow(() -> Unl2Rdf.main(new String[]{"--input-file", "../Examples/r1.txt", "--output-file", "r1", "--output-type", "rdf"})); } + @Tag("integration") + @Test + public void r2ShouldBeConvertedToRdfFile(){ + Assertions.assertDoesNotThrow(() -> Unl2Rdf.main(new String[]{"--input-file", "../Examples/r2.txt", "--output-file", "r2", "--output-type", "rdf"})); + } + @Tag("integration") @Test public void catShouldBeConvertedToRdfFile(){