Skip to content
Snippets Groups Projects
Commit 9a34156a authored by Gian-Luca Savino's avatar Gian-Luca Savino
Browse files

initial commit

parents
No related branches found
No related tags found
No related merge requests found
Showing
with 1042 additions and 0 deletions
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="lib" path="/Users/Gian-Luca/Documents/Uni/7. Semester/Bachelor Arbeit/libraries/jsoup-1.8.3.jar"/>
<classpathentry kind="lib" path="/Users/Gian-Luca/Documents/Uni/7. Semester/Bachelor Arbeit/libraries/stanford-postagger-2014-08-27/stanford-postagger.jar"/>
<classpathentry kind="lib" path="/Users/Gian-Luca/Documents/Uni/7. Semester/Bachelor Arbeit/libraries/customsearch/libs/gson-2.1.jar"/>
<classpathentry kind="lib" path="/Users/Gian-Luca/Documents/Uni/7. Semester/Bachelor Arbeit/libraries/disco-2.0.jar"/>
<classpathentry kind="lib" path="/Users/Gian-Luca/Documents/Uni/7. Semester/Bachelor Arbeit/libraries/customsearch"/>
<classpathentry kind="output" path="bin"/>
</classpath>
.project 0 → 100644
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>KitchenAid_0.1</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
encoding//src/Disco.java=UTF-8
encoding//src/Grammar.java=UTF-8
encoding//src/Mergesort.java=UTF-8
encoding//src/SimilarityMachine.java=UTF-8
encoding//src/Substituator.java=UTF-8
encoding//src/main.java=UTF-8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.Iterator;
import java.util.concurrent.ThreadLocalRandom;
import org.apache.lucene.index.CorruptIndexException;
import de.linguatools.disco.Compositionality;
import de.linguatools.disco.CorruptConfigFileException;
import de.linguatools.disco.DISCO;
import edu.stanford.nlp.tagger.maxent.MaxentTagger;
public class Substituator {
//The current grammar
Grammar grammar = new Grammar();
//Instance of Similarity Machine
SimilarityMachine simMachine;
//Instance of Disco
Disco disco;
//Initialize Compositor
Compositionality comp = new Compositionality();
// Initialize the tagger
MaxentTagger tagger = new MaxentTagger("taggers/english-left3words-distsim.tagger");
//The strings that should be substituated
String s1;
String s2;
//Combination of both Strings for better Wordfinding
String combi;
// The tagged string
String tagged1;
String tagged2;
public Substituator(String wordspace, String s1, String s2) throws CorruptIndexException, IOException, CorruptConfigFileException{
this.disco = new Disco(wordspace);
this.simMachine = new SimilarityMachine(wordspace);
this.s1 = s1.replaceAll("\\W", " ");
this.s2 = s2.replaceAll("\\W", " ");
this.combi = s1 + " " + s2;
this.tagged1 = tagger.tagString(s1);
this.tagged2 = tagger.tagString(s2);
}
public ArrayList<String> getNounList(String s){
String[] x = s.split(" ");
ArrayList<String> list = new ArrayList<String>();
for(int i=0;i<x.length;i++)
{
if (x[i].substring(x[i].lastIndexOf("_")+1).startsWith("N"))
{
System.out.println("Ist das in diesem Kontext ein Nomen?");
System.out.println(x[i].split("_")[0]);
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
switch(input){
case "y":
list.add(x[i].split("_")[0]);
case "n":
default:
}
list.add(x[i].split("_")[0]);
}
}
return list;
}
public void substutiuateSentence() throws IOException{
ArrayList<String> nounListString1 = getNounList(tagged1);
ArrayList<String> nounListString2 = getNounList(tagged2);
String string1 = tagger.tagTokenizedString(s1);
String string2 = tagger.tagTokenizedString(s2);
ArrayList<String> result = new ArrayList();
String[] theTwoStrings = {string1, string2};
//Use both sentences for substituation. Loop through both of them
for(String string : theTwoStrings){
//Show the sentence that is currently used for substituation
System.out.println("Der aktuelle Satz ist: " + string);
//Make an array with all the single words from the sentence1
String[] sentence = string.split(" ");
//Loop through the array above
for(int i=0;i<sentence.length;i++)
{
//Check if the current word is included in its own noun list
if(nounListString1.contains(sentence[i].split("_")[0]))
{
//Get the index of the noun in the nounList
int nounIndex = nounListString1.indexOf(sentence[i].split("_")[0]);
//If there is a noun with the same index in noun list 2 swap them
try{
String swapNoun = nounListString2.get(nounIndex);
//Make a new Sentence with the swapped out words
String end = "";
for(int k=0;k<sentence.length;k++){
//i is the index of the word that needs to be swapped
if(k == i){
end = end + nounListString2.get(nounIndex).split("_")[0] + " ";
} else {
end = end + sentence[k].split("_")[0] + " ";
}
}
/**
* Only add if its not already in the list
* Let people decide. Ask in the console if the sentence makes sense.
* Uncomment to use.
*/
if (!result.contains(end)){
System.out.println("Macht dieser Satz sinn? ");
System.out.println(end);
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
//Type 'y' for yes and 'n' for no. Confirm with enter.
//If new sentence has succefully been created. Make a new Pair-Element
switch(input){
case "y":
result.add(end);
for(int l=0; l < grammar.nouns.length; l++){
if(sentence[i].split("_")[0].toLowerCase().equals(grammar.nouns[l].nameOrth)){
String name = nounListString2.get(nounIndex).split("_")[0];
NominalNoun n = new NominalNoun(name.substring(0, 1).toUpperCase() + name.substring(1), grammar.nouns[l].getSubCase(), name);
grammar.makeNounConstruction(n);
}
}
case "n":
default:
}
}
} catch (IndexOutOfBoundsException e) {
System.out.println("Da gabs kein Wort mehr");
}
}
}
}
/*
//Run through the list of candidates and check their similarity. If similar enough swap.
for(int j=0; j < list.size(); j++){
//check Similarity
//If similarity is big enough replace word with similar one
float sim;
try{
sim = simMachine.getWordSimilarity(sentence[i], list.get(j));
//System.out.println(sentence[i].split("_")[0] + " und " + list.get(j) + " sind so ahnlich " + sim);
} catch (NullPointerException ex){
sim = 0;
}
if (sim >= 0.1 && sim < 1.98){
//Make a new Sentence with the swapped out words
String end = "";
for(int k=0;k<sentence.length;k++){
//i is the index of the word that needs to be swapped
if(k == i){
end = end + list.get(j).split("_")[0] + " ";
} else {
end = end + sentence[k].split("_")[0] + " ";
}
}
/**
* Only add if its not already in the list
* Let people decide. Ask in the console if the sentence makes sense.
* Uncomment to use.
*/
/*
if (!result.contains(end)){
System.out.println("Macht dieser Satz sinn? ");
System.out.println(end);
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
//Type 'y' for yes and 'n' for no. Confirm with enter.
//If new sentence has succefully been created. Make a new Pair-Element
switch(input){
case "y":
result.add(end);
for(int l=0; l < grammar.nouns.length; l++){
if(sentence[i].split("_")[0].toLowerCase().equals(grammar.nouns[l].nameOrth)){
String name = list.get(j).split("_")[0];
NominalNoun n = new NominalNoun(name.substring(0, 1).toUpperCase() + name.substring(1), grammar.nouns[l].getSubCase(), name);
grammar.makeNounConstruction(n);
}
}
case "n":
default:
}
}
/**
* Uses GoogleSearch to determine if sentences are semantically correct
* Comment out to use.
System.out.println(end);
GoogleSearch search = new GoogleSearch();
if (search.search(end) > 0){
result.add(end);
for(int l=0; l < grammar.nouns.length; l++){
if(sentence[i].split("_")[0].toLowerCase().equals(grammar.nouns[l].nameOrth)){
String name = list.get(j).split("_")[0];
NominalNoun n = new NominalNoun(name.substring(0, 1).toUpperCase() + name.substring(1), grammar.nouns[l].getSubCase(), name);
grammar.makeNounConstruction(n);
}
}
}*/
/*
}
}
}
}
}
*/
System.out.println(result.toString());
}
}
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.Iterator;
import java.util.concurrent.ThreadLocalRandom;
import org.apache.lucene.index.CorruptIndexException;
import de.linguatools.disco.Compositionality;
import de.linguatools.disco.CorruptConfigFileException;
import de.linguatools.disco.DISCO;
import edu.stanford.nlp.tagger.maxent.MaxentTagger;
public class Substituator {
//The current grammar
Grammar grammar = new Grammar();
//Instance of Similarity Machine
SimilarityMachine simMachine;
//Instance of Disco
Disco disco;
//Initialize Compositor
Compositionality comp = new Compositionality();
// Initialize the tagger
MaxentTagger tagger = new MaxentTagger("taggers/english-left3words-distsim.tagger");
//The strings that should be substituated
String s1;
String s2;
//Combination of both Strings for better Wordfinding
String combi;
// The tagged string
String tagged;
public Substituator(String wordspace, String s1, String s2) throws CorruptIndexException, IOException, CorruptConfigFileException{
this.disco = new Disco(wordspace);
this.simMachine = new SimilarityMachine(wordspace);
this.s1 = s1.replaceAll("\\W", " ");
this.s2 = s2.replaceAll("\\W", " ");
this.combi = s1 + " " + s2;
this.tagged = tagger.tagString(combi);
}
public ArrayList<String> getNounList(){
String[] x = tagged.split(" ");
ArrayList<String> list = new ArrayList<String>();
for(int i=0;i<x.length;i++)
{
if (x[i].substring(x[i].lastIndexOf("_")+1).startsWith("N"))
{
System.out.println("Ist das in diesem Kontext ein Nomen?");
System.out.println(x[i].split("_")[0]);
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
switch(input){
case "y":
list.add(x[i].split("_")[0]);
case "n":
default:
}
list.add(x[i].split("_")[0]);
}
}
return list;
}
public void substutiuateSentence() throws IOException{
ArrayList<String> list = getNounList();
String string1 = tagger.tagTokenizedString(s1);
String string2 = tagger.tagTokenizedString(s2);
ArrayList<String> result = new ArrayList();
String[] theTwoStrings = {string1, string2};
for(String string : theTwoStrings){
System.out.println("Der aktuelle Satz ist: " + string);
String[] sentence = string.split(" ");
for(int i=0;i<sentence.length;i++)
{
//If word is a noun
//if (sentence[i].substring(sentence[i].lastIndexOf("_")+1).startsWith("N"))
//System.out.println("Neue Runde und das Wort ist " + sentence[i]);
if(list.contains(sentence[i].split("_")[0]))
{
//Run through the list of candidates and check their similarity. If similar enough swap.
for(int j=0; j < list.size(); j++){
//check Similarity
//If similarity is big enough replace word with similar one
float sim;
try{
sim = simMachine.getWordSimilarity(sentence[i], list.get(j));
//System.out.println(sentence[i].split("_")[0] + " und " + list.get(j) + " sind so ahnlich " + sim);
} catch (NullPointerException ex){
sim = 0;
}
if (sim >= 0.1 && sim < 1.98){
//Make a new Sentence with the swapped out words
String end = "";
for(int k=0;k<sentence.length;k++){
//i is the index of the word that needs to be swapped
if(k == i){
end = end + list.get(j).split("_")[0] + " ";
} else {
end = end + sentence[k].split("_")[0] + " ";
}
}
//Only add if its not already in the list
//Let people decide. Ask in the console if the sentence makes sense.
/**
* Only add if its not already in the list
* Let people decide. Ask in the console if the sentence makes sense.
* Uncomment to use.
*/
if (!result.contains(end)){
System.out.println("Macht dieser Satz sinn? ");
System.out.println(end);
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
//Type 'y' for yes and 'n' for no. Confirm with enter.
//If new sentence has succefully been created. Make a new Pair-Element
switch(input){
case "y":
result.add(end);
for(int l=0; l < grammar.nouns.length; l++){
if(sentence[i].split("_")[0].toLowerCase().equals(grammar.nouns[l].nameOrth)){
String name = list.get(j).split("_")[0];
NominalNoun n = new NominalNoun(name.substring(0, 1).toUpperCase() + name.substring(1), grammar.nouns[l].getSubCase(), name);
grammar.makeNounConstruction(n);
}
}
case "n":
default:
}
}
/**
* Uses GoogleSearch to determine if sentences are semantically correct
* Comment out to use.
System.out.println(end);
GoogleSearch search = new GoogleSearch();
if (search.search(end) > 0){
result.add(end);
for(int l=0; l < grammar.nouns.length; l++){
if(sentence[i].split("_")[0].toLowerCase().equals(grammar.nouns[l].nameOrth)){
String name = list.get(j).split("_")[0];
NominalNoun n = new NominalNoun(name.substring(0, 1).toUpperCase() + name.substring(1), grammar.nouns[l].getSubCase(), name);
grammar.makeNounConstruction(n);
}
}
}*/
}
}
}
}
}
System.out.println(result.toString());
}
}
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.Iterator;
import java.util.concurrent.ThreadLocalRandom;
import org.apache.lucene.index.CorruptIndexException;
import de.linguatools.disco.Compositionality;
import de.linguatools.disco.CorruptConfigFileException;
import de.linguatools.disco.DISCO;
import edu.stanford.nlp.tagger.maxent.MaxentTagger;
/**
* The Substituator is able to create Lists of noun/verbs/adjectives from a sentence and then swap
* these with the respective one from another sentence
* @author Gian-Luca
*
*/
public class Substituator {
//The current grammar
Grammar grammar = new Grammar();
//Instance of Similarity Machine
SimilarityMachine simMachine;
//Instance of Disco
Disco disco;
//Initialize Compositor
Compositionality comp = new Compositionality();
// Initialize the tagger
MaxentTagger tagger;
//ENUMs that determine what kind of word will be substituted
public enum WordType {NOUN, VERB, ADJ}
WordType wordType;
//The strings that should be substituated
String s1;
String s2;
//Combination of both Strings for better Wordfinding
String combi;
// The tagged string
String tagged1;
String tagged2;
/**
* Creates a Substituator with the following arguments as parameters
* @param tagger
* @param wordspace
* @param s1
* @param s2
* @param wordType
* @throws CorruptIndexException
* @throws IOException
* @throws CorruptConfigFileException
*/
public Substituator(MaxentTagger tagger, String wordspace, String s1, String s2, WordType wordType) throws CorruptIndexException, IOException, CorruptConfigFileException{
this.tagger = tagger;
this.disco = new Disco(wordspace);
this.simMachine = new SimilarityMachine(wordspace);
this.s1 = s1.replaceAll("\\W", " ");
this.s2 = s2.replaceAll("\\W", " ");
this.combi = s1 + " " + s2;
this.tagged1 = tagger.tagString(s1);
this.tagged2 = tagger.tagString(s2);
this.wordType = wordType;
}
/**
* Creates and returns a list with all the words depending on the @param wordType
* that is used when creating the substituator
* @param s, the string from which to create the wordlist
* @return
*/
public ArrayList<String> getWordList(String s){
String[] x = s.split(" ");
ArrayList<String> list = new ArrayList<String>();
//Switch and make List depending on wordType
switch (wordType){
case NOUN:
System.out.println("Wir bauen eine Liste mit Nomen");
for(int i=0;i<x.length;i++) {
if (x[i].substring(x[i].lastIndexOf("_")+1).startsWith("N")) {
System.out.println("Ist das in diesem Kontext ein Nomen?");
System.out.println(x[i].split("_")[0]);
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
switch(input){
case "y":
list.add(x[i].split("_")[0]);
case "n":
default:
}
//list.add(x[i].split("_")[0]);
}
}
break;
case VERB:
System.out.println("Wir bauen eine Liste mit Verben");
for(int i=0;i<x.length;i++) {
if (x[i].substring(x[i].lastIndexOf("_")+1).startsWith("V")) {
System.out.println("Ist das in diesem Kontext ein Verb?");
System.out.println(x[i].split("_")[0]);
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
switch(input){
case "y":
list.add(x[i].split("_")[0]);
case "n":
default:
}
//list.add(x[i].split("_")[0]);
}
}
break;
case ADJ:
System.out.println("Wir bauen eine Liste mit Adjektive");
for(int i=0;i<x.length;i++) {
if (x[i].substring(x[i].lastIndexOf("_")+1).startsWith("J")) {
System.out.println("Ist das in diesem Kontext ein Adjektiv?");
System.out.println(x[i].split("_")[0]);
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
switch(input){
case "y":
list.add(x[i].split("_")[0]);
case "n":
default:
}
//list.add(x[i].split("_")[0]);
}
}
break;
}
System.out.println(list.toString());
return list;
}
/**
* Takes the two String s1 and s2 and creates wordlists for both of them
* It then swaps out the respective words and asks if the resulting sentence is semantically sensible.
* It starts with taking the first sencente and swapping words there and the takes the second one and does the same.
* @throws IOException
*/
public void substutiuateSentence() throws IOException{
ArrayList<String> wordListString1 = getWordList(tagged1);
ArrayList<String> wordListString2 = getWordList(tagged2);
String string1 = tagger.tagTokenizedString(s1);
String string2 = tagger.tagTokenizedString(s2);
ArrayList<String> result = new ArrayList();
/**
* Starts with s1
*/
//Make an array with all the single words from the sentence1
String[] sentence = string1.split(" ");
//Loop through the array above
for(int i=0;i<sentence.length;i++)
{
//Check if the current word is included in its own word list
if(wordListString1.contains(sentence[i].split("_")[0]))
{
//Get the index of the word in the wordList
int wordIndex = wordListString1.indexOf(sentence[i].split("_")[0]);
//If there is a word with the same index in word list 2 swap them
try{
String swapWord = wordListString2.get(wordIndex);
//Make a new Sentence with the swapped out words
String end = "";
for(int k=0;k<sentence.length;k++){
//i is the index of the word that needs to be swapped
if(k == i){
end = end + wordListString2.get(wordIndex).split("_")[0] + " ";
} else {
end = end + sentence[k].split("_")[0] + " ";
}
}
/**
* Only add if its not already in the list
* Let people decide. Ask in the console if the sentence makes sense.
* Uncomment to use.
*/
if (!result.contains(end)){
System.out.println("Macht dieser Satz sinn? ");
System.out.println(end);
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
//Type 'y' for yes and 'n' for no. Confirm with enter.
//If new sentence has succefully been created. Make a new Pair-Element
switch(input){
case "y":
result.add(end);
/*
* If substitution was succesfull create a new Construction and new Ontologies from the Pair
* Therefore check if there is a valid Construction already in place and make a new one with the respective arguments
for(int l=0; l < grammar.nouns.length; l++){
if(sentence[i].split("_")[0].toLowerCase().equals(grammar.nouns[l].nameOrth)){
String name = wordListString2.get(wordIndex).split("_")[0];
NominalNoun n = new NominalNoun(name.substring(0, 1).toUpperCase() + name.substring(1), grammar.nouns[l].getSubCase(), name, new String[]{});
grammar.makeNounConstruction(n);
}
}
*/
case "n":
default:
}
}
} catch (IndexOutOfBoundsException e) {
System.out.println("Da gabs kein Wort mehr");
}
}
}
/**
* Continues with s2
*/
//Make an array with all the single words from the sentence2
String[] sentence2 = string2.split(" ");
//Loop through the array above
for(int i=0;i<sentence2.length;i++)
{
//Check if the current word is included in its own noun list
if(wordListString2.contains(sentence2[i].split("_")[0]))
{
//Get the index of the noun in the nounList
int nounIndex = wordListString2.indexOf(sentence2[i].split("_")[0]);
//If there is a noun with the same index in noun list 2 swap them
try{
String swapNoun = wordListString1.get(nounIndex);
//Make a new Sentence with the swapped out words
String end = "";
for(int k=0;k<sentence2.length;k++){
//i is the index of the word that needs to be swapped
if(k == i){
end = end + wordListString1.get(nounIndex).split("_")[0] + " ";
} else {
end = end + sentence2[k].split("_")[0] + " ";
}
}
/**
* Only add if its not already in the list
* Let people decide. Ask in the console if the sentence makes sense.
* Uncomment to use.
*/
if (!result.contains(end)){
System.out.println("Macht dieser Satz sinn? ");
System.out.println(end);
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
//Type 'y' for yes and 'n' for no. Confirm with enter.
//If new sentence has succefully been created. Make a new Pair-Element
switch(input){
case "y":
result.add(end);
/*
* If substitution was succesfull create a new Construction and new Ontologies from the Pair
* Therefore check if there is a valid Construction already in place and make a new one with the respective arguments
for(int l=0; l < grammar.nouns.length; l++){
if(sentence2[i].split("_")[0].toLowerCase().equals(grammar.nouns[l].nameOrth)){
String name = wordListString1.get(nounIndex).split("_")[0];
NominalNoun n = new NominalNoun(name.substring(0, 1).toUpperCase() + name.substring(1), grammar.nouns[l].getSubCase(), name, new String[]{});
grammar.makeNounConstruction(n);
}
}
*/
case "n":
default:
}
}
} catch (IndexOutOfBoundsException e) {
System.out.println("Da gabs kein Wort mehr");
}
}
}
/*
//Run through the list of candidates and check their similarity. If similar enough swap.
for(int j=0; j < list.size(); j++){
//check Similarity
//If similarity is big enough replace word with similar one
float sim;
try{
sim = simMachine.getWordSimilarity(sentence[i], list.get(j));
//System.out.println(sentence[i].split("_")[0] + " und " + list.get(j) + " sind so ahnlich " + sim);
} catch (NullPointerException ex){
sim = 0;
}
if (sim >= 0.1 && sim < 1.98){
//Make a new Sentence with the swapped out words
String end = "";
for(int k=0;k<sentence.length;k++){
//i is the index of the word that needs to be swapped
if(k == i){
end = end + list.get(j).split("_")[0] + " ";
} else {
end = end + sentence[k].split("_")[0] + " ";
}
}
/**
* Only add if its not already in the list
* Let people decide. Ask in the console if the sentence makes sense.
* Uncomment to use.
*/
/*
if (!result.contains(end)){
System.out.println("Macht dieser Satz sinn? ");
System.out.println(end);
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
//Type 'y' for yes and 'n' for no. Confirm with enter.
//If new sentence has succefully been created. Make a new Pair-Element
switch(input){
case "y":
result.add(end);
for(int l=0; l < grammar.nouns.length; l++){
if(sentence[i].split("_")[0].toLowerCase().equals(grammar.nouns[l].nameOrth)){
String name = list.get(j).split("_")[0];
NominalNoun n = new NominalNoun(name.substring(0, 1).toUpperCase() + name.substring(1), grammar.nouns[l].getSubCase(), name);
grammar.makeNounConstruction(n);
}
}
case "n":
default:
}
}
/**
* Uses GoogleSearch to determine if sentences are semantically correct
* Comment out to use.
System.out.println(end);
GoogleSearch search = new GoogleSearch();
if (search.search(end) > 0){
result.add(end);
for(int l=0; l < grammar.nouns.length; l++){
if(sentence[i].split("_")[0].toLowerCase().equals(grammar.nouns[l].nameOrth)){
String name = list.get(j).split("_")[0];
NominalNoun n = new NominalNoun(name.substring(0, 1).toUpperCase() + name.substring(1), grammar.nouns[l].getSubCase(), name);
grammar.makeNounConstruction(n);
}
}
}*/
/*
}
}
}
}
}
*/
System.out.println(result.toString());
}
}
KitchenAid - Eine Software zur Erweiterung einer Konstruktionsgrammatik
Autor: Gian-Luca Savino
README
Bei KitchenAid handelt es sich um eine Software zur Erweiterung einer Konstruktionsgrammtik. Bei den hier vorliegndend Dateien handelt es sich um ein Eclipse Projekt. Die notwendigen Java-Dateien befinden in dem Ordner src.
Im Folgenden gebe ich eine kurze Übersicht über die darüberhinaus mitgelieferten Dateien in diesem Projektordner. Für die Funktionsweise der Software verweise ich auf den Kommentierten Quellcode.
*AlterantiveClasses*
In diesem Ordner befinden sich Klassen, die zum Testen von Features angelegt, aber wieder verworfen wurden, sowie Backups von manchen Methoden.
*bin*
Der normale von Eclipse angelegte bin Ordner.
*experiment*
Die Ergebnis-Daten des in der Arbeit beschriebenen Experiments.
*input*
Hier befindet sich der verwendet Korpus, sowie die Save-Files von KitchenAid. In diese Listen wurden neu gefundene Konstruktionen gespeichert und beim Programmstart reingeladen.
*input/betaTest*
Hier befinden sich zwei Listen mit jeweils allen Prototyp-Sätzen mit allen Nomen und alle Prototyp-Sätze, die ein Adjektiv beinhalten. Diese wurden benutzt, um eine Liste aller möglichen Kandidaten für die Substitution zu erstellen.
*input/betaTest/output*
Die Liste mit allen möglichen Kandidaten für Nomen und Andjektive nach Runden aufgeteilt.
*kappastatistic*
Zwei Listen mit jeweils dem Output von den in der Arbeit beschriebenen Kappa Statistik Experimenten.
*output*
Die Workbench lesbaren Konstruktionen und Ontologie-Terme sowie die Kappa-Statistik Daten.
*saveFiles*
KitchenAid hat die Funktionen ein Savefile des aktuellen Stands anzufertigen, diese werden hier gespeichert.
*src*
Eclipse source folder.
*startState*
Drei Listen mit Nomen, Adjektiven und Ontologie-Termen die als Startpunkt oder "Seed Grammar" dienen.
*taggers*
Quell-Dateien des Stanford POS Taggers.
*testSet*
Ordner wird nicht genutzt.
*wordspace*
Verschiedenen Wordspaces (Worträume) für den DISCO.
\ No newline at end of file
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment