Commit aa9f752a authored by Andrea Cascallar Fuentes's avatar Andrea Cascallar Fuentes

Refactorización código

parent 1de6ba8c
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -45,6 +45,13 @@ public abstract class AggregationRule {
this.factory = new NLGFactory();
}
/**
* Creates a new instance of AggregationRule
*/
public AggregationRule(NLGFactory factory) {
this.factory = factory;
}
/**
* @return the factory being used by this rule to create phrases
*/
......
......@@ -22,6 +22,7 @@ import simplenlg.features.Feature;
import simplenlg.features.InternalFeature;
import simplenlg.framework.CoordinatedPhraseElement;
import simplenlg.framework.NLGElement;
import simplenlg.framework.NLGFactory;
import simplenlg.framework.PhraseCategory;
import java.util.List;
......@@ -62,6 +63,13 @@ public class ClauseCoordinationRule extends AggregationRule {
super();
}
/**
* Constructs an instance of the ClauseCoordinationRule
*/
public ClauseCoordinationRule(NLGFactory factory) {
super(factory);
}
/**
* Applies aggregation to two NLGElements e1 and e2, succeeding only if they
* are clauses (that is, e1.getCategory() == e2.getCategory ==
......
......@@ -92,7 +92,7 @@ public class CoordinatedPhraseElement extends NLGElement {
* @param coordinate1 the first coordinate.
* @param coordinate2 the second coordinate.
*/
public CoordinatedPhraseElement(Object coordinate1, Object coordinate2) {
public CoordinatedPhraseElement(Object coordinate1, Object coordinate2) {
this(coordinate1, coordinate2, new NLGFactory());
}
......
......@@ -19,9 +19,7 @@
package simplenlg.framework;
import simplenlg.features.InternalFeature;
import simplenlg.features.LexicalFeature;
import simplenlg.lexicon.Lexicon;
import simplenlg.lexicon.galician.XMLLexicon;
import simplenlg.phrasespec.*;
import java.util.List;
......@@ -86,8 +84,12 @@ public class NLGFactory {
* Gets the lexicon used by this factory.
*/
public Lexicon getLexicon() {
if (lexicon == null)
this.lexicon = new XMLLexicon();
if (lexicon == null) {
//if lexicon == null, gets default lexicon
this.lexicon = Lexicon.getDefaultLexicon();
}
return this.lexicon;
}
......@@ -168,7 +170,7 @@ public class NLGFactory {
inflElement = new InflectedWordElement((WordElement) word);
} else if (word instanceof String) {
NLGElement baseword = createWord((String) word, category);
NLGElement baseword = createWord(word, category);
if (baseword != null && baseword instanceof WordElement) {
inflElement = new InflectedWordElement((WordElement) baseword);
......@@ -193,7 +195,7 @@ public class NLGFactory {
*/
@SuppressWarnings("unused")
private void doLexiconLookUp(LexicalCategory category, String word, NLGElement wordElement) {
WordElement baseWord = null;
WordElement baseWord;
if (LexicalCategory.NOUN.equals(category) && this.lexicon.hasWord(word, LexicalCategory.PRONOUN)) {
baseWord = this.lexicon.lookupWord(word, LexicalCategory.PRONOUN);
......@@ -371,13 +373,13 @@ public class NLGFactory {
if (specifier != null) {
//when possesive + noun add determiner -> determiner + possesive + noun
if(specifier.toString().equals("meu") || specifier.toString().equals("teu") || specifier.toString().equals("seu") || specifier.toString().equals("noso") || specifier.toString().equals("voso")) {
if (specifier.toString().equals("meu") || specifier.toString().equals("teu") || specifier.toString().equals("seu") || specifier.toString().equals("noso") || specifier.toString().equals("voso")) {
phraseElement.setSpecifier("o");
phraseElement.addSpecifier(specifier);
} else if (specifier.toString().equals("miña") || specifier.toString().equals("túa") || specifier.toString().equals("súa") || specifier.toString().equals("nosa") || specifier.toString().equals("vosa")) {
phraseElement.setSpecifier("a");
phraseElement.addSpecifier(specifier);
} else if(specifier.toString().equals("meus") || specifier.toString().equals("teus") || specifier.toString().equals("seus") || specifier.toString().equals("nosos") || specifier.toString().equals("vosos")) {
} else if (specifier.toString().equals("meus") || specifier.toString().equals("teus") || specifier.toString().equals("seus") || specifier.toString().equals("nosos") || specifier.toString().equals("vosos")) {
phraseElement.setSpecifier("os");
phraseElement.addSpecifier(specifier);
} else if (specifier.toString().equals("miñas") || specifier.toString().equals("túas") || specifier.toString().equals("súas") || specifier.toString().equals("nosas") || specifier.toString().equals("vosas")) {
......
......@@ -130,9 +130,36 @@ public abstract class Lexicon {
* @return default lexicon
*/
public static Lexicon getDefaultLexicon() {
return new simplenlg.lexicon.galician.XMLLexicon();
}
/**
* returns the English built-in lexicon
*
* @return default lexicon
*/
public static Lexicon getEnglishLexicon() {
return new simplenlg.lexicon.english.XMLLexicon();
}
/**
* returns the Spanish built-in lexicon
*
* @return default lexicon
*/
public static Lexicon getSpanishLexicon() {
return new simplenlg.lexicon.spanish.XMLLexicon();
}
/**
* returns the Galician built-in lexicon
*
* @return default lexicon
*/
public static Lexicon getGalicianLexicon() {
return new simplenlg.lexicon.galician.XMLLexicon();
}
/**
* Gets the language used by this factory.
*/
......
......@@ -139,72 +139,78 @@ public abstract class Realiser extends NLGModule {
debug.append("<br/>POST-SYNTAX TREE<br/>");
debug.append(postSyntax.printTree("&nbsp;&nbsp;").replaceAll("\n", "<br/>"));
}
//////////////////////////////verb + pronoun colocation/////////////////////////////////////////////////
//////////////////////////////Galician verb + pronoun colocation/////////////////////////////////////////////////
//negated and interrogative sentences: verb+pronoun
if(postSyntax.getCategory() != null && postSyntax.getCategory().equals(DocumentCategory.SENTENCE)) {
if (postSyntax.getFeatureAsBoolean(Feature.NEGATED) == false && postSyntax.getFeatureAsBoolean(Feature.INTERROGATIVE_TYPE) == false) {
pronoun_after = true;
}
List<NLGElement> elements = new ArrayList<NLGElement>();
if (postSyntax instanceof ListElement || postSyntax instanceof DocumentElement) {
elements.addAll(postSyntax.getChildren());
} else {
elements.add(postSyntax);
}
try {
if (this.syntax.getLexicon() != null && this.syntax.getLexicon().getLanguage().equals(Language.GALICIAN) /*&& postSyntax.getCategory() != null && postSyntax.getCategory().equals(DocumentCategory.SENTENCE)*/) {
if (postSyntax.getFeatureAsBoolean(Feature.NEGATED) == false && postSyntax.getFeatureAsBoolean(Feature.INTERROGATIVE_TYPE) == false) {
pronoun_after = true;
}
List<NLGElement> elements = new ArrayList<NLGElement>();
if (postSyntax instanceof ListElement || postSyntax instanceof DocumentElement) {
elements.addAll(postSyntax.getChildren());
} else {
elements.add(postSyntax);
}
elements = checkElements(elements);
elements = checkElements(elements);
int indexVerb = -1, indexSubordinate = -1, indexAdverb = -1, indexIndefinite = -1, indexInterrogative = -1, indexDesiderative = -1;
for (NLGElement e : elements) {
try {
if (e.getCategory().equals(LexicalCategory.VERB)) {
indexVerb = elements.indexOf(e);
}
} catch (Exception ex) {
int indexVerb = -1, indexSubordinate = -1, indexAdverb = -1, indexIndefinite = -1, indexInterrogative = -1, indexDesiderative = -1;
for (NLGElement e : elements) {
try {
if (e.getCategory().equals(LexicalCategory.VERB)) {
indexVerb = elements.indexOf(e);
}
} catch (Exception ex) {
try {
if (Arrays.asList(SUBORDINATES).contains(e.getRealisation())) {
indexSubordinate = elements.indexOf(e);
}
if (Arrays.asList(ADVERBS).contains(e.getRealisation()) || e.getCategory().equals(LexicalCategory.ADVERB)) {
indexAdverb = elements.indexOf(e);
}
if (Arrays.asList(INDEFINITES).contains(e.getRealisation())) {
indexIndefinite = elements.indexOf(e);
}
if (Arrays.asList(INTERROGATIVES).contains(e.getRealisation())) {
indexInterrogative = elements.indexOf(e);
}
if (Arrays.asList(DESIDERATIVES).contains(e.getRealisation())) {
indexDesiderative = elements.indexOf(e);
}
} catch (Exception ex) {
}
}
try {
if (Arrays.asList(SUBORDINATES).contains(e.getRealisation())) {
indexSubordinate = elements.indexOf(e);
if (indexVerb >= 0) {
//subordinates sentences: pronoun before
if (indexSubordinate >= 0 && indexSubordinate < indexVerb) {
pronoun_after = false;
}
if (Arrays.asList(ADVERBS).contains(e.getRealisation()) || e.getCategory().equals(LexicalCategory.ADVERB)) {
indexAdverb = elements.indexOf(e);
//with some adverbs: pronoun before
if (indexAdverb >= 0 && indexAdverb < indexVerb) {
pronoun_after = false;
}
if (Arrays.asList(INDEFINITES).contains(e.getRealisation())) {
indexIndefinite = elements.indexOf(e);
//with some indefinites: pronoun before
if (indexIndefinite >= 0 && indexIndefinite < indexVerb) {
pronoun_after = false;
}
if (Arrays.asList(INTERROGATIVES).contains(e.getRealisation())) {
indexInterrogative = elements.indexOf(e);
//with interrogatives: pronoun before
if (indexInterrogative >= 0 && indexInterrogative < indexVerb) {
pronoun_after = false;
}
if (Arrays.asList(DESIDERATIVES).contains(e.getRealisation())) {
indexDesiderative = elements.indexOf(e);
//in desideratives phrases: pronoun before
if (indexDesiderative >= 0 && indexDesiderative < indexVerb) {
pronoun_after = false;
}
} catch (Exception ex) {
}
}
if (indexVerb >= 0) {
//subordinates sentences: pronoun before
if (indexSubordinate >= 0 && indexSubordinate < indexVerb) {
pronoun_after = false;
}
//with some adverbs: pronoun before
if (indexAdverb >= 0 && indexAdverb < indexVerb) {
pronoun_after = false;
}
//with some indefinites: pronoun before
if (indexIndefinite >= 0 && indexIndefinite < indexVerb) {
pronoun_after = false;
}
//with interrogatives: pronoun before
if (indexInterrogative >= 0 && indexInterrogative < indexVerb) {
pronoun_after = false;
}
//in desideratives phrases: pronoun before
if (indexDesiderative >= 0 && indexDesiderative < indexVerb) {
pronoun_after = false;
}
} else {
pronoun_after = true;
}
}catch (Exception e) {
}
postSyntax.setFeature(Feature.PRONOUN_AFTER, pronoun_after);
......
......@@ -292316,7 +292316,7 @@
<base>quen</base>
<category>pronoun</category>
<gender>neuter</gender>
<number>singular</number>
<number>both</number>
<person>none</person>
</word>
<word>
......@@ -47,7 +47,7 @@ public class ExternalTest {
@Before
public void setup() {
lexicon = Lexicon.getDefaultLexicon();
lexicon = Lexicon.getEnglishLexicon();
phraseFactory = new NLGFactory(lexicon);
realiser = new Realiser(lexicon);
}
......@@ -143,7 +143,7 @@ public class ExternalTest {
verbPhrase1 = this.phraseFactory.createVerbPhrase("perform"); //$NON-NLS-1$
CoordinatedPhraseElement coord1 = new CoordinatedPhraseElement(noun2,
noun3);
noun3, phraseFactory);
sentence1 = this.phraseFactory.createClause(noun1, verbPhrase1, coord1);
sentence1.setFeature(Feature.TENSE,Tense.PAST);
......@@ -418,7 +418,7 @@ public class ExternalTest {
// aggregation
SPhraseSpec s1 = this.phraseFactory.createClause("the man", "be", "hungry");
SPhraseSpec s2 = this.phraseFactory.createClause("the man", "buy", "an apple");
NLGElement result = new ClauseCoordinationRule().apply(s1, s2);
NLGElement result = new ClauseCoordinationRule(this.phraseFactory).apply(s1, s2);
Assert.assertEquals("The man is hungry and buys an apple.", realiser.realiseSentence(result));
}
......
......@@ -18,6 +18,7 @@
*/
package simplenlg.external.galician;
import gov.nih.nlm.nls.lvg.Lib.Category;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
......@@ -34,6 +35,7 @@ import simplenlg.realiser.galician.Realiser;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
/**
* Tests from third parties
......
......@@ -55,7 +55,7 @@ public class RealiserTest {
@Before
public void setup() {
lexicon = Lexicon.getDefaultLexicon();
lexicon = Lexicon.getEnglishLexicon();
nlgFactory = new NLGFactory(lexicon);
realiser = new Realiser(lexicon);
}
......
......@@ -75,7 +75,7 @@ public class AdjectivePhraseTest extends SimpleNLG4Test {
// coordinate the two aps
CoordinatedPhraseElement coordap = new CoordinatedPhraseElement(
this.salacious, this.beautiful);
this.salacious, this.beautiful, this.phraseFactory);
Assert.assertEquals("incredibly salacious and amazingly beautiful", //$NON-NLS-1$
this.realiser.realise(coordap).getRealisation());
......@@ -86,7 +86,7 @@ public class AdjectivePhraseTest extends SimpleNLG4Test {
// coordinate this with a new AdjPhraseSpec
CoordinatedPhraseElement coord2 = new CoordinatedPhraseElement(coordap,
this.stunning);
this.stunning, this.phraseFactory);
Assert.assertEquals(
"incredibly salacious or amazingly beautiful and stunning", //$NON-NLS-1$
this.realiser.realise(coord2).getRealisation());
......@@ -95,7 +95,7 @@ public class AdjectivePhraseTest extends SimpleNLG4Test {
// "seriously and undeniably incredibly salacious or amazingly beautiful
// and stunning"
CoordinatedPhraseElement preMod = new CoordinatedPhraseElement(
new StringElement("seriously"), new StringElement("undeniably")); //$NON-NLS-1$//$NON-NLS-2$
new StringElement("seriously"), new StringElement("undeniably"), this.phraseFactory); //$NON-NLS-1$//$NON-NLS-2$
coord2.addPreModifier(preMod);
Assert.assertEquals(
......
......@@ -427,7 +427,7 @@ public class ClauseTest extends SimpleNLG4Test {
s5.setObject(this.phraseFactory.createNounPhrase("the", "cat")); //$NON-NLS-1$ //$NON-NLS-2$
CoordinatedPhraseElement coord = new CoordinatedPhraseElement(this.s3,
s5);
s5, this.phraseFactory);
complexS = this.phraseFactory.createClause();
complexS.setVerbPhrase(this.phraseFactory.createVerbPhrase("upset")); //$NON-NLS-1$
complexS.setFeature(Feature.TENSE, Tense.PAST);
......@@ -455,7 +455,7 @@ public class ClauseTest extends SimpleNLG4Test {
complexS.setFeature(Feature.TENSE, Tense.PAST);
complexS.setObject(this.phraseFactory.createNounPhrase("Peter")); //$NON-NLS-1$
s6.setObject(complexS);
coord = new CoordinatedPhraseElement(this.s3, s5);
coord = new CoordinatedPhraseElement(this.s3, s5, this.phraseFactory);
complexS.setSubject(coord);
this.s3.setFeature(Feature.PERFECT, true);
Assert.assertEquals(
......@@ -495,7 +495,7 @@ public class ClauseTest extends SimpleNLG4Test {
// the coordinate sentence allows us to raise and lower complementiser
CoordinatedPhraseElement coord2 = new CoordinatedPhraseElement(this.s1,
this.s3);
this.s3, this.phraseFactory);
coord2.setFeature(Feature.TENSE, Tense.PAST);
this.realiser.setDebugMode(true);
......@@ -635,7 +635,7 @@ public class ClauseTest extends SimpleNLG4Test {
// test agreement in passive
PhraseElement _s3 = this.phraseFactory.createClause(
new CoordinatedPhraseElement("my dog", "your cat"), "chase", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new CoordinatedPhraseElement("my dog", "your cat", this.phraseFactory), "chase", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"George"); //$NON-NLS-1$
_s3.setFeature(Feature.TENSE, Tense.PAST);
_s3.addFrontModifier("yesterday"); //$NON-NLS-1$
......@@ -643,7 +643,7 @@ public class ClauseTest extends SimpleNLG4Test {
this.realiser.realise(_s3).getRealisation());
_s3 = this.phraseFactory.createClause(new CoordinatedPhraseElement(
"my dog", "your cat"), "chase", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"my dog", "your cat", this.phraseFactory), "chase", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
this.phraseFactory.createNounPhrase("George")); //$NON-NLS-1$
_s3.setFeature(Feature.TENSE, Tense.PAST);
_s3.addFrontModifier("yesterday"); //$NON-NLS-1$
......
......@@ -196,7 +196,7 @@ public class FeatureTest extends SimpleNLG4Test {
NLGElement albert = phraseFactory.createWord("Albert", LexicalCategory.NOUN);
CoordinatedPhraseElement coord1 = new CoordinatedPhraseElement(
dave, albert);
dave, albert, this.phraseFactory);
PhraseElement born = phraseFactory.createClause(coord1, "be", "born");
born.setFeature(Feature.TENSE,Tense.PAST);
......
......@@ -83,7 +83,7 @@ public class InterrogativeTest extends SimpleNLG4Test {
CoordinatedPhraseElement subjects = new CoordinatedPhraseElement(
this.phraseFactory.createNounPhrase("Jane"), //$NON-NLS-1$
this.phraseFactory.createNounPhrase("Andrew")); //$NON-NLS-1$
this.phraseFactory.createNounPhrase("Andrew"), this.phraseFactory); //$NON-NLS-1$
this.s4 = this.phraseFactory.createClause(subjects, "pick up", //$NON-NLS-1$
"the balls"); //$NON-NLS-1$
this.s4.addPostModifier("in the shop"); //$NON-NLS-1$
......@@ -184,7 +184,7 @@ public class InterrogativeTest extends SimpleNLG4Test {
setUp();
CoordinatedPhraseElement subjects = new CoordinatedPhraseElement(
this.phraseFactory.createNounPhrase("Jane"), //$NON-NLS-1$
this.phraseFactory.createNounPhrase("Andrew")); //$NON-NLS-1$
this.phraseFactory.createNounPhrase("Andrew"), this.phraseFactory); //$NON-NLS-1$
this.s4 = this.phraseFactory.createClause(subjects, "pick up", //$NON-NLS-1$
"the balls"); //$NON-NLS-1$
this.s4.addPostModifier("in the shop"); //$NON-NLS-1$
......@@ -218,7 +218,7 @@ public class InterrogativeTest extends SimpleNLG4Test {
// balls in the shop
CoordinatedPhraseElement subjects = new CoordinatedPhraseElement(
this.phraseFactory.createNounPhrase("Jane"), //$NON-NLS-1$
this.phraseFactory.createNounPhrase("Andrew")); //$NON-NLS-1$
this.phraseFactory.createNounPhrase("Andrew"), this.phraseFactory); //$NON-NLS-1$
this.s4 = this.phraseFactory.createClause(subjects, "pick up", //$NON-NLS-1$
"the balls"); //$NON-NLS-1$
this.s4.addPostModifier("in the shop"); //$NON-NLS-1$
......@@ -241,7 +241,7 @@ public class InterrogativeTest extends SimpleNLG4Test {
// create a complex vp: "kiss the dog and walk in the room"
setUp();
CoordinatedPhraseElement complex = new CoordinatedPhraseElement(
this.kiss, this.walk);
this.kiss, this.walk, this.phraseFactory);
this.kiss.addComplement(this.dog);
this.walk.addComplement(this.inTheRoom);
......@@ -249,7 +249,7 @@ public class InterrogativeTest extends SimpleNLG4Test {
// will walk in the room"
CoordinatedPhraseElement subjects = new CoordinatedPhraseElement(
this.phraseFactory.createNounPhrase("Jane"), //$NON-NLS-1$
this.phraseFactory.createNounPhrase("Andrew")); //$NON-NLS-1$
this.phraseFactory.createNounPhrase("Andrew"), this.phraseFactory); //$NON-NLS-1$
this.s4 = this.phraseFactory.createClause(subjects, complex);
this.s4.setFeature(Feature.CUE_PHRASE, "however"); //$NON-NLS-1$
this.s4.addFrontModifier("tomorrow"); //$NON-NLS-1$
......@@ -264,10 +264,10 @@ public class InterrogativeTest extends SimpleNLG4Test {
setUp();
subjects = new CoordinatedPhraseElement(
this.phraseFactory.createNounPhrase("Jane"), //$NON-NLS-1$
this.phraseFactory.createNounPhrase("Andrew")); //$NON-NLS-1$
this.phraseFactory.createNounPhrase("Andrew"), this.phraseFactory); //$NON-NLS-1$
this.kiss.addComplement(this.dog);
this.walk.addComplement(this.inTheRoom);
complex = new CoordinatedPhraseElement(this.kiss, this.walk);
complex = new CoordinatedPhraseElement(this.kiss, this.walk, this.phraseFactory);
this.s4 = this.phraseFactory.createClause(subjects, complex);
this.s4.setFeature(Feature.CUE_PHRASE, "however"); //$NON-NLS-1$
this.s4.addFrontModifier("tomorrow"); //$NON-NLS-1$
......@@ -283,8 +283,8 @@ public class InterrogativeTest extends SimpleNLG4Test {
this.realiser.setLexicon(this.lexicon);
subjects = new CoordinatedPhraseElement(
this.phraseFactory.createNounPhrase("Jane"), //$NON-NLS-1$
this.phraseFactory.createNounPhrase("Andrew")); //$NON-NLS-1$
complex = new CoordinatedPhraseElement(this.kiss, this.walk);
this.phraseFactory.createNounPhrase("Andrew"), this.phraseFactory); //$NON-NLS-1$
complex = new CoordinatedPhraseElement(this.kiss, this.walk, this.phraseFactory);
this.kiss.addComplement(this.dog);
this.walk.addComplement(this.inTheRoom);
this.s4 = this.phraseFactory.createClause(subjects, complex);
......@@ -812,7 +812,7 @@ public class InterrogativeTest extends SimpleNLG4Test {
*/
@Test
public void testWhatObjectInterrogative() {
Lexicon lexicon = Lexicon.getDefaultLexicon();
Lexicon lexicon = Lexicon.getEnglishLexicon();
NLGFactory nlg = new NLGFactory(lexicon);
Realiser realiser = new Realiser(lexicon);
......
......@@ -315,7 +315,7 @@ public class NounPhraseTest extends SimpleNLG4Test {
public void testCoordination() {
CoordinatedPhraseElement cnp1 = new CoordinatedPhraseElement(this.dog,
this.woman);
this.woman, this.phraseFactory);
// simple coordination
Assert.assertEquals("the dog and the woman", this.realiser //$NON-NLS-1$
.realise(cnp1).getRealisation());
......@@ -344,7 +344,7 @@ public class NounPhraseTest extends SimpleNLG4Test {
this.woman.clearComplements();
CoordinatedPhraseElement cnp1 = new CoordinatedPhraseElement(this.dog,
this.woman);
this.woman, this.phraseFactory);
cnp1.setFeature(Feature.RAISE_SPECIFIER, true);
NLGElement realised = this.realiser.realise(cnp1);
Assert.assertEquals("the dog and woman", realised.getRealisation());
......@@ -353,7 +353,7 @@ public class NounPhraseTest extends SimpleNLG4Test {
this.woman.addComplement(this.behindTheCurtain);
CoordinatedPhraseElement cnp2 = new CoordinatedPhraseElement(this.dog,
this.woman);
this.woman, this.phraseFactory);
this.woman.setFeature(InternalFeature.RAISED, false);
Assert.assertEquals(
......@@ -399,7 +399,7 @@ public class NounPhraseTest extends SimpleNLG4Test {
public void testPossessiveCoordinate() {
// simple coordination
CoordinatedPhraseElement cnp2 = new CoordinatedPhraseElement(this.dog,
this.woman);
this.woman, this.phraseFactory);
Assert.assertEquals("the dog and the woman", this.realiser //$NON-NLS-1$
.realise(cnp2).getRealisation());
......
......@@ -47,7 +47,7 @@ public class PremodifierTest {
@Before
public void setup() {
lexicon = Lexicon.getDefaultLexicon();
lexicon = Lexicon.getEnglishLexicon();
phraseFactory = new NLGFactory(lexicon);
realiser = new Realiser(lexicon);
}
......
......@@ -72,7 +72,7 @@ public class PrepositionalPhraseTest extends SimpleNLG4Test {
this.inTheRoom.clearComplements();
this.inTheRoom.addComplement(new CoordinatedPhraseElement(
this.phraseFactory.createNounPhrase("the", "room"), //$NON-NLS-1$ //$NON-NLS-2$
this.phraseFactory.createNounPhrase("a", "car"))); //$NON-NLS-1$//$NON-NLS-2$
this.phraseFactory.createNounPhrase("a", "car"), this.phraseFactory)); //$NON-NLS-1$//$NON-NLS-2$
Assert.assertEquals("in the room and a car", this.realiser //$NON-NLS-1$
.realise(this.inTheRoom).getRealisation());
}
......@@ -84,7 +84,7 @@ public class PrepositionalPhraseTest extends SimpleNLG4Test {
// simple coordination
CoordinatedPhraseElement coord1 = new CoordinatedPhraseElement(
this.inTheRoom, this.behindTheCurtain);
this.inTheRoom, this.behindTheCurtain, this.phraseFactory);
Assert.assertEquals("in the room and behind the curtain", this.realiser //$NON-NLS-1$
.realise(coord1).getRealisation());
......@@ -102,7 +102,7 @@ public class PrepositionalPhraseTest extends SimpleNLG4Test {
// coordinate two coordinates
CoordinatedPhraseElement coord3 = new CoordinatedPhraseElement(coord1,
coord2);
coord2, this.phraseFactory);
String text = this.realiser.realise(coord3).getRealisation();
Assert
......
......@@ -51,7 +51,7 @@ public class StringElementTest {
@Before
public void setup() {
lexicon = Lexicon.getDefaultLexicon();
lexicon = Lexicon.getEnglishLexicon();
phraseFactory = new NLGFactory(lexicon);
realiser = new Realiser(lexicon);
}
......@@ -339,7 +339,7 @@ public class StringElementTest {
CoordinatedPhraseElement coordinate =
phraseFactory.createCoordinatedPhrase(new StringElement("John is going to Tesco"),
new StringElement("Mary is going to Sainsburys"));
new StringElement("Mary is going to Sainsburys"));
SPhraseSpec sentence = phraseFactory.createClause();
sentence.addComplement(coordinate);
......
......@@ -60,7 +60,7 @@ public class TutorialTest {
*/
@Test
public void section3_Test() {
Lexicon lexicon = Lexicon.getDefaultLexicon(); // default simplenlg lexicon
Lexicon lexicon = Lexicon.getEnglishLexicon();
NLGFactory nlgFactory = new NLGFactory(lexicon); // factory based on lexicon
NLGElement s1 = nlgFactory.createSentence("my dog is happy");
......@@ -95,7 +95,7 @@ public class TutorialTest {
*/
@Test
public void section6_Test() {
Lexicon lexicon = Lexicon.getDefaultLexicon(); // default simplenlg lexicon
Lexicon lexicon = Lexicon.getEnglishLexicon(); // default simplenlg lexicon
NLGFactory nlgFactory = new NLGFactory(lexicon); // factory based on lexicon
Realiser realiser = new Realiser(lexicon);
......@@ -145,7 +145,7 @@ public class TutorialTest {
*/
@Test
public void variantsTest() {
Lexicon lexicon = Lexicon.getDefaultLexicon(); // default simplenlg lexicon
Lexicon lexicon = Lexicon.getEnglishLexicon(); // default simplenlg lexicon
NLGFactory nlgFactory = new NLGFactory(lexicon); // factory based on lexicon
Realiser realiser = new Realiser(lexicon);
......@@ -218,7 +218,7 @@ public class TutorialTest {
*/
@Test
public void section6A_Test() {
Lexicon lexicon = Lexicon.getDefaultLexicon(); // default simplenlg lexicon
Lexicon lexicon = Lexicon.getEnglishLexicon(); // default simplenlg lexicon
NLGFactory nlgFactory = new NLGFactory( lexicon ); // factory based on lexicon
Realiser realiser = new Realiser( lexicon );
......@@ -280,7 +280,7 @@ public class TutorialTest {
*/
@Test
public void section8_Test() {
Lexicon lexicon = Lexicon.getDefaultLexicon(); // default simplenlg lexicon
Lexicon lexicon = Lexicon.getEnglishLexicon(); // default simplenlg lexicon
NLGFactory nlgFactory = new NLGFactory( lexicon ); // factory based on lexicon
Realiser realiser = new Realiser( lexicon );
......@@ -310,7 +310,7 @@ public class TutorialTest {
*/
@Test
public void section10_Test() {
Lexicon lexicon = Lexicon.getDefaultLexicon(); // default simplenlg lexicon
Lexicon lexicon = Lexicon.getEnglishLexicon();
NLGFactory nlgFactory = new NLGFactory( lexicon ); // factory based on lexicon
Realiser realiser = new Realiser( lexicon );
......@@ -391,7 +391,7 @@ public class TutorialTest {