save before apply thing from l3
This commit is contained in:
22
README.md
22
README.md
@@ -19,26 +19,22 @@ entity ::= Entity(String)
|
|||||||
|
|
||||||
turtle ::= Turtle(phrase*)
|
turtle ::= Turtle(phrase*)
|
||||||
phrase ::= Phrase(entity, aff*)
|
phrase ::= Phrase(entity, aff*)
|
||||||
phrase.s = entity.val
|
aff*.s = entity.val
|
||||||
aff ::= Aff(ntity, complement*)
|
aff ::= Aff(entity, complement*)
|
||||||
aff.s = phrase.s
|
complement*.s = aff.s
|
||||||
aff.v = enity.val
|
complement*.v = entity.val
|
||||||
complement ::= Complement(entity)
|
complement ::= Complement(entity)
|
||||||
phrase.s = aff.s
|
complement.c = entity.val
|
||||||
phrase.v = aff.v
|
|
||||||
phrase.c = entity.val
|
|
||||||
| Complement_Text(String)
|
| Complement_Text(String)
|
||||||
phrase.s = aff.s
|
complement.c = String.self
|
||||||
phrase.v = aff.v
|
|
||||||
phrase.c = String.self
|
|
||||||
entity ::= Entity(String)
|
entity ::= Entity(String)
|
||||||
entity.val=String.self
|
entity.val=String.self
|
||||||
|
|
||||||
```
|
```
|
||||||
|TAD |Nom d'attribut |Type | Polarité
|
|TAD |Nom d'attribut |Type | Polarité
|
||||||
|----------------|-----------------|---------------------|---------|
|
|----------------|-----------------|---------------------|---------|
|
||||||
|phrase |s |String |H
|
|phrase | |String |H
|
||||||
|aff |s |String |H
|
|aff | |String |H
|
||||||
|aff |v |String |H
|
|
||||||
|complement |s |String |H
|
|complement |s |String |H
|
||||||
|complement |v |String |H
|
|complement |v |String |H
|
||||||
|complement |c |String |H/S
|
|complement |c |String |H/S
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ options {
|
|||||||
|
|
||||||
}
|
}
|
||||||
prog : bloc EOF
|
prog : bloc EOF
|
||||||
|
{$t = new TurtleAST()}
|
||||||
;
|
;
|
||||||
bloc : sujet listvc P manyb // <entity> list.
|
bloc : sujet listvc P manyb // <entity> list.
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -1,8 +1,63 @@
|
|||||||
package TP1;
|
package TP1;
|
||||||
|
|
||||||
public class TurtleAST {
|
import java.util.ArrayList;
|
||||||
public TurtleAST(){
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TurtleAST {
|
||||||
|
|
||||||
|
sealed interface Ntriple{}
|
||||||
|
sealed interface Phrase{}
|
||||||
|
sealed interface Entity{}
|
||||||
|
|
||||||
|
|
||||||
|
record NtripleImp(List<PhraseImp> phrases) implements Ntriple{
|
||||||
|
public String toString(){
|
||||||
|
String str = "";
|
||||||
|
for (PhraseImp phrase : this.phrases) {
|
||||||
|
str += phrase.toString() + ".\n" ;
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
record PhraseImp(EntityImp s, EntityImp v, EntityImp c) implements Phrase{
|
||||||
|
public String toString(){
|
||||||
|
return s.toString() + " " + v.toString() + " " + c.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
record EntityImp(String val, Boolean isText) implements Entity{
|
||||||
|
public String toString(){
|
||||||
|
String str="";
|
||||||
|
if(isText) str = "\"" + val + "\"";
|
||||||
|
else str = "<" + val + ">";
|
||||||
|
return str;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String currentSujet;
|
||||||
|
String currentVerbe;
|
||||||
|
List<PhraseImp> listPhrases;
|
||||||
|
Ntriple ntriple;
|
||||||
|
public TurtleAST(){
|
||||||
|
this.listPhrases = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSujet(String sujet){
|
||||||
|
this.currentSujet=sujet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addVerbe(String verbe){
|
||||||
|
this.currentVerbe=verbe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addComplement(String complement, Boolean isText){
|
||||||
|
EntityImp s = new EntityImp(currentSujet, false);
|
||||||
|
EntityImp v = new EntityImp(currentVerbe, false);
|
||||||
|
EntityImp c = new EntityImp(complement, isText);
|
||||||
|
PhraseImp phrase = new PhraseImp(s,v,c);
|
||||||
|
this.listPhrases.add(phrase);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void finishNtriple(){
|
||||||
|
this.ntriple = new NtripleImp(listPhrases);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user