...
 
Commits (2)
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="tetra_central" />
<option name="name" value="Tetras Central" />
<option name="url" value="file:////Users/scurt/.m2/tetrasArtifacts/repository" />
</remote-repository>
<remote-repository>
<option name="id" value="tetra_central" />
<option name="name" value="Tetras Central" />
<option name="url" value="file:////Users/scurt/.m2/tetrasArtifacts-unl" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
<option name="id" value="tetra_central" />
<option name="name" value="Tetras Central" />
<option name="url" value="file:///C:\Users\curts/.m2/tetrasArtifacts-unl" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
......@@ -19,7 +29,7 @@
<remote-repository>
<option name="id" value="tetra_central" />
<option name="name" value="Tetras Central" />
<option name="url" value="file:////Users/scurt/.m2/tetrasArtifacts/repository" />
<option name="url" value="file:///C:\Users\curts\.m2\tetrasArtifacts-unl" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
......
[D]
[S:00]
{org:en}
This document defines the functional requirements for ERTMS/ETCS (EUROPEAN RAIL TRAFFIC MANAGEMENT SYSTEM / EUROPEAN TRAIN CONTROL SYSTEM).
{/org}
{unl}
mod(document(icl>writing>thing),this(icl>determiner>adj,mod<concrete_thing))
aoj(define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present,document(icl>writing>thing))
mod(requirement(icl>duty>thing).@def.@pl,functional(icl>adj,ant>nonfunctional))
obj(define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present,requirement(icl>duty>thing).@def.@pl)
or(etcs,ertms)
pur(requirement(icl>duty>thing).@def.@pl,etcs)
mod:01(management(icl>action,agt>volitional_thing,obj>thing),traffic(icl>collection>thing))
mod(:03.@_hn-scope,management(icl>action,agt>volitional_thing,obj>thing))
or:03(european(icl>inhabitant>person).@entry,system(icl>group>thing):01.@entry)
mod:01(control(icl>power>thing),train(icl>public_transport>thing))
mod:01(system(icl>group>thing):02,control(icl>power>thing))
agt:02(rail(icl>complain>do,rsn>thing,agt>volitional_thing).@entry.@present,:01.@entry.@parenthesis)
rsn:02(rail(icl>complain>do,rsn>thing,agt>volitional_thing).@entry.@present,:01.@entry.@parenthesis)
shd(etcs,:02)
mod(train(icl>public_transport>thing),:03.@_hn-scope)
{/unl}
[/S]
[S:00]
{org:en}
The document primarily defines the operational requirements and therefore contains only a few technical terms.
{/org}
{unl}
aoj(define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present,document(icl>writing>thing).@def)
man(define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present,primarily(icl>how,equ>mainly))
and(:01,define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present)
mod(requirement(icl>duty>thing).@def.@pl,operational(icl>adj,com>operation))
obj(define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present,requirement(icl>duty>thing).@def.@pl)
man:01(contain(icl>be,equ>comprise,obj>abstract_thing,aoj>information,pur>abstract_thing).@entry.@present,therefore(icl>how))
man:01(term(icl>word>thing,mod>thing).@pl,only(icl>how,equ>recently))
qua:01(term(icl>word>thing,mod>thing).@pl,a_few(icl>adj,equ>some,qua<thing))
mod:01(term(icl>word>thing,mod>thing).@pl,technical(icl>adj,ant>nontechnical))
obj:01(contain(icl>be,equ>comprise,obj>abstract_thing,aoj>information,pur>abstract_thing).@entry.@present,term(icl>word>thing,mod>thing).@pl)
{/unl}
[/S]
[S:00]
{org:en}
For consistency reasons, all functional requirements not implemented in the SRS 2.3.0 have been removed from this version..
{/org}
{unl}
agt:01(reason(icl>persuade>do,agt>thing,gol>uw,rec>person).@entry.@present,consistency(icl>uniformity>thing,ant>inconsistency))
qua:02(requirement(icl>duty>thing).@pl,all(icl>quantity,ant>some,per>thing))
mod:02(requirement(icl>duty>thing).@pl,functional(icl>adj,ant>nonfunctional))
agt:02(implement(icl>employ>do,agt>thing,obj>thing).@past.@not,requirement(icl>duty>thing).@pl)
plc(remove(icl>dismiss>do,plf>thing,agt>volitional_thing,obj>person).@entry.@present.@complete,srs.@def)
obj(remove(icl>dismiss>do,plf>thing,agt>volitional_thing,obj>person).@entry.@present.@complete,"2.3".@topic)
mod("2.3".@topic,".0")
mod(version(icl>interpretation>abstract_thing,agt>thing,obj>uw),this(icl>determiner>adj,mod<concrete_thing))
plf(remove(icl>dismiss>do,plf>thing,agt>volitional_thing,obj>person).@entry.@present.@complete,version(icl>interpretation>abstract_thing,agt>thing,obj>uw))
and(implement(icl>employ>do,agt>thing,obj>thing).@past.@not,:01)
rsn(remove(icl>dismiss>do,plf>thing,agt>volitional_thing,obj>person).@entry.@present.@complete,:02)
{/unl}
[/S]
[/D]
\ No newline at end of file
......@@ -113,7 +113,7 @@
</snapshots>
<id>tetra_central</id>
<name>Tetras Central</name>
<url>file:///${user.home}/.m2/tetrasArtifacts-unl</url>
<url>file:///${user.home}\.m2\tetrasArtifacts-unl</url>
</repository>
</repositories>
......
......@@ -2,6 +2,7 @@ package fr.tetras_libre.unltools.Convert;
import fr.tetras_libre.unltools.cqrs.CommandHandler;
import fr.tetras_libre.unltools.cqrs.Result;
import fr.tetras_libre.unltools.unl.GraphExportException;
import fr.tetras_libre.unltools.unl.GraphExporterFactory;
import java.io.IOException;
......@@ -18,7 +19,9 @@ public class ExportUnlDocumentsHandler implements CommandHandler<ExportUnlDocume
try {
var graphExporter = factory.createGraphExporter(command.getWriter(), command.getExporterName());
graphExporter.write(command.getGraphImporter().Import());
} catch (IOException e) {
command.getWriter().flush();
command.getWriter().close();
} catch (IOException | GraphExportException e) {
return Result.Failure(String.format("Cannot export unl documents to format '%s'", command.getExporterName()),
e);
}
......
......@@ -81,6 +81,15 @@ public class Graph {
int i = 0;
GraphNode graphNode = null;
while ((i < this.nodes.size()) && (null == graphNode)) {
var node = this.nodes.get(i);
if(graphNumber.equals(node.getNodeId()) && node.isEntryNode()){
return node;
}
i++;
}
i=0;
while ((i < relations.size()) && (null == graphNode)) {
graphNode = getEntryNode(this.relations.get(i), graphNumber);
i++;
......
package fr.tetras_libre.unltools.unl;
public class GraphExportException extends Exception {
public GraphExportException() {
super();
}
public GraphExportException(String message) {
super(message);
}
public GraphExportException(String message, Throwable cause) {
super(message, cause);
}
public GraphExportException(Throwable cause) {
super(cause);
}
}
......@@ -4,5 +4,5 @@ import java.io.IOException;
import java.util.List;
public interface GraphExporter {
void write(List<UnlDocument> g) throws IOException;
void write(List<UnlDocument> g) throws IOException, GraphExportException;
}
package fr.tetras_libre.unltools.unl.builders;
import fr.tetras_libre.unltools.unl.Graph;
import java.util.function.Function;
public class GraphBuilder {
Graph graph;
private GraphBuilder() {
this.graph = new Graph();
}
public static IBuild graph() {
return new GraphBuilder.Builder();
}
public interface IBuild {
IBuild addGraphRelation(Function<GraphRelationBuilder.RequiredLabel, GraphRelationBuilder.IBuild> c);
Graph buildGraph();
}
private static class Builder implements IBuild {
private final GraphBuilder instance;
public Builder() {
instance = new GraphBuilder();
}
@Override
public IBuild addGraphRelation(Function<GraphRelationBuilder.RequiredLabel, GraphRelationBuilder.IBuild> c) {
instance.graph.add(c.apply(GraphRelationBuilder.createBuilder()).buildGraphRelation());
return this;
}
@Override
public Graph buildGraph() {
return instance.graph;
}
}
}
package fr.tetras_libre.unltools.unl.builders;
import fr.tetras_libre.unltools.unl.GraphNode;
import fr.tetras_libre.unltools.unl.GraphRelation;
import java.util.function.Function;
public class GraphRelationBuilder {
private String label;
private String graphReference;
private GraphNode node1;
private GraphNode node2;
public static RequiredLabel createBuilder() {
return new GraphRelationBuilder.Builder();
}
public interface RequiredLabel {
OptionalGraphReference label(String label);
}
public interface OptionalGraphReference {
RequiredLeftNode reference(String nodeName);
RequiredLeftNode noReference();
}
public interface RequiredLeftNode {
RequiredRightNode leftNode(Function<UniversalWordNodeBuilder.IRequiredUniversalWord, UniversalWordNodeBuilder.IBuild> f);
RequiredRightNode leftSubGraphNode(Function<SubGraphReferenceNodeBuilder.IRequiredReferenceNumber, SubGraphReferenceNodeBuilder.IBuild> f);
}
public interface RequiredRightNode {
IBuild rightNode(Function<UniversalWordNodeBuilder.IRequiredUniversalWord, UniversalWordNodeBuilder.IBuild> f);
IBuild rightSubGraphNode(Function<SubGraphReferenceNodeBuilder.IRequiredReferenceNumber, SubGraphReferenceNodeBuilder.IBuild> f);
}
public interface IBuild {
GraphRelation buildGraphRelation();
}
private static class Builder implements RequiredLabel, OptionalGraphReference, RequiredLeftNode, RequiredRightNode, IBuild {
private final GraphRelationBuilder instance;
public Builder() {
instance = new GraphRelationBuilder();
}
@Override
public RequiredLeftNode reference(String nodeName) {
instance.graphReference = nodeName;
return this;
}
@Override
public RequiredLeftNode noReference() {
instance.graphReference = "";
return this;
}
@Override
public RequiredRightNode leftNode(Function<UniversalWordNodeBuilder.IRequiredUniversalWord, UniversalWordNodeBuilder.IBuild> f) {
this.instance.node1 = f.apply(UniversalWordNodeBuilder.createBuilder()).buildUniversalWordNode();
return this;
}
@Override
public RequiredRightNode leftSubGraphNode(Function<SubGraphReferenceNodeBuilder.IRequiredReferenceNumber, SubGraphReferenceNodeBuilder.IBuild> f) {
instance.node1 = f.apply(SubGraphReferenceNodeBuilder.createBuilder()).buildSubGraphReferenceNode();
return this;
}
@Override
public GraphRelation buildGraphRelation() {
return new GraphRelation(instance.node1, instance.node2, instance.label, instance.graphReference);
}
@Override
public OptionalGraphReference label(String label) {
instance.label = label;
return this;
}
@Override
public IBuild rightNode(Function<UniversalWordNodeBuilder.IRequiredUniversalWord, UniversalWordNodeBuilder.IBuild> f) {
instance.node2 = f.apply(UniversalWordNodeBuilder.createBuilder()).buildUniversalWordNode();
return this;
}
@Override
public IBuild rightSubGraphNode(Function<SubGraphReferenceNodeBuilder.IRequiredReferenceNumber, SubGraphReferenceNodeBuilder.IBuild> f) {
instance.node2 = f.apply(SubGraphReferenceNodeBuilder.createBuilder()).buildSubGraphReferenceNode();
return this;
}
}
}
package fr.tetras_libre.unltools.unl.builders;
import fr.tetras_libre.unltools.unl.Restriction;
import fr.tetras_libre.unltools.unl.UniversalWord;
public class RestrictionBuilder {
private String label;
private char orientation;
private UniversalWord universalWord;
private RestrictionBuilder() {
label = "";
orientation = ' ';
universalWord = null;
}
public interface IRequiredLabel {
IOrientation label(String label);
}
public static Restriction simpleRestriction(String label, RestrictionOrientation orientation, String headwordLabel) {
return RestrictionBuilder
.createBuilder()
.label(label)
.withOrientation(orientation)
.universalWord(UniversalWordBuilder.simpleUniversalWord(headwordLabel))
.buildRestriction();
}
public static IRequiredLabel createBuilder() {
return new RestrictionBuilder.Builder();
}
public static Restriction ternaryTransitiveRestriction(String label1, String label2, String label3, RestrictionOrientation orientation) {
return RestrictionBuilder
.createBuilder()
.label(label1)
.withOrientation(orientation)
.universalWord(
UniversalWordBuilder
.createBuilder()
.headWord(label2)
.addSimpleRestriction(label1, orientation, label3 )
.buildUniversalWord()
)
.buildRestriction();
}
public interface IOrientation {
IRequiredUniversalWord withOrientation(RestrictionOrientation orientation);
}
public interface IRequiredUniversalWord {
IBuild universalWord(UniversalWord universalWord);
}
public interface IBuild {
Restriction buildRestriction();
}
private static class Builder implements IRequiredLabel, IRequiredUniversalWord, IOrientation, IBuild {
private final RestrictionBuilder instance;
public Builder(){
instance = new RestrictionBuilder();
}
@Override
public IBuild universalWord(UniversalWord universalWord) {
instance.universalWord = universalWord;
return this;
}
@Override
public IRequiredUniversalWord withOrientation(RestrictionOrientation orientation) {
switch (orientation) {
case Left:
instance.orientation = '<';
break;
case None:
instance.orientation = ' ';
break;
case Right:
instance.orientation = '>';
break;
}
return this;
}
@Override
public Restriction buildRestriction() {
return new Restriction(instance.label, instance.orientation, instance.universalWord);
}
@Override
public IOrientation label(String label) {
if(null == label)
throw new IllegalArgumentException();
instance.label = label;
return this;
}
}
}
package fr.tetras_libre.unltools.unl.builders;
public enum RestrictionOrientation {
None,
Right,
Left
}
package fr.tetras_libre.unltools.unl.builders;
import fr.tetras_libre.unltools.unl.SubGraphReferenceNode;
import java.util.HashSet;
public class SubGraphReferenceNodeBuilder {
private String referenceNumber;
private HashSet<String> attributes;
public static IRequiredReferenceNumber createBuilder()
{
return new SubGraphReferenceNodeBuilder.Builder();
}
private SubGraphReferenceNodeBuilder() {
referenceNumber = null;
attributes = new HashSet<>();
}
public interface IRequiredReferenceNumber {
IBuild referenceNumber(String referenceNumber);
}
public interface IBuild {
IBuild addAttribute(String attribute);
SubGraphReferenceNode buildSubGraphReferenceNode();
}
private static class Builder implements IRequiredReferenceNumber, IBuild {
SubGraphReferenceNodeBuilder instance;
public Builder() {
instance = new SubGraphReferenceNodeBuilder();
}
@Override
public IBuild referenceNumber(String referenceNumber) {
if (null == referenceNumber || referenceNumber.isBlank())
throw new IllegalArgumentException();
this.instance.referenceNumber = referenceNumber;
return this;
}
@Override
public IBuild addAttribute(String attribute) {
if (null != attribute && !attribute.isBlank())
this.instance.attributes.add(attribute);
return this;
}
@Override
public SubGraphReferenceNode buildSubGraphReferenceNode() {
return new SubGraphReferenceNode(instance.referenceNumber, instance.attributes);
}
}
}
package fr.tetras_libre.unltools.unl.builders;
import fr.tetras_libre.unltools.unl.Restriction;
import fr.tetras_libre.unltools.unl.UniversalWord;
import java.util.TreeSet;
import java.util.function.Function;
public class UniversalWordBuilder {
private final TreeSet<Restriction> restrictions;
private String headWord;
private UniversalWordBuilder() {
restrictions = new TreeSet<>();
}
public static IRequiredHeadWord createBuilder() {
return new UniversalWordBuilder.Builder();
}
public static UniversalWord simpleUniversalWord(String headWord) {
return UniversalWordBuilder.createBuilder()
.headWord(headWord)
.buildUniversalWord();
}
public interface IBuild {
IBuild addRestriction(Function<RestrictionBuilder.IRequiredLabel, RestrictionBuilder.IBuild> f);
IBuild addSimpleRestriction(String label1, RestrictionOrientation orientation, String label2);
IBuild addTernaryTransitiveRestriction(String firstLabel, String secondLabel, String thirdLabel, RestrictionOrientation orientation);
UniversalWord buildUniversalWord();
}
public interface IRequiredHeadWord {
IBuild headWord(String headword);
}
private static class Builder implements IRequiredHeadWord, IBuild {
private final UniversalWordBuilder instance;
Builder() {
instance = new UniversalWordBuilder();
}
@Override
public IBuild addRestriction(Function<RestrictionBuilder.IRequiredLabel, RestrictionBuilder.IBuild> f) {
instance.restrictions.add(f.apply(RestrictionBuilder.createBuilder()).buildRestriction());
return this;
}
@Override
public IBuild addSimpleRestriction(String label1, RestrictionOrientation orientation, String label2) {
instance.restrictions.add(RestrictionBuilder.simpleRestriction(label1, orientation, label2));
return this;
}
@Override
public IBuild addTernaryTransitiveRestriction(String firstLabel, String secondLabel, String thirdLabel, RestrictionOrientation orientation) {
instance.restrictions.add(RestrictionBuilder.ternaryTransitiveRestriction(firstLabel, secondLabel, thirdLabel, orientation));
return this;
}
@Override
public UniversalWord buildUniversalWord() {
return new UniversalWord(instance.headWord, instance.restrictions);
}
@Override
public IBuild headWord(String headword) {
if (null == headword)
throw new IllegalArgumentException();
instance.headWord = headword;
return this;
}
}
}
package fr.tetras_libre.unltools.unl.builders;
import fr.tetras_libre.unltools.unl.UniversalWord;
import fr.tetras_libre.unltools.unl.UniversalWordNode;
import java.util.HashSet;
import java.util.function.Function;
import java.util.function.Supplier;
public class UniversalWordNodeBuilder {
private final HashSet<String> attributes;
private UniversalWord universalWord;
private String instanceNumber;
private UniversalWordNodeBuilder() {
this.attributes = new HashSet<>();
this.instanceNumber = "";
}
public static IRequiredUniversalWord createBuilder() {
return new UniversalWordNodeBuilder.Builder();
}
public interface IRequiredUniversalWord {
IBuild universalWord(Function<UniversalWordBuilder.IRequiredHeadWord, UniversalWordBuilder.IBuild> f);
IBuild simpleUniversalWord(Supplier<String> s);
}
public interface IBuild {
IBuild addAttribute(String attribute);
IBuild instanceNumber(String nodeReference);
UniversalWordNode buildUniversalWordNode();
}
private static class Builder implements IRequiredUniversalWord, IBuild {
private final UniversalWordNodeBuilder instance;
public Builder() {
this.instance = new UniversalWordNodeBuilder();
}
@Override
public IBuild addAttribute(String attribute) {
if (null != attribute
&& !attribute.isBlank())
this.instance.attributes.add(attribute);
return this;
}
@Override
public IBuild instanceNumber(String nodeReference) {
if(null == nodeReference){
throw new IllegalArgumentException();
}
this.instance.instanceNumber = nodeReference;
return this;
}
@Override
public UniversalWordNode buildUniversalWordNode() {
return new UniversalWordNode(instance.universalWord, instance.attributes, instance.instanceNumber);
}
@Override
public IBuild universalWord(Function<UniversalWordBuilder.IRequiredHeadWord, UniversalWordBuilder.IBuild> f) {
instance.universalWord = f.apply(UniversalWordBuilder.createBuilder()).buildUniversalWord();
return this;
}
@Override
public IBuild simpleUniversalWord(Supplier<String> s) {
instance.universalWord = UniversalWordBuilder.simpleUniversalWord(s.get());
return this;
}
}
}
package fr.tetras_libre.unltools.unl.builders;
import fr.tetras_libre.unltools.unl.Graph;
import fr.tetras_libre.unltools.unl.UnlDocumentNode;
import fr.tetras_libre.unltools.unl.UnlDocumentNodeType;
import java.util.function.Function;
public class UnlDocumentNodeBuilder {
private UnlDocumentNodeType unlDocumentNodeType;
private String docNodeLabel;
private Graph graph;
private UnlDocumentNodeBuilder() {
docNodeLabel = null;
graph = null;
}
public static IUnlDocumentNodeType createBuilder() {
return new UnlDocumentNodeBuilder.Builder();
}
public interface IUnlDocumentNodeType {
ILabel withNodeType(UnlDocumentNodeType nodeType);
}
public interface ILabel {
IGraph withLabel(String label);
}
public interface IGraph {
IBuild withGraph(Function<GraphBuilder.IBuild, GraphBuilder.IBuild> f);
}
public interface IBuild {
UnlDocumentNode buildUnlDocumentNode();
}
private static class Builder implements IBuild, ILabel, IGraph, IUnlDocumentNodeType {
private final UnlDocumentNodeBuilder instance;
Builder() {
instance = new UnlDocumentNodeBuilder();
}
@Override
public UnlDocumentNode buildUnlDocumentNode() {
return new UnlDocumentNode(instance.unlDocumentNodeType, instance.docNodeLabel, instance.graph);
}
@Override
public IGraph withLabel(String label) {
if (null == label || label.isBlank())
throw new IllegalArgumentException();
instance.docNodeLabel = label;
return this;
}
@Override
public IBuild withGraph(Function<GraphBuilder.IBuild, GraphBuilder.IBuild> f) {
if (null != instance.graph)
throw new IllegalStateException();
instance.graph = f.apply(GraphBuilder.graph()).buildGraph();
return this;
}
@Override
public ILabel withNodeType(UnlDocumentNodeType nodeType) {
instance.unlDocumentNodeType = nodeType;
return this;
}
}
}
......@@ -23,11 +23,12 @@ public class DotFileGraphExporter implements GraphExporter {
}
private void write(Graph g) throws IOException {
private void write(Graph g) throws IOException, GraphExportException {
try {
this.InternalWrite(g);
} catch (NoEntryNodeException e) {
// TODO : to define what to do here
throw new GraphExportException("Unable to export graph due to unknown node relation", e);
}
}
......@@ -190,7 +191,7 @@ public class DotFileGraphExporter implements GraphExporter {
}
@Override
public void write(List<UnlDocument> documents) throws IOException {
public void write(List<UnlDocument> documents) throws IOException, GraphExportException {
for (var document : documents) {
for (var documentNode : document.getDocElements()) {
this.write(documentNode.getGraph());
......
......@@ -22,8 +22,9 @@ public class UnlGraphImporterFromUnlParser implements GraphImporter {
@Override
public List<UnlDocument> Import() {
if (documents == null) {
var documentParser = new UnlParser(this.bufferedReader);
try {
documents = new UnlParser(this.bufferedReader).createUnlDocumentList();
documents = documentParser.createUnlDocumentList();
} catch (ParseException e) {
e.printStackTrace();
}
......
......@@ -93,4 +93,64 @@ public class UnlSentences {
"{/unl}\n" +
"[/S]\n" +
"[/D]";
public static final String Issue12 = "[D]\n" +
"[S:00]\n" +
"{org:en}\n" +
"This document defines the functional requirements for ERTMS/ETCS (EUROPEAN RAIL TRAFFIC MANAGEMENT SYSTEM / EUROPEAN TRAIN CONTROL SYSTEM).\n" +
"{/org}\n" +
"{unl}\n" +
"mod(document(icl>writing>thing),this(icl>determiner>adj,mod<concrete_thing))\n" +
"aoj(define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present,document(icl>writing>thing))\n" +
"mod(requirement(icl>duty>thing).@def.@pl,functional(icl>adj,ant>nonfunctional))\n" +
"obj(define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present,requirement(icl>duty>thing).@def.@pl)\n" +
"or(etcs,ertms)\n" +
"pur(requirement(icl>duty>thing).@def.@pl,etcs)\n" +
"mod:01(management(icl>action,agt>volitional_thing,obj>thing),traffic(icl>collection>thing))\n" +
"mod(:03.@_hn-scope,management(icl>action,agt>volitional_thing,obj>thing))\n" +
"or:03(european(icl>inhabitant>person).@entry,system(icl>group>thing):01.@entry)\n" +
"mod:01(control(icl>power>thing),train(icl>public_transport>thing))\n" +
"mod:01(system(icl>group>thing):02,control(icl>power>thing))\n" +
"agt:02(rail(icl>complain>do,rsn>thing,agt>volitional_thing).@entry.@present,:01.@entry.@parenthesis)\n" +
"rsn:02(rail(icl>complain>do,rsn>thing,agt>volitional_thing).@entry.@present,:01.@entry.@parenthesis)\n" +
"shd(etcs,:02)\n" +
"mod(train(icl>public_transport>thing),:03.@_hn-scope)\n" +
"{/unl}\n" +
"[/S]\n" +
// "[S:00]\n" +
// "{org:en}\n" +
// "The document primarily defines the operational requirements and therefore contains only a few technical terms.\n" +
// "{/org}\n" +
// "{unl}\n" +
// "aoj(define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present,document(icl>writing>thing).@def)\n" +
// "man(define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present,primarily(icl>how,equ>mainly))\n" +
// "and(:01,define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present)\n" +
// "mod(requirement(icl>duty>thing).@def.@pl,operational(icl>adj,com>operation))\n" +
// "obj(define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present,requirement(icl>duty>thing).@def.@pl)\n" +
// "man:01(contain(icl>be,equ>comprise,obj>abstract_thing,aoj>information,pur>abstract_thing).@entry.@present,therefore(icl>how))\n" +
// "man:01(term(icl>word>thing,mod>thing).@pl,only(icl>how,equ>recently))\n" +
// "qua:01(term(icl>word>thing,mod>thing).@pl,a_few(icl>adj,equ>some,qua<thing))\n" +
// "mod:01(term(icl>word>thing,mod>thing).@pl,technical(icl>adj,ant>nontechnical))\n" +
// "obj:01(contain(icl>be,equ>comprise,obj>abstract_thing,aoj>information,pur>abstract_thing).@entry.@present,term(icl>word>thing,mod>thing).@pl)\n" +
// "{/unl}\n" +
// "[/S]\n" +
// "[S:00]\n" +
// "{org:en}\n" +
// "For consistency reasons, all functional requirements not implemented in the SRS 2.3.0 have been removed from this version..\n" +
// "{/org}\n" +
// "{unl}\n" +
// "agt:01(reason(icl>persuade>do,agt>thing,gol>uw,rec>person).@entry.@present,consistency(icl>uniformity>thing,ant>inconsistency))\n" +
// "qua:02(requirement(icl>duty>thing).@pl,all(icl>quantity,ant>some,per>thing))\n" +
// "mod:02(requirement(icl>duty>thing).@pl,functional(icl>adj,ant>nonfunctional))\n" +
// "agt:02(implement(icl>employ>do,agt>thing,obj>thing).@past.@not,requirement(icl>duty>thing).@pl)\n" +
// "plc(remove(icl>dismiss>do,plf>thing,agt>volitional_thing,obj>person).@entry.@present.@complete,srs.@def)\n" +
// "obj(remove(icl>dismiss>do,plf>thing,agt>volitional_thing,obj>person).@entry.@present.@complete,\"2.3\".@topic)\n" +
// "mod(\"2.3\".@topic,\".0\")\n" +
// "mod(version(icl>interpretation>abstract_thing,agt>thing,obj>uw),this(icl>determiner>adj,mod<concrete_thing))\n" +
// "plf(remove(icl>dismiss>do,plf>thing,agt>volitional_thing,obj>person).@entry.@present.@complete,version(icl>interpretation>abstract_thing,agt>thing,obj>uw))\n" +
// "and(implement(icl>employ>do,agt>thing,obj>thing).@past.@not,:01)\n" +
// "rsn(remove(icl>dismiss>do,plf>thing,agt>volitional_thing,obj>person).@entry.@present.@complete,:02)\n" +
// "{/unl}\n" +
// "[/S]\n" +
"[/D]";
}
......@@ -30,6 +30,21 @@ class DotFileBuilderTest {
this.writeInFile(new AllUnl().getUnlDocuments(), new AllSetenceWithExpectedDotChecker());
}
@Test
public void Issue12shouldBeExportedInDotFormatWithoutException(){
// Startup
Writer strResult = new StringWriter();
DotFileGraphExporter dotFileBuilder = new DotFileGraphExporter(strResult);
// Test
Assertions.assertDoesNotThrow(() -> dotFileBuilder.write(new Issue12Unl().getUnlDocuments()));
// Teardown
Assertions.assertDoesNotThrow(strResult::flush);
Assertions.assertTrue(() -> strResult.toString().length() != 0);
Assertions.assertDoesNotThrow(strResult::close);
}
private void writeInFile(List<UnlDocument> unlDocuments, SentenceWithExpectedDotChecker sentenceChecker) {
// Startup
Writer strResult = new StringWriter();
......@@ -39,11 +54,11 @@ class DotFileBuilderTest {
Assertions.assertDoesNotThrow(() -> dotFileBuilder.write(unlDocuments));
// Teardown
Assertions.assertDoesNotThrow(() -> strResult.flush());
Assertions.assertDoesNotThrow(strResult::flush);
Assertions.assertTrue(() -> strResult.toString().length() != 0);
Assertions.assertDoesNotThrow(() -> sentenceChecker.setCurrentDotContent(strResult.toString()));
sentenceChecker.assetSameAsExpected();
Assertions.assertDoesNotThrow(() -> strResult.close());
Assertions.assertDoesNotThrow(strResult::close);
}
}
\ No newline at end of file
package fr.tetras_libre.unltools.unl.parser;
import fr.tetras_libre.unltools.unl.Issue12Unl;
import fr.tetras_libre.unltools.unl.UnlDocument;
import fr.tetras_libre.unltools.unl.UnlSentences;
import java.util.List;
public class Issue12WithExpectedUnlDocumentsChecker extends SentenceWithExpectedUnlDocumentsChecker {
public Issue12WithExpectedUnlDocumentsChecker() {
super(UnlSentences.Issue12, new Issue12Unl().getUnlDocuments());
}
}
......@@ -16,11 +16,12 @@ class UnlParserTest {
return Stream.of(new R1SentenceWithExpectedUnlDocumentsChecker(),
new R2SentenceWithExpectedUnlDocumentsChecker(),
new CatsSentenceWithExpectedUnlDocumentsChecker(),
new AllSentenceWithExpectedUnlDocumentsChecker());
new AllSentenceWithExpectedUnlDocumentsChecker(),
new Issue12WithExpectedUnlDocumentsChecker());
}
@ParameterizedTest
@ValueSource(strings = {UnlSentences.R1, UnlSentences.R2, UnlSentences.Cats, UnlSentences.All})
@ValueSource(strings = {UnlSentences.R1, UnlSentences.R2, UnlSentences.Cats, UnlSentences.All, UnlSentences.Issue12})
void unlParserShouldParseSimpleSentenceWithoutException(String input) {
UnlParserFactory unlFactory = new UnlParserFactoryFromString(input);
var wrapper = createAndCheckUnlParserValidity(unlFactory);
......
......@@ -8,6 +8,7 @@ import fr.tetras_libre.unltools.unl.exporters.GraphExporterNames;
import fr.tetras_libre.unltools.unl.parser.UnlGraphImporterFromUnlParser;
import picocli.CommandLine;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
......@@ -43,9 +44,9 @@ public class Unl2Rdf {
String extension = ToExtension(outType);
String outfileName = options.getOutputFile() + extension;
FileWriter fileWriter = new FileWriter(outfileName, false);
var convertCommand = new ExportUnlDocuments(importer, GetExporterName(outType), fileWriter);
var bufferedWriter = new BufferedWriter(fileWriter);
var convertCommand = new ExportUnlDocuments(importer, GetExporterName(outType), bufferedWriter);
handler.handle(convertCommand);
fileWriter.close();
System.out.println(String.format("Graph writen into file '%s'", outfileName));
}
}
......
......@@ -44,6 +44,12 @@ class Unl2RdfTest {
Assertions.assertDoesNotThrow(() -> Unl2Rdf.main(new String[]{"--input-file", "../Examples/exemples_unl.txt", "--output-file", "exemples_unl", "--output-type", "rdf"}));
}
@Tag("integration")
@Test
public void issue12ShouldBeConvertedToDotFile() {
Assertions.assertDoesNotThrow(() -> Unl2Rdf.main(new String[]{"--input-file", "../Examples/issue12.txt", "--output-file", "issue12", "--output-type", "dot"}));
}
static class TestMainShouldNotThrowOnPartialParameterArgumentProvider implements ArgumentsProvider {
@Override
......