Skip to content
Snippets Groups Projects
Commit 1fe39ee0 authored by Sebastien's avatar Sebastien
Browse files

+ Code Re-relocation

+ UnitTest completion
parent cb7d1d08
No related branches found
No related tags found
1 merge request!9Refactoring toward clean architecture
Showing
with 408 additions and 42 deletions
package fr.tetras_libre.unltools.rdf.vocabulary; package fr.tetras_libre.unltools.unl.exporters.rdf;
import fr.tetras_libre.unltools.unl.GraphExporter; import fr.tetras_libre.unltools.unl.GraphExporter;
import fr.tetras_libre.unltools.unl.UnlDocument; import fr.tetras_libre.unltools.unl.UnlDocument;
...@@ -8,11 +8,11 @@ import org.apache.jena.rdf.model.ModelFactory; ...@@ -8,11 +8,11 @@ import org.apache.jena.rdf.model.ModelFactory;
import java.io.Writer; import java.io.Writer;
import java.util.List; import java.util.List;
public class RdfFileBuilder implements GraphExporter { public class RdfFileGraphExporter implements GraphExporter {
private final UnlDocumentToRdfConverter converter; private final UnlDocumentToRdfConverter converter;
private final Writer writer; private final Writer writer;
public RdfFileBuilder(Writer writer) { public RdfFileGraphExporter(Writer writer) {
this.writer = writer; this.writer = writer;
this.converter = new UnlDocumentToRdfConverter(); this.converter = new UnlDocumentToRdfConverter();
} }
......
package fr.tetras_libre.unltools.rdf.vocabulary; package fr.tetras_libre.unltools.unl.exporters.rdf;
import org.apache.jena.ontology.ObjectProperty; import org.apache.jena.ontology.ObjectProperty;
import org.apache.jena.ontology.OntModel; import org.apache.jena.ontology.OntModel;
......
package fr.tetras_libre.unltools.rdf.vocabulary; package fr.tetras_libre.unltools.unl.exporters.rdf;
class Slugify { class Slugify {
public static String slugify(String stringSource) { public static String slugify(String stringSource) {
......
package fr.tetras_libre.unltools.rdf.vocabulary; package fr.tetras_libre.unltools.unl.exporters.rdf;
import fr.tetras_libre.rdf.vocabulary.UNL; import fr.tetras_libre.rdf.vocabulary.UNL;
import fr.tetras_libre.unltools.unl.*; import fr.tetras_libre.unltools.unl.*;
import fr.tetras_libre.unltools.unl.extensions.GraphExtensions; import fr.tetras_libre.unltools.unl.GraphExtensions;
import fr.tetras_libre.unltools.unl.extensions.SubGraphReferenceNodeExtensions; import fr.tetras_libre.unltools.unl.SubGraphReferenceNodeExtensions;
import org.apache.jena.ontology.Individual; import org.apache.jena.ontology.Individual;
import org.apache.jena.ontology.OntModel; import org.apache.jena.ontology.OntModel;
import org.apache.jena.ontology.Ontology; import org.apache.jena.ontology.Ontology;
...@@ -15,13 +15,11 @@ import java.util.LinkedList; ...@@ -15,13 +15,11 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import static fr.tetras_libre.unltools.rdf.vocabulary.Slugify.slugify;
public class UnlDocumentToRdfConverter { public class UnlDocumentToRdfConverter {
private final static String DOMAIN = "http://rdf-unl.org"; private final static String DOMAIN = "http://rdf-unl.org";
private final static String Lang = null; private final static String Lang = null;
private RelationLabelToUnlPropertyConverter relationLabelToUnlPropertyConverter; private final RelationLabelToUnlPropertyConverter relationLabelToUnlPropertyConverter;
public UnlDocumentToRdfConverter() { public UnlDocumentToRdfConverter() {
relationLabelToUnlPropertyConverter = new RelationLabelToUnlPropertyConverter(); relationLabelToUnlPropertyConverter = new RelationLabelToUnlPropertyConverter();
...@@ -78,7 +76,7 @@ public class UnlDocumentToRdfConverter { ...@@ -78,7 +76,7 @@ public class UnlDocumentToRdfConverter {
var uw = (UniversalWordNode) sentenceNode; var uw = (UniversalWordNode) sentenceNode;
// Création de l'universalWord dans le dictionnaire // Création de l'universalWord dans le dictionnaire
var universalWordIndividual = sentenceOntModel.createIndividual(String.format("%s/%s#%s", DOMAIN, uniqId, slugify(uw.getUniversalWord().toString())), UNL.UW_Lexeme); var universalWordIndividual = sentenceOntModel.createIndividual(String.format("%s/%s#%s", DOMAIN, uniqId, Slugify.slugify(uw.getUniversalWord().toString())), UNL.UW_Lexeme);
universalWordIndividual.addLabel(uw.getUniversalWord().toString(), UnlDocumentToRdfConverter.Lang); universalWordIndividual.addLabel(uw.getUniversalWord().toString(), UnlDocumentToRdfConverter.Lang);
// Création de l'occurence du l'universalWord // Création de l'occurence du l'universalWord
...@@ -164,9 +162,9 @@ public class UnlDocumentToRdfConverter { ...@@ -164,9 +162,9 @@ public class UnlDocumentToRdfConverter {
public static String constructRelationUri(String scopeName, GraphRelation graphRelation) { public static String constructRelationUri(String scopeName, GraphRelation graphRelation) {
return String.format("%s%s_%s_%s", return String.format("%s%s_%s_%s",
scopeName, scopeName,
slugify(constructRelationUri(graphRelation.getNode1())), Slugify.slugify(constructRelationUri(graphRelation.getNode1())),
graphRelation.getRelationLabel(), graphRelation.getRelationLabel(),
slugify(constructRelationUri(graphRelation.getNode2()))); Slugify.slugify(constructRelationUri(graphRelation.getNode2())));
} }
private static String constructRelationUri(GraphNode node) { private static String constructRelationUri(GraphNode node) {
......
package fr.tetras_libre.unltools.rdf.vocabulary; package fr.tetras_libre.unltools.unl.exporters.rdf;
import fr.tetras_libre.unltools.unl.GraphNode; import fr.tetras_libre.unltools.unl.GraphNode;
import fr.tetras_libre.unltools.unl.SubGraphReferenceNode; import fr.tetras_libre.unltools.unl.SubGraphReferenceNode;
import fr.tetras_libre.unltools.unl.UniversalWordNode; import fr.tetras_libre.unltools.unl.UniversalWordNode;
import fr.tetras_libre.unltools.unl.extensions.SubGraphReferenceNodeExtensions; import fr.tetras_libre.unltools.unl.SubGraphReferenceNodeExtensions;
import static fr.tetras_libre.unltools.rdf.vocabulary.Slugify.slugify; import static fr.tetras_libre.unltools.unl.exporters.rdf.Slugify.slugify;
class UtilGraphNodeUri { class UtilGraphNodeUri {
public static String constructGraphNodeUri(String namespace, GraphNode node) { public static String constructGraphNodeUri(String namespace, GraphNode node) {
......
package fr.tetras_libre.unltools.unl;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.List;
public abstract class AbstractFlyweightUnlArgumentProvider extends AbstractUnlArgumentProvider {
private static final Dictionary<Class<?>, List<UnlDocument>> values = new Hashtable<>();
protected abstract List<UnlDocument> buildUnlDocuments();
final public List<UnlDocument> getUnlDocuments() {
if (null == values.get(this.getClass())) {
synchronized (AbstractFlyweightUnlArgumentProvider.class) {
if (null == values.get(this.getClass())) {
values.put(this.getClass(), this.buildUnlDocuments());
}
}
}
return values.get(this.getClass());
}
}
package fr.tetras_libre.unltools.unl;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.ArgumentsProvider;
import java.util.List;
import java.util.stream.Stream;
public abstract class AbstractUnlArgumentProvider implements ArgumentsProvider {
public abstract List<UnlDocument> getUnlDocuments();
@Override
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
return Stream.of(Arguments.of(getUnlDocuments()));
}
}
package fr.tetras_libre.unltools.unl;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class AllUnl extends AbstractFlyweightUnlArgumentProvider {
@Override
protected List<UnlDocument> buildUnlDocuments() {
var unlDocument = new UnlDocument("[D]");
unlDocument.add(R1Unl.buildSentenceNode());
unlDocument.add(R2Unl.buildSentenceNode());
unlDocument.add(CatsUnl.buildSentenceNode());
return Collections.singletonList(unlDocument);
}
}
package fr.tetras_libre.unltools.unl;
import java.util.*;
public class CatsUnl extends AbstractFlyweightUnlArgumentProvider {
public static UnlDocumentNode buildSentenceNode() {
var graph = new Graph();
// mod
var restrictions = new TreeSet<Restriction>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("feline", new TreeSet<>(Collections.singletonList(new Restriction("icl", '>', new UniversalWord("thing", new TreeSet<>())))))));
var uw = new UniversalWord("cat1", restrictions);
GraphNode uwNode = new UniversalWordNode(uw, new HashSet<>(Arrays.asList(".@entry", ".@def")), ":01");
restrictions = new TreeSet<>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("adj", new TreeSet<>())));
uw = new UniversalWord("black", restrictions);
GraphNode uwNode2 = new UniversalWordNode(uw, new HashSet<>());
graph.add(new GraphRelation(uwNode, uwNode2, "mod", ":01"));
// and
restrictions = new TreeSet<>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("feline", new TreeSet<>(Collections.singletonList(new Restriction("icl", '>', new UniversalWord("thing", new TreeSet<>())))))));
uw = new UniversalWord("cat1", restrictions);
uwNode = new UniversalWordNode(uw, new HashSet<>(Arrays.asList(".@entry", ".@def")), ":01");
restrictions = new TreeSet<>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("feline", new TreeSet<>(Collections.singletonList(new Restriction("icl", '>', new UniversalWord("thing", new TreeSet<>())))))));
uw = new UniversalWord("cat2", restrictions);
uwNode2 = new UniversalWordNode(uw, new HashSet<>(Arrays.asList(".@entry", ".@def")), ":02");
graph.add(new GraphRelation(uwNode, uwNode2, "and", ":01"));
// mod
restrictions = new TreeSet<>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("feline", new TreeSet<>(Collections.singletonList(new Restriction("icl", '>', new UniversalWord("thing", new TreeSet<>())))))));
uw = new UniversalWord("cat2", restrictions);
uwNode = new UniversalWordNode(uw, new HashSet<>(Arrays.asList(".@entry", ".@def")), ":02");
restrictions = new TreeSet<>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("adj", new TreeSet<>())));
uw = new UniversalWord("white", restrictions);
uwNode2 = new UniversalWordNode(uw, new HashSet<>());
graph.add(new GraphRelation(uwNode, uwNode2, "mod", ":01"));
// agt
restrictions = new TreeSet<>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("consume", new TreeSet<>(Collections.singletonList(new Restriction("icl", '>', new UniversalWord("do", new TreeSet<>())))))));
restrictions.add(new Restriction("agt", '>', new UniversalWord("living_thing", new TreeSet<>())));
restrictions.add(new Restriction("obj", '>', new UniversalWord("concrete_thing", new TreeSet<>())));
restrictions.add(new Restriction("ins", '>', new UniversalWord("thing", new TreeSet<>())));
uw = new UniversalWord("eat", restrictions);
uwNode = new UniversalWordNode(uw, new HashSet<>(Arrays.asList(".@entry", ".@pl", ".@present", ".@progress")));
uwNode2 = new SubGraphReferenceNode(":01", new HashSet<>(Collections.singletonList(".@_hn-scope")));
graph.add(new GraphRelation(uwNode, uwNode2, "agt"));
return new UnlDocumentNode(UnlDocumentNodeType.Sentence, "[S:00]", graph);
}
protected List<UnlDocument> buildUnlDocuments() {
var unlDocument = new UnlDocument("[D]");
UnlDocumentNode unlDocumentNode = buildSentenceNode();
unlDocument.add(unlDocumentNode);
return Collections.singletonList(unlDocument);
}
}
package fr.tetras_libre.unltools.rdf.vocabulary; package fr.tetras_libre.unltools.unl;
import fr.tetras_libre.unltools.unl.*; import java.util.*;
import java.util.Collections; public class R1Unl extends AbstractFlyweightUnlArgumentProvider {
import java.util.HashSet;
import java.util.List;
import java.util.TreeSet;
public class CatUnlSentence { @Override
private static List<UnlDocument> unlDocuments; final protected List<UnlDocument> buildUnlDocuments() {
private static void buildUnlDocuments() {
var unlDocument = new UnlDocument("[D]"); var unlDocument = new UnlDocument("[D]");
UnlDocumentNode unlDocumentNode = buildSentenceNode();
unlDocument.add(unlDocumentNode);
return Collections.singletonList(unlDocument);
}
public static UnlDocumentNode buildSentenceNode() {
var graph = new Graph(); var graph = new Graph();
// aoj // agt
var restrictions = new TreeSet<Restriction>(); var restrictions = new TreeSet<Restriction>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("be", new TreeSet<>()))); restrictions.add(new Restriction("icl", '>', new UniversalWord("be", new TreeSet<>())));
restrictions.add(new Restriction("aoj", '>', new UniversalWord("thing", new TreeSet<>()))); restrictions.add(new Restriction("aoj", '>', new UniversalWord("thing", new TreeSet<>())));
...@@ -64,7 +68,7 @@ public class CatUnlSentence { ...@@ -64,7 +68,7 @@ public class CatUnlSentence {
restrictions = new TreeSet<>(); restrictions = new TreeSet<>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("radiowave", new TreeSet<>()))); restrictions.add(new Restriction("icl", '>', new UniversalWord("radiowave", new TreeSet<>())));
uw = new UniversalWord("radiowave", restrictions); uw = new UniversalWord("channel", restrictions);
uwNode2 = new UniversalWordNode(uw, new HashSet<>(Collections.singletonList(".@indef"))); uwNode2 = new UniversalWordNode(uw, new HashSet<>(Collections.singletonList(".@indef")));
graph.add(new GraphRelation(uwNode, uwNode2, "ben")); graph.add(new GraphRelation(uwNode, uwNode2, "ben"));
...@@ -120,7 +124,7 @@ public class CatUnlSentence { ...@@ -120,7 +124,7 @@ public class CatUnlSentence {
restrictions = new TreeSet<>(); restrictions = new TreeSet<>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("sensing", new TreeSet<>()))); restrictions.add(new Restriction("icl", '>', new UniversalWord("sensing", new TreeSet<>())));
uw = new UniversalWord("listening", restrictions); uw = new UniversalWord("listening", restrictions);
uwNode2 = new UniversalWordNode(uw, new HashSet<>(Collections.singletonList(".@plu"))); uwNode2 = new UniversalWordNode(uw, new HashSet<>());
graph.add(new GraphRelation(uwNode, uwNode2, "cnt")); graph.add(new GraphRelation(uwNode, uwNode2, "cnt"));
...@@ -137,18 +141,6 @@ public class CatUnlSentence { ...@@ -137,18 +141,6 @@ public class CatUnlSentence {
graph.add(new GraphRelation(uwNode, uwNode2, "and")); graph.add(new GraphRelation(uwNode, uwNode2, "and"));
var unlDocumentNode = new UnlDocumentNode(UnlDocumentNodeType.Sentence, "[S:R1]", graph); return new UnlDocumentNode(UnlDocumentNodeType.Sentence, "[S:R1]", graph);
unlDocument.add(unlDocumentNode);
unlDocuments.add(unlDocument);
}
public static List<UnlDocument> getUnlDocuments() {
if (null == unlDocuments) {
buildUnlDocuments();
}
return unlDocuments;
} }
} }
package fr.tetras_libre.unltools.rdf.vocabulary; package fr.tetras_libre.unltools.unl;
import fr.tetras_libre.unltools.unl.*;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.ArgumentsProvider;
import java.util.*; import java.util.*;
import java.util.stream.Stream;
public class R1SentenceWithExpectedRdf implements ArgumentsProvider {
private static LinkedList<UnlDocument> unlDocuments;
public R1SentenceWithExpectedRdf() { public class R2Unl extends AbstractFlyweightUnlArgumentProvider {
unlDocuments = new LinkedList<>();
}
private static void buildUnlDocument() { @Override
final protected List<UnlDocument> buildUnlDocuments() {
var unlDocument = new UnlDocument("[D]"); var unlDocument = new UnlDocument("[D]");
UnlDocumentNode unlDocumentNode = buildSentenceNode();
unlDocument.add(unlDocumentNode);
return Collections.singletonList(unlDocument);
}
public static UnlDocumentNode buildSentenceNode() {
var graph = new Graph(); var graph = new Graph();
// aoj // agt
var restrictions = new TreeSet<Restriction>(); var restrictions = new TreeSet<Restriction>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("be", new TreeSet<>()))); restrictions.add(new Restriction("icl", '>', new UniversalWord("show", new TreeSet<>())));
restrictions.add(new Restriction("aoj", '>', new UniversalWord("thing", new TreeSet<>()))); restrictions.add(new Restriction("equ", '>', new UniversalWord("exhibit", new TreeSet<>())));
restrictions.add(new Restriction("ben", '>', new UniversalWord("thing", new TreeSet<>()))); restrictions.add(new Restriction("agt", '>', new UniversalWord("thing", new TreeSet<>())));
restrictions.add(new Restriction("obj", '>', new UniversalWord("uw", new TreeSet<>()))); restrictions.add(new Restriction("obj", '>', new UniversalWord("thing", new TreeSet<>())));
restrictions.add(new Restriction("equ", '>', new UniversalWord("make_possible", new TreeSet<>()))); var uw = new UniversalWord("display", restrictions);
var uw = new UniversalWord("allow", restrictions); GraphNode node1 = new UniversalWordNode(uw, new HashSet<>(Arrays.asList(".@entry", ".@present")));
var uwNode = new UniversalWordNode(uw, new HashSet<>(Collections.singletonList(".@entry")));
restrictions = new TreeSet<>(); restrictions = new TreeSet<>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("group", new TreeSet<>()))); restrictions.add(new Restriction("icl", '>', new UniversalWord("group", new TreeSet<>())));
uw = new UniversalWord("system", restrictions); uw = new UniversalWord("system", restrictions);
var uwNode2 = new UniversalWordNode(uw, new HashSet<>(Collections.singletonList(".@def"))); GraphNode node2 = new UniversalWordNode(uw, new HashSet<>(Collections.singletonList(".@def")));
graph.add(new GraphRelation(uwNode, uwNode2, "aoj"));
// obj
restrictions = new TreeSet<>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("be", new TreeSet<>())));
restrictions.add(new Restriction("aoj", '>', new UniversalWord("thing", new TreeSet<>())));
restrictions.add(new Restriction("ben", '>', new UniversalWord("thing", new TreeSet<>())));
restrictions.add(new Restriction("obj", '>', new UniversalWord("uw", new TreeSet<>())));
restrictions.add(new Restriction("equ", '>', new UniversalWord("make_possible", new TreeSet<>())));
uw = new UniversalWord("allow", restrictions);
uwNode = new UniversalWordNode(uw, new HashSet<>(Collections.singletonList(".@entry")));
restrictions = new TreeSet<>();
restrictions.add(new Restriction("aoj", '>', new UniversalWord("thing", new TreeSet<>())));
restrictions.add(new Restriction("equ", '>', new UniversalWord("assume", new TreeSet<>())));
restrictions.add(new Restriction("icl", '>', new UniversalWord("change", new TreeSet<>())));
restrictions.add(new Restriction("obj", '>', new UniversalWord("thing", new TreeSet<>())));
uw = new UniversalWord("take_on", restrictions);
uwNode2 = new UniversalWordNode(uw, new HashSet<>());
graph.add(new GraphRelation(uwNode, uwNode2, "obj")); graph.add(new GraphRelation(node1, node2, "agt"));
// ben // mod
restrictions = new TreeSet<>(); restrictions = new TreeSet<>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("be", new TreeSet<>()))); restrictions.add(new Restriction("icl", '>', new UniversalWord("radiowave", new TreeSet<>())));
restrictions.add(new Restriction("aoj", '>', new UniversalWord("thing", new TreeSet<>()))); uw = new UniversalWord("channel", restrictions);
restrictions.add(new Restriction("ben", '>', new UniversalWord("thing", new TreeSet<>()))); node1 = new UniversalWordNode(uw, new HashSet<>(Collections.singletonList(".@indef")));
restrictions.add(new Restriction("obj", '>', new UniversalWord("uw", new TreeSet<>())));
restrictions.add(new Restriction("equ", '>', new UniversalWord("make_possible", new TreeSet<>())));
uw = new UniversalWord("allow", restrictions);
uwNode = new UniversalWordNode(uw, new HashSet<>(Collections.singletonList(".@entry")));
restrictions = new TreeSet<>(); restrictions = new TreeSet<>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("radiowave", new TreeSet<>()))); restrictions.add(new Restriction("icl", '>', new UniversalWord("adj", new TreeSet<>())));
uw = new UniversalWord("radiowave", restrictions); restrictions.add(new Restriction("iof", '>', new UniversalWord("color", new TreeSet<>())));
uwNode2 = new UniversalWordNode(uw, new HashSet<>(Collections.singletonList(".@indef"))); uw = new UniversalWord("green", restrictions);
node2 = new UniversalWordNode(uw, new HashSet<>());
graph.add(new GraphRelation(uwNode, uwNode2, "ben")); graph.add(new GraphRelation(node1, node2, "mod"));
// aoj // obj
restrictions = new TreeSet<>(); restrictions = new TreeSet<>();
restrictions.add(new Restriction("aoj", '>', new UniversalWord("thing", new TreeSet<>()))); restrictions.add(new Restriction("icl", '>', new UniversalWord("show", new TreeSet<>())));
restrictions.add(new Restriction("equ", '>', new UniversalWord("assume", new TreeSet<>()))); restrictions.add(new Restriction("equ", '>', new UniversalWord("exhibit", new TreeSet<>())));
restrictions.add(new Restriction("icl", '>', new UniversalWord("change", new TreeSet<>()))); restrictions.add(new Restriction("agt", '>', new UniversalWord("thing", new TreeSet<>())));
restrictions.add(new Restriction("obj", '>', new UniversalWord("thing", new TreeSet<>()))); restrictions.add(new Restriction("obj", '>', new UniversalWord("thing", new TreeSet<>())));
uw = new UniversalWord("take_on", restrictions); uw = new UniversalWord("display", restrictions);
uwNode = new UniversalWordNode(uw, new HashSet<>()); node1 = new UniversalWordNode(uw, new HashSet<>(Arrays.asList(".@entry", ".@present")));
restrictions = new TreeSet<>(); restrictions = new TreeSet<>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("radiowave", new TreeSet<>()))); restrictions.add(new Restriction("icl", '>', new UniversalWord("radiowave", new TreeSet<>())));
uw = new UniversalWord("channel", restrictions); uw = new UniversalWord("channel", restrictions);
uwNode2 = new UniversalWordNode(uw, new HashSet<>(Collections.singletonList(".@indef"))); node2 = new UniversalWordNode(uw, new HashSet<>(Collections.singletonList(".@indef")));
graph.add(new GraphRelation(uwNode, uwNode2, "aoj")); graph.add(new GraphRelation(node1, node2, "obj"));
// obj // tim
restrictions = new TreeSet<>(); restrictions = new TreeSet<>();
restrictions.add(new Restriction("aoj", '>', new UniversalWord("thing", new TreeSet<>()))); restrictions.add(new Restriction("icl", '>', new UniversalWord("show", new TreeSet<>())));
restrictions.add(new Restriction("equ", '>', new UniversalWord("assume", new TreeSet<>()))); restrictions.add(new Restriction("equ", '>', new UniversalWord("exhibit", new TreeSet<>())));
restrictions.add(new Restriction("icl", '>', new UniversalWord("change", new TreeSet<>()))); restrictions.add(new Restriction("agt", '>', new UniversalWord("thing", new TreeSet<>())));
restrictions.add(new Restriction("obj", '>', new UniversalWord("thing", new TreeSet<>()))); restrictions.add(new Restriction("obj", '>', new UniversalWord("thing", new TreeSet<>())));
uw = new UniversalWord("take_on", restrictions); uw = new UniversalWord("display", restrictions);
uwNode = new UniversalWordNode(uw, new HashSet<>()); node1 = new UniversalWordNode(uw, new HashSet<>(Arrays.asList(".@entry", ".@present")));
restrictions = new TreeSet<>(); restrictions = new TreeSet<>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("attribute", new TreeSet<>()))); restrictions.add(new Restriction("icl", '>', new UniversalWord("how", new TreeSet<>())));
uw = new UniversalWord("state", restrictions); restrictions.add(new Restriction("com", '>', new UniversalWord("always", new TreeSet<>())));
uwNode2 = new UniversalWordNode(uw, new HashSet<>(Collections.singletonList(".@plu"))); restrictions.add(new Restriction("tim", '<', new UniversalWord("uw", new TreeSet<>())));
restrictions.add(new Restriction("obj", '>', new UniversalWord("uw", new TreeSet<>())));
uw = new UniversalWord("when", restrictions);
node2 = new UniversalWordNode(uw, new HashSet<>());
graph.add(new GraphRelation(uwNode, uwNode2, "obj")); graph.add(new GraphRelation(node1, node2, "tim"));
// qua // aoj
restrictions = new TreeSet<>(); restrictions = new TreeSet<>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("attribute", new TreeSet<>()))); restrictions.add(new Restriction("aoj", '>', new UniversalWord("thing", new TreeSet<>())));
uw = new UniversalWord("state", restrictions); restrictions.add(new Restriction("icl", '>', new UniversalWord("be", new TreeSet<>())));
uwNode = new UniversalWordNode(uw, new HashSet<>(Collections.singletonList(".@plu"))); restrictions.add(new Restriction("obj", '>', new UniversalWord("state", new TreeSet<>())));
uw = new UniversalWord("be_in_a_state", restrictions);
node1 = new UniversalWordNode(uw, new HashSet<>(Arrays.asList(".@entry", ".@present")));
uwNode2 = new UniversalWordNode(new UniversalWord("2", new TreeSet<>()), new HashSet<>()); restrictions = new TreeSet<>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("radiowave", new TreeSet<>())));
uw = new UniversalWord("channel", restrictions);
node2 = new UniversalWordNode(uw, new HashSet<>(Collections.singletonList(".@indef")));
graph.add(new GraphRelation(uwNode, uwNode2, "qua")); graph.add(new GraphRelation(node1, node2, "aoj", ":01"));
// cnt // plc
restrictions = new TreeSet<>(); restrictions = new TreeSet<>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("attribute", new TreeSet<>()))); restrictions.add(new Restriction("icl", '>', new UniversalWord("attribute", new TreeSet<>())));
uw = new UniversalWord("state", restrictions); uw = new UniversalWord("state", restrictions);
uwNode = new UniversalWordNode(uw, new HashSet<>(Collections.singletonList(".@plu"))); node1 = new UniversalWordNode(uw, new HashSet<>());
restrictions = new TreeSet<>(); restrictions = new TreeSet<>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("sensing", new TreeSet<>()))); restrictions.add(new Restriction("icl", '>', new UniversalWord("message", new TreeSet<>())));
uw = new UniversalWord("listening", restrictions); uw = new UniversalWord("broadcast", restrictions);
uwNode2 = new UniversalWordNode(uw, new HashSet<>(Collections.singletonList(".@plu"))); node2 = new UniversalWordNode(uw, new HashSet<>());
graph.add(new GraphRelation(uwNode, uwNode2, "cnt")); graph.add(new GraphRelation(node1, node2, "plc", ":01"));
// and // obj
restrictions = new TreeSet<>(); restrictions = new TreeSet<>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("sensing", new TreeSet<>()))); restrictions.add(new Restriction("aoj", '>', new UniversalWord("thing", new TreeSet<>())));
uw = new UniversalWord("listening", restrictions); restrictions.add(new Restriction("icl", '>', new UniversalWord("be", new TreeSet<>())));
uwNode = new UniversalWordNode(uw, new HashSet<>()); restrictions.add(new Restriction("obj", '>', new UniversalWord("state", new TreeSet<>())));
uw = new UniversalWord("be_in_a_state", restrictions);
node1 = new UniversalWordNode(uw, new HashSet<>(Arrays.asList(".@entry", ".@present")));
restrictions = new TreeSet<>(); restrictions = new TreeSet<>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("communication", new TreeSet<>()))); restrictions.add(new Restriction("icl", '>', new UniversalWord("attribute", new TreeSet<>())));
uw = new UniversalWord("traffic", restrictions); uw = new UniversalWord("state", restrictions);
uwNode2 = new UniversalWordNode(uw, new HashSet<>()); node2 = new UniversalWordNode(uw, new HashSet<>());
graph.add(new GraphRelation(uwNode, uwNode2, "and"));
var unlDocumentNode = new UnlDocumentNode(UnlDocumentNodeType.Sentence, "[S:R1]", graph);
unlDocument.add(unlDocumentNode); graph.add(new GraphRelation(node1, node2, "obj", ":01"));
unlDocuments.add(unlDocument); // obj
} restrictions = new TreeSet<>();
restrictions.add(new Restriction("icl", '>', new UniversalWord("how", new TreeSet<>())));
private static List<UnlDocument> getUnlDocuments() { restrictions.add(new Restriction("com", '>', new UniversalWord("always", new TreeSet<>())));
if (null == unlDocuments) { restrictions.add(new Restriction("tim", '<', new UniversalWord("uw", new TreeSet<>())));
buildUnlDocument(); restrictions.add(new Restriction("obj", '>', new UniversalWord("uw", new TreeSet<>())));
} uw = new UniversalWord("when", restrictions);
node1 = new UniversalWordNode(uw, new HashSet<>());
return unlDocuments; node2 = new SubGraphReferenceNode(":01");
}
graph.add(new GraphRelation(node1, node2, "obj"));
@Override return new UnlDocumentNode(UnlDocumentNodeType.Sentence, "[S:R2]", graph);
public Stream<? extends Arguments> provideArguments(ExtensionContext extensionContext) {
buildUnlDocument();
return Stream.of(Arguments.of(unlDocuments));
} }
} }
package fr.tetras_libre.unltools.unl;
public class UnlSentences {
public static final String R1 = "[D]\n" +
"[S:R1]\n" +
"{org:en}\n" +
"The system allows a radio channel to take on two states: Listening and Traffic.\n" +
"{/org}\n" +
"{unl}\n" +
"aoj( allow(icl>be, aoj>thing, ben>thing, obj>uw, equ>make_possible).@entry, system(icl>group).@def )\n" +
"obj( allow(icl>be, aoj>thing, ben>thing, obj>uw, equ>make_possible).@entry, take_on(aoj>thing, equ>assume,icl>change, obj>thing) )\n" +
"ben( allow(icl>be, aoj>thing, ben>thing, obj>uw, equ>make_possible).@entry, channel(icl>radiowave).@indef)\n" +
"aoj( take_on(aoj>thing, equ>assume, icl>change, obj>thing), channel(icl>radiowave).@indef ) \n" +
"obj( take_on(aoj>thing, equ>assume, icl>change, obj>thing), state(icl>attribute).@plu ) \n" +
"qua( state(icl>attribute).@plu, 2 ) \n" +
"cnt( state(icl>attribute).@plu, listening(icl>sensing) )\n" +
"and( listening(icl>sensing),traffic(icl>communication) )\n" +
"{/unl}\n" +
"[/S]\n" +
"[/D]";
public static final String R2 = "[D]\n" +
"[S:R2]\n" +
"{org:en}\n" +
"The system displays a channel in green when it is in broadcast state. \n" +
"{/org}\n" +
"{unl}\n" +
"agt(display(icl>show,equ>exhibit,agt>thing,obj>thing).@entry.@present,system(icl>group).@def)\n" +
"mod(channel(icl>radiowave).@indef,green(icl>adj,iof>color))\n" +
"obj(display(icl>show,equ>exhibit,agt>thing,obj>thing).@entry.@present,channel(icl>radiowave).@indef)\n" +
"tim(display(icl>show,equ>exhibit,agt>thing,obj>thing).@entry.@present,when(icl>how,com>always,tim<uw,obj>uw))\n" +
"aoj:01(be_in_a_state(aoj>thing,icl>be,obj>state).@entry.@present,channel(icl>radiowave).@indef)\n" +
"plc:01(state(icl>attribute),broadcast(icl>message))\n" +
"obj:01(be_in_a_state(aoj>thing,icl>be,obj>state).@entry.@present,state(icl>attribute))\n" +
"obj(when(icl>how,com>always,tim<uw,obj>uw),:01)\n" +
"{/unl}\n" +
"[/S] \n" +
"[/D] \n";
public static final String Cats = "[D]" +
"[S:00]\n" +
"{org:en}\n" +
"The black cat and the white cat are eating.\n" +
"{/org}\n" +
"{unl}\n" +
"mod:01(cat1(icl>feline>thing):01.@entry.@def,black(icl>adj))\n" +
"and:01(cat1(icl>feline>thing):01.@entry.@def,cat2(icl>feline>thing):02.@entry.@def)\n" +
"mod:01(cat2(icl>feline>thing):02.@entry.@def,white(icl>adj))\n" +
"agt(eat(icl>consume>do,agt>living_thing,obj>concrete_thing,ins>thing).@entry.@pl.@present.@progress,:01.@_hn-scope)\n" +
"{/unl}\n" +
"[/S]\n";
public static final String All = "[D]" +
"[S:R1]\n" +
"{org:en}\n" +
"The system allows a radio channel to take on two states: Listening and Traffic.\n" +
"{/org}\n" +
"{unl}\n" +
"aoj( allow(icl>be, aoj>thing, ben>thing, obj>uw, equ>make_possible).@entry, system(icl>group).@def )\n" +
"obj( allow(icl>be, aoj>thing, ben>thing, obj>uw, equ>make_possible).@entry, take_on(aoj>thing, equ>assume,icl>change, obj>thing) )\n" +
"ben( allow(icl>be, aoj>thing, ben>thing, obj>uw, equ>make_possible).@entry, channel(icl>radiowave).@indef)\n" +
"aoj( take_on(aoj>thing, equ>assume, icl>change, obj>thing), channel(icl>radiowave).@indef) \n" +
"obj( take_on(aoj>thing, equ>assume, icl>change, obj>thing), state(icl>attribute).@plu ) \n" +
"qua( state(icl>attribute).@plu, 2 ) \n" +
"cnt( state(icl>attribute).@plu, listening(icl>sensing) )\n" +
"and( listening(icl>sensing),traffic(icl>communication) )\n" +
"{/unl}\n" +
"[/S]\n" +
"[S:R2]\n" +
"{org:en}\n" +
"The system displays a channel in green when it is in broadcast state. \n" +
"{/org}\n" +
"{unl}\n" +
"agt(display(icl>show,equ>exhibit,agt>thing,obj>thing).@entry.@present,system(icl>group).@def)\n" +
"mod(channel(icl>radiowave).@indef,green(icl>adj,iof>color))\n" +
"obj(display(icl>show,equ>exhibit,agt>thing,obj>thing).@entry.@present,channel(icl>radiowave).@indef)\n" +
"tim(display(icl>show,equ>exhibit,agt>thing,obj>thing).@entry.@present,when(icl>how,com>always,tim<uw,obj>uw))\n" +
"aoj:01(be_in_a_state(aoj>thing,icl>be,obj>state).@entry.@present,channel(icl>radiowave).@indef)\n" +
"plc:01(state(icl>attribute),broadcast(icl>message))\n" +
"obj:01(be_in_a_state(aoj>thing,icl>be,obj>state).@entry.@present,state(icl>attribute))\n" +
"obj(when(icl>how,com>always,tim<uw,obj>uw),:01)\n" +
"{/unl}\n" +
"[/S] \n" +
"[S:00]\n" +
"{org:en}\n" +
"The black cat and the white cat are eating.\n" +
"{/org}\n" +
"{unl}\n" +
"mod:01(cat1(icl>feline>thing):01.@entry.@def,black(icl>adj))\n" +
"and:01(cat1(icl>feline>thing):01.@entry.@def,cat2(icl>feline>thing):02.@entry.@def)\n" +
"mod:01(cat2(icl>feline>thing):02.@entry.@def,white(icl>adj))\n" +
"agt(eat(icl>consume>do,agt>living_thing,obj>concrete_thing,ins>thing).@entry.@pl.@present.@progress,:01.@_hn-scope)\n" +
"{/unl}\n" +
"[/S]\n" +
"[/D]";
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment