From a899b639366b4f2b706f926483cad8ed58e9c6f7 Mon Sep 17 00:00:00 2001 From: MarkusKrug <markus.krug@uni-wuerzburg.de> Date: Tue, 19 Jul 2016 09:23:25 +0200 Subject: [PATCH] Upload of all projects fro relation classification --- .../.classpath | 7 + .../.gitignore | 1 + de.uniwue.mk.kall.relationResources/.project | 28 + .../.settings/org.eclipse.jdt.core.prefs | 7 + .../.settings/org.eclipse.pde.core.prefs | 3 + .../META-INF/MANIFEST.MF | 10 + .../build.properties | 4 + .../util/IRepresentation.java | 8 + .../util/IRepresentationConstants.java | 9 + .../relationResources/util/MentionPair.java | 275 ++++++++++ .../util/NeRepresentation.java | 137 +++++ .../relationResources/util/RelationUtil.java | 133 +++++ .../util/TokenRepresentation.java | 66 +++ .../instructions/AConversionInsruction.java | 25 + .../ChunkTypeConversionINstruction.java | 57 ++ .../instructions/EDecision.java | 6 + .../instructions/LookUpInputStruct.java | 33 ++ .../NETypeConversionINstruction.java | 47 ++ .../instructions/SegmentsUnifyUtil.java | 36 ++ .../ToDepRelConversionInstruction.java | 39 ++ .../ToGermanNetConversionInstruction.java | 65 +++ .../ToLemmaConversionInstruction.java | 43 ++ .../ToNullConversionInstruction.java | 39 ++ .../ToPOSConversionInstruction.java | 40 ++ .../ToPureTextConversionInstruction.java | 39 ++ .../ToW2VConversionInstruction.java | 54 ++ .../matrix/structs/SearchResult.java | 31 ++ .../matrix/structs/SentenceElement.java | 196 +++++++ .../matrix/structs/SentenceElementEntry.java | 55 ++ .../matrix/structs/SentenceElementMatrix.java | 174 ++++++ .../matrix/structs/SentenceElementUtil.java | 128 +++++ .../structs/SentenceMatrixCollection.java | 60 +++ .../matrix/structs/SentenceMatrixFactory.java | 200 +++++++ .../.classpath | 7 + .../.gitignore | 1 + .../.project | 28 + .../.settings/org.eclipse.jdt.core.prefs | 7 + .../.settings/org.eclipse.pde.core.prefs | 3 + .../META-INF/MANIFEST.MF | 7 + .../build.properties | 4 + .../app/VisualizeOntologyMain.java | 146 +++++ .../visualizeOntology/struct/Relation.java | 124 +++++ .../struct/RelationIOUtil.java | 127 +++++ .../.classpath | 7 + .../.gitignore | 1 + .../.project | 28 + .../.settings/org.eclipse.jdt.core.prefs | 7 + .../.settings/org.eclipse.pde.core.prefs | 3 + .../META-INF/MANIFEST.MF | 12 + .../build.properties | 4 + .../dependencypath/deppaths.txt | 37 ++ .../matrixPaths/matrixpaths.txt | 0 .../possessives/possessives.txt | 232 ++++++++ .../preciseConstructs/preciseConstructs.txt | 96 ++++ .../relationGeneral/ruleset.txt | 484 +++++++++++++++++ .../relationGeneral1/ruleset.txt | 507 ++++++++++++++++++ .../relationGeneral1/ruleset_temp.txt | 456 ++++++++++++++++ .../algo/ARelationDetectionPass.java | 11 + .../algo/RelationPairFirstPass.java | 132 +++++ .../algo/RuleBasedRelationDetection.java | 171 ++++++ .../app/EvalStruct.java | 12 + .../app/EvaluateRulesMain.java | 158 ++++++ .../app/PrintRelationsMain.java | 36 ++ .../app/RefactorRuleset.java | 55 ++ .../app/RelationRuleBasedMain.java | 126 +++++ .../app/RenameRelations.java | 60 +++ .../app/RescaleRelationsMain.java | 67 +++ .../app/TestRepresentation.java | 142 +++++ .../filter/AMentionCreationFilter.java | 9 + .../filter/BothArePronounsFilter.java | 22 + .../filter/FirstIsNotRelateableFilter.java | 26 + .../filter/PluralFilter.java | 38 ++ .../filter/SecondisNotRelateableFilter.java | 27 + .../rules/ARelationDetectionRule.java | 9 + .../firstpass/rules/DefinitToSubjectRule.java | 137 +++++ .../firstpass/rules/DependencyPathRule.java | 76 +++ .../rules/LookiLookiDetectionRule.java | 17 + .../rules/MatrixPathsRelationRule.java | 89 +++ .../rules/PossessivesRelationRule.java | 111 ++++ .../rules/PreciseConstructsRule.java | 76 +++ .../firstpass/rules/RepresentationNPRule.java | 76 +++ .../struct/IndicatorSets.java | 23 + .../src/util/RescaleRelations.java | 12 + 83 files changed, 6101 insertions(+) create mode 100644 de.uniwue.mk.kall.relationResources/.classpath create mode 100644 de.uniwue.mk.kall.relationResources/.gitignore create mode 100644 de.uniwue.mk.kall.relationResources/.project create mode 100644 de.uniwue.mk.kall.relationResources/.settings/org.eclipse.jdt.core.prefs create mode 100644 de.uniwue.mk.kall.relationResources/.settings/org.eclipse.pde.core.prefs create mode 100644 de.uniwue.mk.kall.relationResources/META-INF/MANIFEST.MF create mode 100644 de.uniwue.mk.kall.relationResources/build.properties create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/IRepresentation.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/IRepresentationConstants.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/MentionPair.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/NeRepresentation.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/RelationUtil.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/TokenRepresentation.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/AConversionInsruction.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ChunkTypeConversionINstruction.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/EDecision.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/LookUpInputStruct.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/NETypeConversionINstruction.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/SegmentsUnifyUtil.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToDepRelConversionInstruction.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToGermanNetConversionInstruction.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToLemmaConversionInstruction.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToNullConversionInstruction.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToPOSConversionInstruction.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToPureTextConversionInstruction.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToW2VConversionInstruction.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SearchResult.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceElement.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceElementEntry.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceElementMatrix.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceElementUtil.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceMatrixCollection.java create mode 100644 de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceMatrixFactory.java create mode 100644 de.uniwue.mk.kall.relationen.visualizeOntology/.classpath create mode 100644 de.uniwue.mk.kall.relationen.visualizeOntology/.gitignore create mode 100644 de.uniwue.mk.kall.relationen.visualizeOntology/.project create mode 100644 de.uniwue.mk.kall.relationen.visualizeOntology/.settings/org.eclipse.jdt.core.prefs create mode 100644 de.uniwue.mk.kall.relationen.visualizeOntology/.settings/org.eclipse.pde.core.prefs create mode 100644 de.uniwue.mk.kall.relationen.visualizeOntology/META-INF/MANIFEST.MF create mode 100644 de.uniwue.mk.kall.relationen.visualizeOntology/build.properties create mode 100644 de.uniwue.mk.kall.relationen.visualizeOntology/src/de/uniwue/mk/kall/relationen/visualizeOntology/app/VisualizeOntologyMain.java create mode 100644 de.uniwue.mk.kall.relationen.visualizeOntology/src/de/uniwue/mk/kall/relationen/visualizeOntology/struct/Relation.java create mode 100644 de.uniwue.mk.kall.relationen.visualizeOntology/src/de/uniwue/mk/kall/relationen/visualizeOntology/struct/RelationIOUtil.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/.classpath create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/.gitignore create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/.project create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/.settings/org.eclipse.jdt.core.prefs create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/.settings/org.eclipse.pde.core.prefs create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/META-INF/MANIFEST.MF create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/build.properties create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/dependencypath/deppaths.txt create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/matrixPaths/matrixpaths.txt create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/possessives/possessives.txt create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/preciseConstructs/preciseConstructs.txt create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/relationGeneral/ruleset.txt create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/relationGeneral1/ruleset.txt create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/relationGeneral1/ruleset_temp.txt create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/algo/ARelationDetectionPass.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/algo/RelationPairFirstPass.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/algo/RuleBasedRelationDetection.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/EvalStruct.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/EvaluateRulesMain.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/PrintRelationsMain.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/RefactorRuleset.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/RelationRuleBasedMain.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/RenameRelations.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/RescaleRelationsMain.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/TestRepresentation.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/filter/AMentionCreationFilter.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/filter/BothArePronounsFilter.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/filter/FirstIsNotRelateableFilter.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/filter/PluralFilter.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/filter/SecondisNotRelateableFilter.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/ARelationDetectionRule.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/DefinitToSubjectRule.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/DependencyPathRule.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/LookiLookiDetectionRule.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/MatrixPathsRelationRule.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/PossessivesRelationRule.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/PreciseConstructsRule.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/RepresentationNPRule.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/struct/IndicatorSets.java create mode 100644 de.uniwue.mk.kall.ruleBasedRelationClassification/src/util/RescaleRelations.java diff --git a/de.uniwue.mk.kall.relationResources/.classpath b/de.uniwue.mk.kall.relationResources/.classpath new file mode 100644 index 0000000..b862a29 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/de.uniwue.mk.kall.relationResources/.gitignore b/de.uniwue.mk.kall.relationResources/.gitignore new file mode 100644 index 0000000..5e56e04 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/.gitignore @@ -0,0 +1 @@ +/bin diff --git a/de.uniwue.mk.kall.relationResources/.project b/de.uniwue.mk.kall.relationResources/.project new file mode 100644 index 0000000..eae4ae9 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>de.uniwue.mk.kall.relationResources</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/de.uniwue.mk.kall.relationResources/.settings/org.eclipse.jdt.core.prefs b/de.uniwue.mk.kall.relationResources/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..295926d --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/de.uniwue.mk.kall.relationResources/.settings/org.eclipse.pde.core.prefs b/de.uniwue.mk.kall.relationResources/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 0000000..b7e72d0 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/de.uniwue.mk.kall.relationResources/META-INF/MANIFEST.MF b/de.uniwue.mk.kall.relationResources/META-INF/MANIFEST.MF new file mode 100644 index 0000000..08f876a --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/META-INF/MANIFEST.MF @@ -0,0 +1,10 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: RelationResources +Bundle-SymbolicName: de.uniwue.mk.kall.relationResources +Bundle-Version: 1.0.0.qualifier +Export-Package: de.uniwue.mk.kall.relationResources.util, + de.uniwue.mk.kall.ruleBasedRelationClassification.instructions, + de.uniwue.mk.kall.ruleBasedRelationClassification.matrix.structs +Require-Bundle: de.uniwue.mk.kall.projectresources;bundle-version="1.0.0", + de.uniwue.mkrug.kall.typesystemUtil;bundle-version="1.0.0" diff --git a/de.uniwue.mk.kall.relationResources/build.properties b/de.uniwue.mk.kall.relationResources/build.properties new file mode 100644 index 0000000..41eb6ad --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/IRepresentation.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/IRepresentation.java new file mode 100644 index 0000000..80e32f4 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/IRepresentation.java @@ -0,0 +1,8 @@ +package de.uniwue.mk.kall.relationResources.util; + +import java.util.List; + +public interface IRepresentation { + + public List<String> getRepresentations(); +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/IRepresentationConstants.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/IRepresentationConstants.java new file mode 100644 index 0000000..d17a8ec --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/IRepresentationConstants.java @@ -0,0 +1,9 @@ +package de.uniwue.mk.kall.relationResources.util; + +public interface IRepresentationConstants { + + public static final String NE_FEMALE = "<NE_FEMALE>"; + public static final String NE_MALE = "<NE_MALE>"; + public static final String NE = "<NE>"; + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/MentionPair.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/MentionPair.java new file mode 100644 index 0000000..8f9f61d --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/MentionPair.java @@ -0,0 +1,275 @@ +package de.uniwue.mk.kall.relationResources.util; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.Feature; +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mk.kall.ruleBasedRelationClassification.matrix.structs.SentenceElementMatrix; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class MentionPair { + + private AnnotationFS neFrom; + private AnnotationFS neTo; + + private String relationFromTo; + private String relationToFrom; + private boolean resolveWithNP; + + private String svmInstance; + private List<SentenceElementMatrix> matrixRepresentation; + private List<String> representations; + + public MentionPair(AnnotationFS from, AnnotationFS to) { + + this.neFrom = from; + this.neTo = to; + + this.svmInstance = getTextAndBetween(); + } + + public List<String> getRepresentations() { + return representations; + } + + public void setRepresentations(List<String> representations) { + this.representations = representations; + } + + public boolean isResolveWithNP() { + return resolveWithNP; + } + + public void setResolveWithNP(boolean resolveWithNP) { + this.resolveWithNP = resolveWithNP; + } + + public List<SentenceElementMatrix> getPathRepresentation() { + return matrixRepresentation; + } + + public void setPathRepresentation(List<SentenceElementMatrix> pathRepresentation) { + this.matrixRepresentation = pathRepresentation; + } + + public AnnotationFS getNeFrom() { + return neFrom; + } + + public void setNeFrom(AnnotationFS neFrom) { + this.neFrom = neFrom; + } + + public AnnotationFS getNeTo() { + return neTo; + } + + public void setNeTo(AnnotationFS neTo) { + this.neTo = neTo; + } + + public CAS getCas() { + return neFrom.getCAS(); + } + + public String getTextAndBetween() { + + return getCas().getDocumentText().substring(neFrom.getBegin(), neTo.getEnd()); + } + + public String getRelationFromTo() { + return relationFromTo; + } + + public void setRelationFromTo(String relationFromTo) { + this.relationFromTo = relationFromTo; + } + + public String getRelationToFrom() { + return relationToFrom; + } + + public void setRelationToFrom(String relationToFrom) { + this.relationToFrom = relationToFrom; + } + + public String getSvmInstance() { + return svmInstance; + } + + public void setSvmInstance(String svmInstance) { + this.svmInstance = svmInstance; + } + + public boolean isResolved() { + return this.relationFromTo != null || this.relationToFrom != null; + } + + public String getTextBetween() { + if (neFrom.getEnd() < neTo.getBegin()) { + return getCas().getDocumentText().substring(neFrom.getEnd(), neTo.getBegin()); + } else { + return ""; + } + } + + public String getNameNoCoreTo() { + + return reduce(this.neTo); + + } + + private String reduce(AnnotationFS anno) { + Feature feat = anno.getType().getFeatureByBaseName("Construction"); + + Util_impl util = new Util_impl(getCas()); + + String value = anno.getFeatureValueAsString(feat); + if (value == null) + return anno.getCoveredText(); + + String[] cats = value.split("\\|"); + String reducedString = ""; + int index = 0; + for (AnnotationFS pos : util.getCovered(anno, util.getPOSType())) { + + if (!cats[index].matches("VORNAME|NACHNAME|NAME|ADELSPRAEDIKAT")) { + reducedString += " " + pos.getCoveredText(); + } + index++; + } + + if (reducedString.trim().isEmpty()) { + reducedString = "<CORE>"; + } + + reducedString = reducedString.replaceAll("(<CORE>\\s+)+", "<CORE> "); + return reducedString.trim(); + } + + public void setResolveWithNPs(boolean resolveWithNP) { + this.resolveWithNP = resolveWithNP; + + } + + public boolean getResolveWithNPs() { + return this.resolveWithNP; + + } + + public List<String> getAllRepresentations() { + Set<String> representations = new HashSet<String>(); + + // add the plain text between both + representations.add(getTextAndBetween()); + + // add <FIRST> <SECOND> representation + String between = getTextBetween(); + + addReducedRepresentations(representations, between); + + // add all skip-paths TODO + + // for (String s : representations) { + // System.out.println(s); + // } + // System.out.println(); + return new ArrayList<>(representations); + } + + private void addReducedRepresentations(Set<String> representations, String between) { + representations.add("<FIRST>" + between + "<SECOND>"); + representations.add("<FIRST>" + between + getNeTo().getCoveredText()); + representations.add(getNeFrom().getCoveredText() + between + "<SECOND>"); + + // add the reduced forms + representations.add(getNameNoCoreFrom() + between + getNameNoCoreTo()); + representations.add(getNameNoCoreFrom() + between + neTo.getCoveredText()); + representations.add(neFrom.getCoveredText() + between + getNameNoCoreTo()); + + // add genitiv as well + representations.add(getGenitivRepresentation(neFrom) + between + getGenitivRepresentation(neTo)); + representations.add(getGenitivRepresentation(neFrom) + between + neTo.getCoveredText()); + representations.add(getGenitivRepresentation(neFrom) + between + getNameNoCoreTo()); + representations.add(neFrom.getCoveredText() + between + getGenitivRepresentation(neTo)); + representations.add(getNameNoCoreFrom() + between + getGenitivRepresentation(neTo)); + } + + private String getGenitivRepresentation(AnnotationFS ne) { + + // return <GENITIV> if it is Genitiv else returns getCOveredText + + Util_impl util = new Util_impl(getCas()); + + for (AnnotationFS rf : util.getCovered(ne, util.getRFType())) { + + String rfFeat = rf.getFeatureValueAsString(util.getRFTagFeature()); + + if (rfFeat.toLowerCase().contains(".gen.")) + return "<GENITIV>"; + } + return ne.getCoveredText(); + } + + public String getNameNoCoreFrom() { + + return reduce(neFrom); + } + + public List<String> getDependencyPathRepresentations() { + + Set<String> paths = new HashSet<String>(); + Util_impl util = new Util_impl(getCas()); + + // Dep-Rel - head + List<AnnotationFS> depPath = util.getDepPath(neFrom, neTo); + + String path = ""; + if (depPath == null) + return new ArrayList<>(paths); + + String betweenPath = " "; + for (AnnotationFS a : depPath) { + path += a.getCoveredText() + " "; + + if (a.getBegin() >= neFrom.getBegin() && a.getEnd() <= neFrom.getEnd() || a.getBegin() >= neTo.getBegin() + && a.getEnd() <= neTo.getEnd()) { + continue; + } + betweenPath += a.getCoveredText() + " "; + } + + paths.add(path); + paths.add(getTextAndBetween()); + + addReducedRepresentations(paths, betweenPath); + + List<AnnotationFS> covered = util.getCovered(0, getCas().getDocumentText().length(), util.getRelationType()); + if (covered.size() > 0 && containsFittingRelation(covered)) { + + for (String s : paths) { + System.out.println(s); + } + System.out.println("Relation " + covered.get(0).getFeatureValueAsString(util.getRelationTypeFeature())); + System.out.println(getTextAndBetween()); + System.out.println(); + } + + return new ArrayList<>(paths); + } + + private boolean containsFittingRelation(List<AnnotationFS> covered) { + + for (AnnotationFS a : covered) { + if (a.getBegin() == neFrom.getBegin() && a.getEnd() == neTo.getEnd()) + return true; + } + return false; + } + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/NeRepresentation.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/NeRepresentation.java new file mode 100644 index 0000000..4448483 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/NeRepresentation.java @@ -0,0 +1,137 @@ +package de.uniwue.mk.kall.relationResources.util; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.uima.cas.Feature; +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class NeRepresentation implements IRepresentation { + + AnnotationFS ne; + + List<String> representation; + + private Util_impl util; + + public NeRepresentation(AnnotationFS ne, boolean isLastNE) { + this.ne = ne; + util = new Util_impl(ne.getCAS()); + + representation = new ArrayList<String>(); + + // add the plain text + representation.add(ne.getCoveredText()); + representation.add(IRepresentationConstants.NE); + representation.add(reduce(this.ne)); + representation.add(reduceLeaveCategories(ne)); + representation.add(getGenitivRepresentation(ne)); + + if (!util.isPronoun(ne) && ne.getCoveredText().endsWith("s")) { + representation.add("<ENDS-S>"); + } + // also add just the first token + representation.add(this.ne.getCoveredText().split(" ")[0]); + + if (util.isPronoun(ne) && !isLastNE) { + String posTag = util.getPosTag(ne); + + if (posTag.matches("PPOSAT|PRELAT")) { + representation.add(""); + } + } + + // TODO gender + } + + public AnnotationFS getNe() { + return ne; + } + + public void setNe(AnnotationFS ne) { + this.ne = ne; + } + + public List<String> getRepresentation() { + return representation; + } + + public void setRepresentation(List<String> representation) { + this.representation = representation; + } + + private String reduce(AnnotationFS anno) { + Feature feat = anno.getType().getFeatureByBaseName("Construction"); + + String value = anno.getFeatureValueAsString(feat); + if (value == null) + return anno.getCoveredText(); + + String[] cats = value.split("\\|"); + String reducedString = ""; + int index = 0; + for (AnnotationFS pos : util.getCovered(anno, util.getPOSType())) { + String posTag = util.getPosTag(pos); + if (!cats[index].matches("VORNAME|NACHNAME|NAME|ADELSPRAEDIKAT") && !posTag.matches("NE")) { + reducedString += " " + pos.getCoveredText(); + } + index++; + } + + if (reducedString.trim().isEmpty()) { + reducedString = "<CORE>"; + } + + reducedString = reducedString.replaceAll("(<CORE>\\s+)+", "<CORE> "); + return reducedString.trim(); + } + + private String reduceLeaveCategories(AnnotationFS anno) { + Feature feat = anno.getType().getFeatureByBaseName("Construction"); + + String value = anno.getFeatureValueAsString(feat); + if (value == null) + return anno.getCoveredText(); + + String[] cats = value.split("\\|"); + String reducedString = ""; + int index = 0; + for (AnnotationFS pos : util.getCovered(anno, util.getPOSType())) { + + String posTag = util.getPosTag(pos); + if (!cats[index].matches("VORNAME|NACHNAME|NAME|ADELSPRAEDIKAT") && !posTag.matches("NE")) { + reducedString += " " + "<" + cats[index] + ">"; + } + index++; + } + + if (reducedString.trim().isEmpty()) { + reducedString = "<CORE>"; + } + + reducedString = reducedString.replaceAll("(<CORE>\\s+)+", "<CORE> "); + return reducedString.trim(); + } + + private String getGenitivRepresentation(AnnotationFS ne) { + + // return <GENITIV> if it is Genitiv else returns getCOveredText + + for (AnnotationFS rf : util.getCovered(ne, util.getRFType())) { + + String rfFeat = rf.getFeatureValueAsString(util.getRFTagFeature()); + + if (rfFeat.toLowerCase().contains(".gen.")) + return "<GENITIV>"; + } + return ne.getCoveredText(); + } + + @Override + public List<String> getRepresentations() { + return this.representation; + } + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/RelationUtil.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/RelationUtil.java new file mode 100644 index 0000000..c9f8411 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/RelationUtil.java @@ -0,0 +1,133 @@ +package de.uniwue.mk.kall.relationResources.util; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class RelationUtil { + + public static Set<String> generateTextRepresentations(AnnotationFS neFrom, AnnotationFS neTo) { + + CAS cas = neFrom.getCAS(); + Util_impl util = new Util_impl(cas); + + Set<String> representations = new HashSet<>(); + + List<AnnotationFS> tokBetween = util.getCovered(neFrom.getEnd(), neTo.getBegin(), util.getPOSType()); + + // we convert those to a wrapper object + + List<IRepresentation> representationWrapper = new ArrayList<>(); + + representationWrapper.add(new NeRepresentation(neFrom, false)); + for (AnnotationFS tok : tokBetween) { + representationWrapper.add(new TokenRepresentation(tok, neFrom, neTo, true)); + } + representationWrapper.add(new NeRepresentation(neTo, true)); + + // if we have more than 7 unreduceable tokens we return the blank text + + int amountIrreducable = 0; + for (IRepresentation r : representationWrapper) { + if (r.getRepresentations().contains("")) { + amountIrreducable++; + } + } + + if (amountIrreducable > 7) { + representations.add(cas.getDocumentText().substring(neFrom.getBegin(), neTo.getEnd())); + return representations; + } + + createRepresentationsBySearch(representations, representationWrapper); + return representations; + } + + private static void createRepresentationsBySearch(Set<String> representations, + List<IRepresentation> representationWrapper) { + // add the initial state + representations.addAll(representationWrapper.get(0).getRepresentations()); + + // calculate all full representations + for (int i = 1; i < representationWrapper.size(); i++) { + + // get the current token + List<String> repsAct = representationWrapper.get(i).getRepresentations(); + + // update the states + List<String> newStates = new ArrayList<>(); + for (String s : representations) { + + for (String actRep : repsAct) { + String newState = s + " " + actRep; + // TODO pruneing + if (newState.split(" ").length <= 7) { + newStates.add(newState.trim()); + } + } + } + + representations.clear(); + representations.addAll(newStates); + + } + } + + public static Set<String> generatePathRepresentations(AnnotationFS neFrom, AnnotationFS neTo) { + + CAS cas = neFrom.getCAS(); + Util_impl util = new Util_impl(cas); + + Set<String> representations = new HashSet<>(); + + // Dep-Rel - head + List<AnnotationFS> depPath = util.getDepPath(neFrom, neTo); + + if (depPath == null) + return representations; + + // find all annotations that are not part of the nes + List<AnnotationFS> tokBetween = new ArrayList<>(); + + for (AnnotationFS tok : depPath) { + if (tok.getBegin() >= neFrom.getBegin() && tok.getEnd() <= neFrom.getEnd() + || tok.getBegin() >= neTo.getBegin() && tok.getEnd() <= neTo.getEnd()) + continue; + + tokBetween.add(tok); + } + + if (tokBetween.size() == 0) + return representations; + + // create the wrapper + List<IRepresentation> representationWrapper = new ArrayList<>(); + + representationWrapper.add(new NeRepresentation(neFrom, false)); + for (AnnotationFS tok : tokBetween) { + representationWrapper.add(new TokenRepresentation(tok, neFrom, neTo, false)); + } + representationWrapper.add(new NeRepresentation(neTo, true)); + + createRepresentationsBySearch(representations, representationWrapper); + + return representations; + } + + public static Set<String> generateAllRepresentations(AnnotationFS neFrom, AnnotationFS neTo) { + Set<String> representations = new HashSet<>(); + + representations.addAll(generatePathRepresentations(neFrom, neTo)); + representations.addAll(generateTextRepresentations(neFrom, neTo)); + + return representations; + + } + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/TokenRepresentation.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/TokenRepresentation.java new file mode 100644 index 0000000..d8fabac --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/relationResources/util/TokenRepresentation.java @@ -0,0 +1,66 @@ +package de.uniwue.mk.kall.relationResources.util; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class TokenRepresentation implements IRepresentation { + + AnnotationFS tok; + + List<String> representation; + + private Util_impl util; + + public TokenRepresentation(AnnotationFS tok, AnnotationFS neFrom, AnnotationFS neTo, boolean skipChunks) { + this.tok = tok; + util = new Util_impl(tok.getCAS()); + + representation = new ArrayList<String>(); + + // add the plain text + representation.add(tok.getCoveredText()); + + // we remove certain POS Tags or tokens + + String posTag = util.getPosTag(tok); + + if (posTag != null + && (posTag.matches("ADV|ADJD|ADJA|ART|CARD|PIAT|PTKNEG") || tok.getCoveredText().toLowerCase() + .matches("\\)|\\(|–|›|»"))) { + // empty representation since we do not need that one at all + representation.add(""); + + if (tok.getCoveredText().matches(",")) { + AnnotationFS coveringChunk = util.getCoveringChunk(tok); + + if (coveringChunk != null) { + representation.add(""); + } + } + } + + // test if it is part of a chunk in between those nes + if (skipChunks) { + AnnotationFS coveringChunk = util.getCoveringChunk(tok); + + if (coveringChunk != null && coveringChunk.getBegin() > neFrom.getEnd() + && coveringChunk.getEnd() < neTo.getBegin()) { + String chunkFeat = coveringChunk.getFeatureValueAsString(util.getChunkFeature()); + if (!chunkFeat.equals("VC")) { + representation.add(""); + } + } + } + + } + + @Override + public List<String> getRepresentations() { + return this.representation; + } + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/AConversionInsruction.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/AConversionInsruction.java new file mode 100644 index 0000000..6ab8bc5 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/AConversionInsruction.java @@ -0,0 +1,25 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.instructions; + +import java.io.Serializable; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mk.kall.ruleBasedRelationClassification.matrix.structs.SentenceElementEntry; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public abstract class AConversionInsruction implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3042641885456036318L; + protected String instructionId; + + public abstract String convertNE(AnnotationFS neFrom, CAS cas, Util_impl util); + + public abstract String convertToken(AnnotationFS tok, CAS cas, Util_impl util); + + public abstract SentenceElementEntry createEntry(AnnotationFS tok, CAS cas, Util_impl util); + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ChunkTypeConversionINstruction.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ChunkTypeConversionINstruction.java new file mode 100644 index 0000000..7844e57 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ChunkTypeConversionINstruction.java @@ -0,0 +1,57 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.instructions; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mk.kall.ruleBasedRelationClassification.matrix.structs.SentenceElementEntry; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class ChunkTypeConversionINstruction extends AConversionInsruction { + + /** + * + */ + private static final long serialVersionUID = -7007336915810186404L; + + public ChunkTypeConversionINstruction() { + super.instructionId = "CHUNK_TAG"; + } + + @Override + public String convertNE(AnnotationFS neFrom, CAS cas, Util_impl util) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String convertToken(AnnotationFS tok, CAS cas, Util_impl util) { + // TODO Auto-generated method stub + return null; + } + + @Override + public SentenceElementEntry createEntry(AnnotationFS tok, CAS cas, Util_impl util) { + + AnnotationFS coveringChunk = util.getCoveringChunk(tok); + + // no comma matches!! + if (tok.getCoveredText().matches(",") && coveringChunk == null) { + return new SentenceElementEntry(instructionId, ","); + + } + + if (coveringChunk == null) { + return new SentenceElementEntry(super.instructionId, tok.getCoveredText()); + } + if (tok.getBegin() == coveringChunk.getBegin()) { + String chunkFeat = coveringChunk.getFeatureValueAsString(util.getChunkFeature()); + return new SentenceElementEntry(super.instructionId, "B-" + chunkFeat); + } + + else { + String chunkFeat = coveringChunk.getFeatureValueAsString(util.getChunkFeature()); + return new SentenceElementEntry(super.instructionId, "I-" + chunkFeat); + } + } + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/EDecision.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/EDecision.java new file mode 100644 index 0000000..f48b590 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/EDecision.java @@ -0,0 +1,6 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.instructions; + +public enum EDecision { + MATCH, NO_MATCH, UNDECIDED; + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/LookUpInputStruct.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/LookUpInputStruct.java new file mode 100644 index 0000000..a405c92 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/LookUpInputStruct.java @@ -0,0 +1,33 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.instructions; + +import org.apache.uima.cas.text.AnnotationFS; + +public class LookUpInputStruct { + + private AnnotationFS neFrom; + + private AnnotationFS neTo; + + public LookUpInputStruct(AnnotationFS neFrom, AnnotationFS neTo) { + super(); + this.neFrom = neFrom; + this.neTo = neTo; + } + + public AnnotationFS getNeFrom() { + return neFrom; + } + + public void setNeFrom(AnnotationFS neFrom) { + this.neFrom = neFrom; + } + + public AnnotationFS getNeTo() { + return neTo; + } + + public void setNeTo(AnnotationFS neTo) { + this.neTo = neTo; + } + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/NETypeConversionINstruction.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/NETypeConversionINstruction.java new file mode 100644 index 0000000..f9cb221 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/NETypeConversionINstruction.java @@ -0,0 +1,47 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.instructions; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mk.kall.ruleBasedRelationClassification.matrix.structs.SentenceElementEntry; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class NETypeConversionINstruction extends AConversionInsruction { + + /** + * + */ + private static final long serialVersionUID = -3302978548398020484L; + + public NETypeConversionINstruction() { + super.instructionId = "NE_TYPE"; + } + + @Override + public String convertNE(AnnotationFS neFrom, CAS cas, Util_impl util) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String convertToken(AnnotationFS tok, CAS cas, Util_impl util) { + // TODO Auto-generated method stub + return null; + } + + @Override + public SentenceElementEntry createEntry(AnnotationFS tok, CAS cas, Util_impl util) { + + String neType = tok.getFeatureValueAsString(util.getNeFeatureType()); + + if (neType == null || neType.toLowerCase().equals("pron")) { + return new SentenceElementEntry(instructionId, tok.getCoveredText()); + } + + else { + return new SentenceElementEntry(instructionId, neType); + } + + } + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/SegmentsUnifyUtil.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/SegmentsUnifyUtil.java new file mode 100644 index 0000000..d15e68f --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/SegmentsUnifyUtil.java @@ -0,0 +1,36 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.instructions; + +import java.util.List; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class SegmentsUnifyUtil { + + public static String unifySegment(CAS cas, Util_impl util, AnnotationFS neFrom, AnnotationFS neTo, + AConversionInsruction instruction) { + + // get 3 parts + + // first part is the NeFrom + String neFromS = instruction.convertNE(neFrom, cas, util); + + List<AnnotationFS> coveredSecond = util.getCovered(neFrom.getEnd(), neTo.getBegin(), util.getPOSType()); + + String secondPart = ""; + + // second part are all tokens between those NEs + for (AnnotationFS tok : coveredSecond) { + + secondPart += instruction.convertToken(tok, cas, util) + " "; + } + + // this part is the second NE + String neToS = instruction.convertNE(neTo, cas, util); + + return neFromS + " " + secondPart + neToS; + } + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToDepRelConversionInstruction.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToDepRelConversionInstruction.java new file mode 100644 index 0000000..9c9ba68 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToDepRelConversionInstruction.java @@ -0,0 +1,39 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.instructions; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mk.kall.ruleBasedRelationClassification.matrix.structs.SentenceElementEntry; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class ToDepRelConversionInstruction extends AConversionInsruction { + + /** + * + */ + private static final long serialVersionUID = -6680724633309239986L; + + public ToDepRelConversionInstruction() { + super.instructionId = "DEP_REL"; + } + + @Override + public String convertNE(AnnotationFS neFrom, CAS cas, Util_impl util) { + + return neFrom.getCoveredText().replaceAll("\n", ""); + } + + @Override + public String convertToken(AnnotationFS tok, CAS cas, Util_impl util) { + + return tok.getCoveredText().replaceAll("\n", ""); + } + + @Override + public SentenceElementEntry createEntry(AnnotationFS tok, CAS cas, Util_impl util) { + + String text = util.getDepRel(tok); + return new SentenceElementEntry(instructionId, text); + } + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToGermanNetConversionInstruction.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToGermanNetConversionInstruction.java new file mode 100644 index 0000000..c01b540 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToGermanNetConversionInstruction.java @@ -0,0 +1,65 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.instructions; + +import java.util.Set; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mk.kall.projectresources.KallimachosResourceLoader; +import de.uniwue.mk.kall.ruleBasedRelationClassification.matrix.structs.SentenceElementEntry; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class ToGermanNetConversionInstruction extends AConversionInsruction { + + /** + * + */ + private static final long serialVersionUID = 535203129641678376L; + + public ToGermanNetConversionInstruction() { + super.instructionId = "GERMANET"; + } + + @Override + public String convertNE(AnnotationFS neFrom, CAS cas, Util_impl util) { + + return neFrom.getCoveredText().replaceAll("\n", ""); + } + + @Override + public String convertToken(AnnotationFS tok, CAS cas, Util_impl util) { + + return tok.getFeatureValueAsString(util.getPOSTagFeature()); + } + + @Override + public SentenceElementEntry createEntry(AnnotationFS tok, CAS cas, Util_impl util) { + + String lemma = util.getLemma(tok); + + // no comma matches!! + if (tok.getCoveredText().matches(",")) { + return new SentenceElementEntry(instructionId, ","); + + } + + if (lemma == null) { + return new SentenceElementEntry(instructionId, tok.getCoveredText()); + } + + Set<String> germanetCategories = KallimachosResourceLoader.getGermanetCategories(lemma); + + if (germanetCategories == null) { + return new SentenceElementEntry(instructionId, tok.getCoveredText()); + } + + else { + // return the first entry + for (String s : germanetCategories) { + return new SentenceElementEntry(instructionId, s); + } + } + return new SentenceElementEntry(instructionId, tok.getCoveredText()); + + } +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToLemmaConversionInstruction.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToLemmaConversionInstruction.java new file mode 100644 index 0000000..d185648 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToLemmaConversionInstruction.java @@ -0,0 +1,43 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.instructions; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mk.kall.ruleBasedRelationClassification.matrix.structs.SentenceElementEntry; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class ToLemmaConversionInstruction extends AConversionInsruction { + + /** + * + */ + private static final long serialVersionUID = 4339039458008887078L; + + public ToLemmaConversionInstruction() { + super.instructionId = "LEMMA_TAG"; + } + + @Override + public String convertNE(AnnotationFS neFrom, CAS cas, Util_impl util) { + + return neFrom.getCoveredText().replaceAll("\n", ""); + } + + @Override + public String convertToken(AnnotationFS tok, CAS cas, Util_impl util) { + + return tok.getFeatureValueAsString(util.getPOSTagFeature()); + } + + @Override + public SentenceElementEntry createEntry(AnnotationFS tok, CAS cas, Util_impl util) { + + String lemma = tok.getFeatureValueAsString(util.getLemmaFeature()); + + if (lemma == null || lemma.equals("<unknown>")) + return new SentenceElementEntry(instructionId, tok.getCoveredText()); + + return new SentenceElementEntry(instructionId, lemma); + } + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToNullConversionInstruction.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToNullConversionInstruction.java new file mode 100644 index 0000000..b1997c7 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToNullConversionInstruction.java @@ -0,0 +1,39 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.instructions; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mk.kall.ruleBasedRelationClassification.matrix.structs.SentenceElementEntry; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class ToNullConversionInstruction extends AConversionInsruction { + + /** + * + */ + private static final long serialVersionUID = -5054132398379580399L; + + public ToNullConversionInstruction() { + super.instructionId = "NULL"; + } + + @Override + public String convertNE(AnnotationFS neFrom, CAS cas, Util_impl util) { + + return neFrom.getCoveredText().replaceAll("\n", ""); + } + + @Override + public String convertToken(AnnotationFS tok, CAS cas, Util_impl util) { + + return tok.getFeatureValueAsString(util.getPOSTagFeature()); + } + + @Override + public SentenceElementEntry createEntry(AnnotationFS tok, CAS cas, Util_impl util) { + + return new SentenceElementEntry(instructionId, SentenceElementEntry.NULL_VALUE); + + } + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToPOSConversionInstruction.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToPOSConversionInstruction.java new file mode 100644 index 0000000..31343b1 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToPOSConversionInstruction.java @@ -0,0 +1,40 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.instructions; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mk.kall.ruleBasedRelationClassification.matrix.structs.SentenceElementEntry; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class ToPOSConversionInstruction extends AConversionInsruction { + + /** + * + */ + private static final long serialVersionUID = -3003625849006819827L; + + public ToPOSConversionInstruction() { + super.instructionId = "POS_TAG"; + } + + @Override + public String convertNE(AnnotationFS neFrom, CAS cas, Util_impl util) { + + return neFrom.getCoveredText().replaceAll("\n", ""); + } + + @Override + public String convertToken(AnnotationFS tok, CAS cas, Util_impl util) { + + return tok.getFeatureValueAsString(util.getPOSTagFeature()); + } + + @Override + public SentenceElementEntry createEntry(AnnotationFS tok, CAS cas, Util_impl util) { + + String posTag = tok.getFeatureValueAsString(util.getPOSTagFeature()); + + return new SentenceElementEntry(instructionId, posTag); + } + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToPureTextConversionInstruction.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToPureTextConversionInstruction.java new file mode 100644 index 0000000..30b657c --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToPureTextConversionInstruction.java @@ -0,0 +1,39 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.instructions; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mk.kall.ruleBasedRelationClassification.matrix.structs.SentenceElementEntry; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class ToPureTextConversionInstruction extends AConversionInsruction { + + /** + * + */ + private static final long serialVersionUID = 6420544138941855368L; + + public ToPureTextConversionInstruction() { + super.instructionId = "TEXT"; + } + + @Override + public String convertNE(AnnotationFS neFrom, CAS cas, Util_impl util) { + + return neFrom.getCoveredText().replaceAll("\n", ""); + } + + @Override + public String convertToken(AnnotationFS tok, CAS cas, Util_impl util) { + + return tok.getCoveredText().replaceAll("\n", ""); + } + + @Override + public SentenceElementEntry createEntry(AnnotationFS tok, CAS cas, Util_impl util) { + + String text = tok.getCoveredText().replaceAll("\n", ""); + return new SentenceElementEntry(instructionId, text); + } + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToW2VConversionInstruction.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToW2VConversionInstruction.java new file mode 100644 index 0000000..0b937e5 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/instructions/ToW2VConversionInstruction.java @@ -0,0 +1,54 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.instructions; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mk.kall.projectresources.KallimachosResourceLoader; +import de.uniwue.mk.kall.ruleBasedRelationClassification.matrix.structs.SentenceElementEntry; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class ToW2VConversionInstruction extends AConversionInsruction { + + /** + * + */ + private static final long serialVersionUID = -3111917197051115550L; + + public ToW2VConversionInstruction() { + super.instructionId = "W2V_CLUSTER"; + } + + @Override + public String convertNE(AnnotationFS neFrom, CAS cas, Util_impl util) { + + return neFrom.getCoveredText().replaceAll("\n", ""); + } + + @Override + public String convertToken(AnnotationFS tok, CAS cas, Util_impl util) { + + return tok.getFeatureValueAsString(util.getPOSTagFeature()); + } + + @Override + public SentenceElementEntry createEntry(AnnotationFS tok, CAS cas, Util_impl util) { + // no comma matches!! + if (tok.getCoveredText().matches(",")) { + return new SentenceElementEntry(instructionId, ","); + + } + + String w2vCategories = KallimachosResourceLoader.getW2VCategories(tok.getCoveredText()); + + if (w2vCategories == null) { + return new SentenceElementEntry(instructionId, tok.getCoveredText()); + } + + else { + // return the first entry + return new SentenceElementEntry(instructionId, w2vCategories); + } + + } + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SearchResult.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SearchResult.java new file mode 100644 index 0000000..379661f --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SearchResult.java @@ -0,0 +1,31 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.matrix.structs; + +public class SearchResult { + + private double amountOfCommonWays; + + private double probabiliy; + + public SearchResult(double amountOfCommonWays, double probability) { + super(); + this.amountOfCommonWays = amountOfCommonWays; + this.probabiliy = probability; + } + + public double getAmountOfCommonWays() { + return amountOfCommonWays; + } + + public void setAmountOfCommonWays(double amountOfCommonWays) { + this.amountOfCommonWays = amountOfCommonWays; + } + + public double getProbabiliy() { + return probabiliy; + } + + public void setProbabiliy(double probabiliy) { + this.probabiliy = probabiliy; + } + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceElement.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceElement.java new file mode 100644 index 0000000..85ae719 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceElement.java @@ -0,0 +1,196 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.matrix.structs; + +import java.io.Serializable; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +import javax.xml.bind.annotation.XmlTransient; + +import org.apache.uima.cas.text.AnnotationFS; + +public class SentenceElement implements Serializable { + + // this is the vector for a token + + /** + * + */ + private static final long serialVersionUID = 1L; + + // the elementEntries of the vector + private List<SentenceElementEntry> elementEntries; + + private boolean hasMatchedToken; + + // this information tells us which words are more important in a sentence + // than others + private int lowestDepLvl; + + // the actual ne do not serialize it + private transient AnnotationFS ne; + + public SentenceElement(List<SentenceElementEntry> entries) { + super(); + this.elementEntries = entries; + } + + public SentenceElement() { + } + + @XmlTransient + public AnnotationFS getNe() { + return ne; + } + + public void setNe(AnnotationFS ne) { + this.ne = ne; + } + + public int getLowestDepLvl() { + return lowestDepLvl; + } + + public void setLowestDepLvl(int lowestDepLvl) { + this.lowestDepLvl = lowestDepLvl; + } + + // use this method to get the elements of the vector - sorted by id + public synchronized List<SentenceElementEntry> getEntriesOrdered() { + + Collections.sort(this.elementEntries, new Comparator<SentenceElementEntry>() { + + @Override + public int compare(SentenceElementEntry o1, SentenceElementEntry o2) { + + return o1.getId().compareTo(o2.getId()); + } + }); + + return this.elementEntries; + + } + + public boolean hasNonNullMatch() { + + for (SentenceElementEntry entry : this.elementEntries) { + + if (!entry.getValue().equals(SentenceElementEntry.NULL_VALUE) && entry.isHasMatched()) { + return true; + } + } + + return false; + } + + public double getAmountOfMatches() { + + int matches = 0; + + for (SentenceElementEntry entry : this.elementEntries) { + + if (entry.getValue().equals(SentenceElementEntry.NULL_VALUE) || entry.isHasMatched()) { + matches++; + } + } + + if (matches <= 1) + return matches; + + else { + + // use the logarith because the numbers can be insanely huge + return Math.log(matches); + } + + } + + public boolean isHasMatchedToken() { + return hasMatchedToken; + } + + public void setHasMatchedToken(boolean hasMatchedToken) { + this.hasMatchedToken = hasMatchedToken; + } + + public synchronized void resetDecisions() { + + for (SentenceElementEntry entry : this.elementEntries) { + entry.setHasMatched(false); + } + + } + + public boolean matches(SentenceElementEntry entryOther) { + + SentenceElementEntry entryThis = getEntryById(entryOther.getId()); + // if we have a null value we match + + // System.out.println(entryThis.getId() + "\t" + entryOther.getValue()); + + // we should not use this null match here !! + // if (entryThis.getValue().equals(SentenceElementEntry.NULL_VALUE)) { + // entryThis.setHasMatched(true); + // return true; + // } + // otherwise we need a stringmatch + if (entryThis != null && entryThis.getValue().equals(entryOther.getValue())) { + entryThis.setHasMatched(true); + return true; + } + + return false; + } + + // TODO this is slow + private synchronized SentenceElementEntry getEntryById(String id) { + + for (SentenceElementEntry entry : this.elementEntries) { + + if (entry.getId().equals(id)) + return entry; + } + return null; + } + + public boolean hasNullEntries() { + + for (SentenceElementEntry entry : this.elementEntries) { + + if (entry.getValue().equals(SentenceElementEntry.NULL_VALUE)) + return true; + } + + return false; + } + + public List<SentenceElementEntry> getElementEntries() { + return elementEntries; + } + + public void setElementEntries(List<SentenceElementEntry> elementEntries) { + this.elementEntries = elementEntries; + } + + @Override + public String toString() { + + String vec = ""; + + for (SentenceElementEntry entry : getEntriesOrdered()) { + vec += entry.getValue() + "\n"; + } + return vec; + } + + public boolean matches(String string) { + + for (SentenceElementEntry entry : this.elementEntries) { + + if (entry.getValue().equals(string)) + return true; + } + return false; + } + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceElementEntry.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceElementEntry.java new file mode 100644 index 0000000..4fc1447 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceElementEntry.java @@ -0,0 +1,55 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.matrix.structs; + +import java.io.Serializable; + +public class SentenceElementEntry implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 1L; + + private String id; + + private String value; + + private boolean hasMatched = false; + + // NULL VALUE => this is a wildcard and can be seen as a match + public static final String NULL_VALUE = "NULL"; + + public SentenceElementEntry(String id, String value) { + + this.id = id; + this.value = value; + } + + public SentenceElementEntry() { + + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public boolean isHasMatched() { + return hasMatched; + } + + public void setHasMatched(boolean hasMatched) { + this.hasMatched = hasMatched; + } + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceElementMatrix.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceElementMatrix.java new file mode 100644 index 0000000..bc26d33 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceElementMatrix.java @@ -0,0 +1,174 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.matrix.structs; + +import java.io.Serializable; +import java.util.List; + +public class SentenceElementMatrix implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 1L; + + // the matrix of a sentence + private List<SentenceElement> vectors; + + private int id; + + private SentenceElement neFrom; + + private SentenceElement neTo; + + private boolean isGoldCoreferent; + + public SentenceElementMatrix(List<SentenceElement> vectors, SentenceElement neFrom, SentenceElement neTo) { + + this.vectors = vectors; + this.neFrom = neFrom; + this.neTo = neTo; + } + + public SentenceElementMatrix() { + + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public List<SentenceElement> getVectors() { + return vectors; + } + + public void setVectors(List<SentenceElement> vectors) { + this.vectors = vectors; + } + + public boolean isGoldCoreferent() { + return isGoldCoreferent; + } + + public void setGoldCoreferent(boolean isGoldCoreferent) { + this.isGoldCoreferent = isGoldCoreferent; + } + + public SentenceElement getNeFrom() { + return neFrom; + } + + public void setNeFrom(SentenceElement neFrom) { + this.neFrom = neFrom; + } + + public SentenceElement getNeTo() { + return neTo; + } + + public void setNeTo(SentenceElement neTo) { + this.neTo = neTo; + } + + public double getAmountOfActivatePaths() { + + double totalMatches = 1; + totalMatches *= neFrom.getAmountOfMatches(); + totalMatches *= neTo.getAmountOfMatches(); + + for (SentenceElement element : this.vectors) { + totalMatches *= element.getAmountOfMatches(); + } + return totalMatches; + } + + @Override + public String toString() { + + // get max vector size + + String stringNeFrom = neFrom.toString(); + int matrixRows = getMatrixRows(); + + String stringNeTo = neTo.toString(); + + String matrix = ""; + for (int i = 0; i < matrixRows; i++) { + + String[] split = stringNeFrom.toString().split("\n"); + + if (i < split.length) { + matrix += split[i] + "\t"; + } + + else { + matrix += "<EMPTY>\t"; + } + + for (SentenceElement element : vectors) { + String[] vecString = element.toString().split("\n"); + + if (i < vecString.length) { + matrix += vecString[i] + "\t"; + } + + else { + matrix += "<EMPTY>\t"; + } + } + + split = stringNeTo.toString().split("\n"); + + if (i < split.length) { + matrix += split[i]; + } + + else { + + matrix += "<EMPTY>"; + } + + matrix += "\n"; + } + return matrix; + + } + + private int getMatrixRows() { + + if (vectors.size() == 0) { + return neFrom.getEntriesOrdered().size(); + } + + else { + return vectors.get(0).getEntriesOrdered().size(); + } + } + + // assumes is splitted by spaces + public boolean hasMatrixPath(String s) { + + String[] split = s.split(" "); + + if (split.length < 2) + return false; + + if (split.length - 2 != this.vectors.size()) + return false; + + // now we need to try + + // check ne vectors first + if (!neFrom.matches(split[0]) || !neTo.matches(split[split.length - 1])) + return false; + + for (int i = 1; i < split.length - 1; i++) { + if (!this.vectors.get(i - 1).matches(split[i])) + return false; + } + + return true; + } +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceElementUtil.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceElementUtil.java new file mode 100644 index 0000000..8640c18 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceElementUtil.java @@ -0,0 +1,128 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.matrix.structs; + +public class SentenceElementUtil { + + public synchronized static SearchResult performSimilaritySearch(SentenceElementMatrix data, + SentenceElementMatrix gold) { + + // perform the search => not that easy :) + + // prepapre the gold-data strcuture => set every match to false + reset(gold, data); + + // compare the namedentities first if they are compatible, if not return + // 0 + long compatibleElementsNEFrom = compareVectors(data.getNeFrom(), gold.getNeFrom()); + + if (compatibleElementsNEFrom == 0) { + return new SearchResult(0, 1.0); + } + + long compatibleElementsNeTo = compareVectors(data.getNeTo(), gold.getNeTo()); + + if (compatibleElementsNeTo == 0) { + return new SearchResult(0, 1.0); + } + + // we need a valid mapping to each token in the goldMatrix -> afterwards + // we can calc the amount + // of valid ways + + // now compare all the tokens between the NEs + + for (SentenceElement vecGold : gold.getVectors()) { + + for (SentenceElement vecCand : data.getVectors()) { + // never assign a token twice + if (vecCand.isHasMatchedToken()) + continue; + + // match those vectors + long commonElements = compareVectors(vecCand, vecGold); + + // if there are 0 common elements we have failed to find a path + if (commonElements == 0) { + return new SearchResult(0, 1.0); + } + // if the tokens are compatible (have non null compatibility) + // we use this match and try to match to the next gold token + if (vecGold.hasNonNullMatch()) { + // continue with the next gold token + vecCand.setHasMatchedToken(true); + break; + } + + else { + // if we can skip the current token of the candidate (e.g. + // if it has null entries) + if (vecCand.hasNullEntries()) { + // try to match the next token to the gold token + continue; + } + + else { + + // if we cannot skip the current token and have no match + // we cannot find a valid path + return new SearchResult(0, 1.0); + } + } + + } + } + + // if the candidate has used all its tokens aka the last matched token + // has to be the last token + // or if all of the remaining tokens have null values + double activePathsThroughCand = data.getAmountOfActivatePaths(); + + // if not all tokens are used we will have a 0 here + if (activePathsThroughCand == 0.0d) { + return new SearchResult(0, 1.0); + } + + // count the result + + double activePaths = gold.getAmountOfActivatePaths(); + + // TODO calculate a reasonable probability + return new SearchResult(activePaths, 1.337); + + } + + private static void reset(SentenceElementMatrix gold, SentenceElementMatrix data) { + + for (SentenceElement entry : gold.getVectors()) { + // set everything to false + entry.resetDecisions(); + } + + for (SentenceElement entry : data.getVectors()) { + // set everything to false + entry.resetDecisions(); + } + + // also no token assignment in candidates + + for (SentenceElement element : data.getVectors()) { + + element.setHasMatchedToken(false); + } + } + + public synchronized static long compareVectors(SentenceElement ne, SentenceElement neGold) { + + long commonMatches = 0; + for (SentenceElementEntry entryGold : neGold.getEntriesOrdered()) { + + // null value is a free match + if (ne.matches(entryGold) || entryGold.getValue().equals(SentenceElementEntry.NULL_VALUE)) { + commonMatches++; + entryGold.setHasMatched(true); + } + } + + return commonMatches; + } + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceMatrixCollection.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceMatrixCollection.java new file mode 100644 index 0000000..5d944f4 --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceMatrixCollection.java @@ -0,0 +1,60 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.matrix.structs; + +import java.io.Serializable; +import java.util.List; + +import javax.xml.bind.annotation.XmlRootElement; + +import de.uniwue.mk.kall.ruleBasedRelationClassification.instructions.AConversionInsruction; + +@XmlRootElement(namespace = "de.uniwue.mk.kall.sentencematrixcollection") +public class SentenceMatrixCollection implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 7982070957193073010L; + private List<SentenceElementMatrix> entries; + + private List<AConversionInsruction> instructionsTokens; + + private List<AConversionInsruction> instructionsNes; + + public SentenceMatrixCollection(List<SentenceElementMatrix> entries) { + super(); + this.entries = entries; + } + + public SentenceMatrixCollection(List<SentenceElementMatrix> structsTrain, + List<AConversionInsruction> instructionsNEs, List<AConversionInsruction> instructionsTokens) { + super(); + this.entries = structsTrain; + this.instructionsNes = instructionsNEs; + this.instructionsTokens = instructionsTokens; + } + + public List<AConversionInsruction> getInstructionsTokens() { + return instructionsTokens; + } + + public void setInstructionsTokens(List<AConversionInsruction> instructionsTokens) { + this.instructionsTokens = instructionsTokens; + } + + public List<AConversionInsruction> getInstructionsNes() { + return instructionsNes; + } + + public void setInstructionsNes(List<AConversionInsruction> instructionsNes) { + this.instructionsNes = instructionsNes; + } + + public List<SentenceElementMatrix> getEntries() { + return entries; + } + + public void setEntries(List<SentenceElementMatrix> entries) { + this.entries = entries; + } + +} diff --git a/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceMatrixFactory.java b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceMatrixFactory.java new file mode 100644 index 0000000..f97df3c --- /dev/null +++ b/de.uniwue.mk.kall.relationResources/src/de/uniwue/mk/kall/ruleBasedRelationClassification/matrix/structs/SentenceMatrixFactory.java @@ -0,0 +1,200 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.matrix.structs; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mk.kall.ruleBasedRelationClassification.instructions.AConversionInsruction; +import de.uniwue.mk.kall.ruleBasedRelationClassification.instructions.LookUpInputStruct; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class SentenceMatrixFactory { + + public static SentenceElementMatrix create(CAS cas, Util_impl util, AnnotationFS neFrom, AnnotationFS neTo, + List<AConversionInsruction> neInstructions, List<AConversionInsruction> tokenInstructions) { + + SentenceElement neFromElement = createNEElement(neFrom, cas, util, neInstructions); + + SentenceElement neToElement = createNEElement(neTo, cas, util, neInstructions); + + // get all tokens in between from and to (exclusive them) + List<AnnotationFS> coveredBetween = util.getCovered(neFrom.getEnd(), neTo.getBegin(), util.getPOSType()); + + List<SentenceElement> tokenElements = new ArrayList<SentenceElement>(); + for (AnnotationFS tok : coveredBetween) { + + tokenElements.add(createTokenElement(tok, cas, util, tokenInstructions)); + + } + + // set the gold feature + + String idFrom = neFrom.getFeatureValueAsString(util.getNEId()); + String idTo = neTo.getFeatureValueAsString(util.getNEId()); + + SentenceElementMatrix sentenceElementMatrix = new SentenceElementMatrix(tokenElements, neFromElement, + neToElement); + + boolean goldCoreferent = false; + + if (idFrom.equals(idTo)) { + goldCoreferent = true; + } + + sentenceElementMatrix.setGoldCoreferent(goldCoreferent); + + return sentenceElementMatrix; + } + + public static List<SentenceElementMatrix> createAndReduce(CAS cas, Util_impl util, AnnotationFS neFrom, + AnnotationFS neTo, List<AConversionInsruction> neInstructions, List<AConversionInsruction> tokenInstructions) { + + List<SentenceElementMatrix> matrizes = new ArrayList<SentenceElementMatrix>(); + SentenceElement neFromElement = createNEElement(neFrom, cas, util, neInstructions); + + SentenceElement neToElement = createNEElement(neTo, cas, util, neInstructions); + + // get all tokens in between from and to (exclusive them) + List<AnnotationFS> coveredBetween = util.getCovered(neFrom.getEnd(), neTo.getBegin(), util.getPOSType()); + + List<SentenceElement> tokenElements = new ArrayList<SentenceElement>(); + for (AnnotationFS tok : coveredBetween) { + + tokenElements.add(createTokenElement(tok, cas, util, tokenInstructions)); + + } + + // set the gold feature + + String idFrom = neFrom.getFeatureValueAsString(util.getNEId()); + String idTo = neTo.getFeatureValueAsString(util.getNEId()); + + SentenceElementMatrix sentenceElementMatrix = new SentenceElementMatrix(tokenElements, neFromElement, + neToElement); + + boolean goldCoreferent = false; + if (idFrom != null && idTo != null) { + if (idFrom.equals(idTo)) { + goldCoreferent = true; + } + } + sentenceElementMatrix.setGoldCoreferent(goldCoreferent); + + matrizes.add(sentenceElementMatrix); + + // also add all reduced variants if possible + + List<SentenceElementMatrix> reducedMatrices = reduceSentenceByImportance(tokenElements, neFromElement, + neToElement, goldCoreferent); + + matrizes.addAll(reducedMatrices); + + return matrizes; + } + + public static List<SentenceElementMatrix> reduceSentenceByImportance(List<SentenceElement> tokenElements, + SentenceElement neFromElement, SentenceElement neToElement, boolean goldCoreferent) { + + List<SentenceElementMatrix> reducedMatrizes = new ArrayList<SentenceElementMatrix>(); + + // the maximum of all tokens + int fromIteration = -1; + + for (SentenceElement el : tokenElements) { + if (el.getLowestDepLvl() > fromIteration) { + fromIteration = el.getLowestDepLvl(); + } + } + + // the maximum of the nes + int toIteration = Math.max(neFromElement.getLowestDepLvl(), neToElement.getLowestDepLvl()); + + // 1 reduced matrix per iteration + for (int i = fromIteration; i > toIteration; i--) { + + List<SentenceElement> reducedTokens = new ArrayList<SentenceElement>(); + + for (SentenceElement tok : tokenElements) { + // only keep if it has a lower lvl + if (tok.getLowestDepLvl() < i) { + reducedTokens.add(tok); + } + } + + // create the matrix + SentenceElementMatrix sentenceElementMatrix = new SentenceElementMatrix(reducedTokens, neFromElement, + neToElement); + sentenceElementMatrix.setGoldCoreferent(goldCoreferent); + + reducedMatrizes.add(sentenceElementMatrix); + } + + return reducedMatrizes; + } + + private static SentenceElement createTokenElement(AnnotationFS tok, CAS cas, Util_impl util, + List<AConversionInsruction> tokenInstructions) { + + // we need a list of entries + + List<SentenceElementEntry> entries = new ArrayList<SentenceElementEntry>(); + for (AConversionInsruction instruction : tokenInstructions) { + + SentenceElementEntry entry = instruction.createEntry(tok, cas, util); + + entries.add(entry); + } + + SentenceElement element = new SentenceElement(entries); + + // also set the dep parse information + + int lowestDeplvl = getLowestDepLvl(tok, cas, util); + element.setLowestDepLvl(lowestDeplvl); + return element; + } + + private static SentenceElement createNEElement(AnnotationFS ne, CAS cas, Util_impl util, + List<AConversionInsruction> neInstructions) { + List<SentenceElementEntry> entries = new ArrayList<SentenceElementEntry>(); + for (AConversionInsruction instruction : neInstructions) { + + SentenceElementEntry entry = instruction.createEntry(ne, cas, util); + + entries.add(entry); + } + + SentenceElement element = new SentenceElement(entries); + element.setNe(ne); + + // also set the dep parse information + + int lowestDeplvl = getLowestDepLvl(ne, cas, util); + element.setLowestDepLvl(lowestDeplvl); + + return element; + } + + private static int getLowestDepLvl(AnnotationFS ne, CAS cas, Util_impl util) { + + int lowest = Integer.MAX_VALUE; + for (AnnotationFS dep : util.getCovered(ne, util.getDependencyType())) { + + int depLevel = util.getDepLevel(dep); + + if (depLevel < lowest) + lowest = depLevel; + } + return lowest; + } + + public static SentenceElementMatrix create(CAS cas, Util_impl util, LookUpInputStruct struct, + List<AConversionInsruction> neInstructions, List<AConversionInsruction> tokenInstructions) { + + return create(cas, util, struct.getNeFrom(), struct.getNeTo(), neInstructions, tokenInstructions); + + } + +} diff --git a/de.uniwue.mk.kall.relationen.visualizeOntology/.classpath b/de.uniwue.mk.kall.relationen.visualizeOntology/.classpath new file mode 100644 index 0000000..b862a29 --- /dev/null +++ b/de.uniwue.mk.kall.relationen.visualizeOntology/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/de.uniwue.mk.kall.relationen.visualizeOntology/.gitignore b/de.uniwue.mk.kall.relationen.visualizeOntology/.gitignore new file mode 100644 index 0000000..5e56e04 --- /dev/null +++ b/de.uniwue.mk.kall.relationen.visualizeOntology/.gitignore @@ -0,0 +1 @@ +/bin diff --git a/de.uniwue.mk.kall.relationen.visualizeOntology/.project b/de.uniwue.mk.kall.relationen.visualizeOntology/.project new file mode 100644 index 0000000..265803c --- /dev/null +++ b/de.uniwue.mk.kall.relationen.visualizeOntology/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>de.uniwue.mk.kall.relationen.visualizeOntology</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/de.uniwue.mk.kall.relationen.visualizeOntology/.settings/org.eclipse.jdt.core.prefs b/de.uniwue.mk.kall.relationen.visualizeOntology/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..295926d --- /dev/null +++ b/de.uniwue.mk.kall.relationen.visualizeOntology/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/de.uniwue.mk.kall.relationen.visualizeOntology/.settings/org.eclipse.pde.core.prefs b/de.uniwue.mk.kall.relationen.visualizeOntology/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 0000000..b7e72d0 --- /dev/null +++ b/de.uniwue.mk.kall.relationen.visualizeOntology/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/de.uniwue.mk.kall.relationen.visualizeOntology/META-INF/MANIFEST.MF b/de.uniwue.mk.kall.relationen.visualizeOntology/META-INF/MANIFEST.MF new file mode 100644 index 0000000..882e5a8 --- /dev/null +++ b/de.uniwue.mk.kall.relationen.visualizeOntology/META-INF/MANIFEST.MF @@ -0,0 +1,7 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: VisualizeOntology +Bundle-SymbolicName: de.uniwue.mk.kall.relationen.visualizeOntology +Bundle-Version: 1.0.0.qualifier +Require-Bundle: de.uniwue.mk.parser.algos;bundle-version="1.0.0" +Export-Package: de.uniwue.mk.kall.relationen.visualizeOntology.struct diff --git a/de.uniwue.mk.kall.relationen.visualizeOntology/build.properties b/de.uniwue.mk.kall.relationen.visualizeOntology/build.properties new file mode 100644 index 0000000..41eb6ad --- /dev/null +++ b/de.uniwue.mk.kall.relationen.visualizeOntology/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/de.uniwue.mk.kall.relationen.visualizeOntology/src/de/uniwue/mk/kall/relationen/visualizeOntology/app/VisualizeOntologyMain.java b/de.uniwue.mk.kall.relationen.visualizeOntology/src/de/uniwue/mk/kall/relationen/visualizeOntology/app/VisualizeOntologyMain.java new file mode 100644 index 0000000..273279e --- /dev/null +++ b/de.uniwue.mk.kall.relationen.visualizeOntology/src/de/uniwue/mk/kall/relationen/visualizeOntology/app/VisualizeOntologyMain.java @@ -0,0 +1,146 @@ +package de.uniwue.mk.kall.relationen.visualizeOntology.app; + +import java.awt.Color; +import java.awt.Component; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.List; + +import javax.imageio.ImageIO; +import javax.swing.JFrame; + +import org.antlr.v4.runtime.tree.gui.TreeViewer; + +import de.uniwue.mk.kall.relationen.visualizeOntology.struct.Relation; + +public class VisualizeOntologyMain { + + public static final String SUBSUMED = "SUBSUMIERT_VON:"; + public static final String ROOT = "hatRelation"; + + public static void main(String[] args) throws Exception { + + String location = getExecutionPath(); + + // String location = + // "C:\\owncloud\\projekt romangeschichte\\ActiveLearningRelationen\\ontologie\\Relationen"; + + List<Relation> relations = new ArrayList<>(); + for (File f : new File(location).listFiles()) { + + if (!f.getName().endsWith(".txt")) + continue; + + String relName = f.getName().replaceAll("\\..*", ""); + + Relation r = new Relation(relName); + relations.add(r); + r.setFile(f); + + } + + // set parents/children + for (Relation r : relations) { + + Relation father = getFatherRelation(r, relations); + + if (father != null) { + r.setParent(father); + father.addChild(r); + + System.out.println("Relation " + r.getRelationName() + " Father:" + father.getRelationName()); + } + + } + + System.out.println(relations.size()); + + // and now find the root relation + + Relation root = null; + + for (Relation r : relations) { + + if (r.getPayload().equals(ROOT)) + root = r; + } + + if (root != null) { + + BufferedImage parseTreeToImage = parseTreeToImage(root); + + ImageIO.write(parseTreeToImage, "PNG", new File(location + "/ontology.png")); + } + + System.exit(0); + + } + + private static Relation getFatherRelation(Relation r, List<Relation> relations) { + + File f = r.getFile(); + + try { + List<String> lines = Files.readAllLines(f.toPath(), StandardCharsets.ISO_8859_1); + + for (String line : lines) { + + if (line.startsWith(SUBSUMED)) { + return getFatherFromString(line.split(SUBSUMED)[1], relations); + } + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + private static Relation getFatherFromString(String string, List<Relation> relations) { + + for (Relation r : relations) { + if (r.getPayload().equals(string.trim())) + return r; + } + return null; + } + + private static String getExecutionPath() { + String absolutePath = VisualizeOntologyMain.class.getProtectionDomain().getCodeSource().getLocation().getPath(); + absolutePath = absolutePath.substring(0, absolutePath.lastIndexOf("/")); + absolutePath = absolutePath.replaceAll("%20", " "); // Surely need to do + // this here + return absolutePath; + } + + public static BufferedImage parseTreeToImage(Relation root) { + + // TODO this is somewhat ugly code + JFrame frame = new JFrame("Visualisierung"); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + // frame.setVisible(false); + frame.setBackground(Color.WHITE); + + TreeViewer tw = new TreeViewer(null, root); + + frame.add(tw); + frame.pack(); + BufferedImage img = getScreenShot(frame.getContentPane()); + + return img; + } + + public static BufferedImage getScreenShot(Component component) { + + BufferedImage image = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_RGB); + // call the Component's paint method, using + // the Graphics object of the image. + component.paint(image.getGraphics()); // alternately use .printAll(..) + return image; + } + +} diff --git a/de.uniwue.mk.kall.relationen.visualizeOntology/src/de/uniwue/mk/kall/relationen/visualizeOntology/struct/Relation.java b/de.uniwue.mk.kall.relationen.visualizeOntology/src/de/uniwue/mk/kall/relationen/visualizeOntology/struct/Relation.java new file mode 100644 index 0000000..09bfb9f --- /dev/null +++ b/de.uniwue.mk.kall.relationen.visualizeOntology/src/de/uniwue/mk/kall/relationen/visualizeOntology/struct/Relation.java @@ -0,0 +1,124 @@ +package de.uniwue.mk.kall.relationen.visualizeOntology.struct; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.antlr.v4.runtime.tree.Tree; + +public class Relation implements Tree { + + Relation parent; + List<Relation> children; + Relation inverse; + + String relationName; + private File file; + + public Relation(String name) { + this.relationName = name; + children = new ArrayList<Relation>(); + + } + + @Override + public Tree getChild(int arg0) { + + return children.get(arg0); + } + + @Override + public int getChildCount() { + return children.size(); + } + + @Override + public Tree getParent() { + return this.parent; + } + + @Override + public Object getPayload() { + return relationName; + } + + @Override + public String toStringTree() { + // TODO Auto-generated method stub + return null; + } + + public void setFile(File f) { + this.file = f; + + } + + public File getFile() { + return this.file; + } + + public List<Relation> getChildren() { + return children; + } + + public void setChildren(List<Relation> children) { + this.children = children; + } + + public String getRelationName() { + return relationName; + } + + public void setRelationName(String relationName) { + this.relationName = relationName; + } + + public void setParent(Relation parent) { + this.parent = parent; + } + + public void addChild(Relation child) { + + if (!this.children.contains(child)) + children.add(child); + } + + public Relation getInverse() { + return inverse; + } + + public void setInverse(Relation inverse) { + this.inverse = inverse; + } + + public Relation getChildByLabel(String label) { + + List<Relation> allChildren = getAllChildren(); + + for (Relation r : allChildren) { + if (r.getRelationName().equals(label)) { + return r; + } + } + + if (label.equals(this.relationName)) + return this; + return null; + } + + public List<Relation> getAllChildren() { + + List<Relation> childs = new ArrayList<>(); + + if (children.size() == 0) { + return children; + } else { + for (Relation child : children) { + childs.add(child); + childs.addAll(child.getAllChildren()); + } + } + return childs; + } + +} diff --git a/de.uniwue.mk.kall.relationen.visualizeOntology/src/de/uniwue/mk/kall/relationen/visualizeOntology/struct/RelationIOUtil.java b/de.uniwue.mk.kall.relationen.visualizeOntology/src/de/uniwue/mk/kall/relationen/visualizeOntology/struct/RelationIOUtil.java new file mode 100644 index 0000000..f1b207e --- /dev/null +++ b/de.uniwue.mk.kall.relationen.visualizeOntology/src/de/uniwue/mk/kall/relationen/visualizeOntology/struct/RelationIOUtil.java @@ -0,0 +1,127 @@ +package de.uniwue.mk.kall.relationen.visualizeOntology.struct; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.List; + +public class RelationIOUtil { + public static final String SUBSUMED = "SUBSUMIERT_VON:"; + public static final String ROOT = "hatRelation"; + public static final String INVERSE = "INVERS_ZU:"; + public static final String SYMMETRIC = "SYMMETRISCH:"; + + public static Relation readOntology(File folder) { + + List<Relation> relations = new ArrayList<>(); + for (File f : folder.listFiles()) { + + if (!f.getName().endsWith(".txt")) + continue; + + String relName = f.getName().replaceAll("\\..*", ""); + + Relation r = new Relation(relName); + relations.add(r); + r.setFile(f); + + } + + // set parents/children/inverse + for (Relation r : relations) { + + Relation father = getFatherRelation(r, relations); + + if (father != null) { + r.setParent(father); + father.addChild(r); + + } + + Relation inverseRelation = getInverseRelation(r, relations); + + if (inverseRelation != null) { + r.setInverse(inverseRelation); + } else { + + System.out.println(r.getPayload()); + } + } + + System.out.println(relations.size()); + + // and now find the root relation + + Relation root = null; + + for (Relation r : relations) { + + if (r.getPayload().equals(ROOT)) + root = r; + } + return root; + } + + private static Relation getFatherRelation(Relation r, List<Relation> relations) { + + File f = r.getFile(); + + try { + List<String> lines = Files.readAllLines(f.toPath(), StandardCharsets.ISO_8859_1); + + for (String line : lines) { + + if (line.startsWith(SUBSUMED)) { + return getRelationFromString(line.split(SUBSUMED)[1], relations); + } + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + private static Relation getInverseRelation(Relation r, List<Relation> relations) { + + File f = r.getFile(); + + try { + List<String> lines = Files.readAllLines(f.toPath(), StandardCharsets.ISO_8859_1); + + for (String line : lines) { + + if (line.startsWith(INVERSE)) { + return getRelationFromString(line.split(INVERSE)[1], relations); + } + + else if (line.startsWith(SYMMETRIC)) { + + String symm = line.split(SYMMETRIC)[1]; + + if (symm.toLowerCase().contains("nein")) + continue; + + // its own inverse + return r; + } + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + private static Relation getRelationFromString(String string, List<Relation> relations) { + + for (Relation r : relations) { + if (r.getPayload().equals(string.trim())) + return r; + } + return null; + } + +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/.classpath b/de.uniwue.mk.kall.ruleBasedRelationClassification/.classpath new file mode 100644 index 0000000..b862a29 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/.gitignore b/de.uniwue.mk.kall.ruleBasedRelationClassification/.gitignore new file mode 100644 index 0000000..5e56e04 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/.gitignore @@ -0,0 +1 @@ +/bin diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/.project b/de.uniwue.mk.kall.ruleBasedRelationClassification/.project new file mode 100644 index 0000000..a2c8cfa --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>de.uniwue.mk.kall.ruleBasedRelationClassification</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/.settings/org.eclipse.jdt.core.prefs b/de.uniwue.mk.kall.ruleBasedRelationClassification/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..295926d --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/.settings/org.eclipse.pde.core.prefs b/de.uniwue.mk.kall.ruleBasedRelationClassification/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 0000000..b7e72d0 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/META-INF/MANIFEST.MF b/de.uniwue.mk.kall.ruleBasedRelationClassification/META-INF/MANIFEST.MF new file mode 100644 index 0000000..9c3cb2f --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/META-INF/MANIFEST.MF @@ -0,0 +1,12 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: RuleBasedRelationClassification +Bundle-SymbolicName: de.uniwue.mk.kall.ruleBasedRelationClassification +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: de.uniwue.mkrug.kall.typesystemUtil;bundle-version="1.0.0", + de.uniwue.mk.kall.projectresources;bundle-version="1.0.0", + de.uniwue.mk.kall.relationResources;bundle-version="1.0.0", + de.uniwue.mk.kall.neCategoryDetermination.app;bundle-version="1.0.0" +Export-Package: de.uniwue.mk.kall.ruleBasedRelationClassification.algo, + de.uniwue.mk.kall.ruleBasedRelationClassification.struct diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/build.properties b/de.uniwue.mk.kall.ruleBasedRelationClassification/build.properties new file mode 100644 index 0000000..41eb6ad --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/dependencypath/deppaths.txt b/de.uniwue.mk.kall.ruleBasedRelationClassification/dependencypath/deppaths.txt new file mode 100644 index 0000000..34c11be --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/dependencypath/deppaths.txt @@ -0,0 +1,37 @@ +<FIRST> trifft Freund hatFeund(1,2) +er heiratet <SECOND> hatEhefrau(1,2) +sie heiratet <SECOND> hatEhemann(1,2) +<FIRST> heiratet er hatEhemann(1,2) +<FIRST> tritt in Dienst <SECOND> hatVorgesetzten(1,2) +<FIRST> kennen <SECOND> hatFreund(1,2) +Mentor findet Entwicklung <GENITIV> hatLehrer(2,1) +<FIRST> liebt <SECOND> hatGeliebten(1,2) +<FIRST> verliebt in <SECOND> hatGeliebten(1,2) +<FIRST> lässt Zuneigung zu <SECOND> hatGeliebten(1,2) +sein Weib sampt Sohn hatSohn(1,2) +<FIRST> trage Kind hatkind(1,2) +<FIRST> wird Ehefrau hatEhefrau(1,2) +<FIRST> offenbaren Freund hatFreund(1,2) +<FIRST> werde geboren Kind hatKind(1,2) +<FIRST> wächst bei Pflegeeltern hatPflegeelternteil(1,2) +er fiel Mutter hatMutter(1,2) +<FIRST> gehabt Kind hatKind(1,2) +<FIRST> kam zum Vater hatVater(1,2) +Sohn stieg und sah Mutter hatMutter(1,2) +Ich hab ein Kind hatKind(1,2) +<FIRST> träfe Eltern hatElternteil(1,2) +<FIRST> ließ an Schwester hatSchwester(1,2) +<FIRST> bedient <SECOND> hatAngestellten(1,2) +<FIRST> konnte sagen Mutter hatMutter(1,2) +Mutter ermahnte sie hatTochter(1,2) +<FIRST> richtet Tochter hatTochter(1,2) +<FIRST> heimführt Gemahlin hatEhefrau(1,2) +<FIRST> beschenkte Mutter hatMutter(1,2) +<FIRST> hatte gebracht Freund hatFreund(1,2) +<FIRST> ausspannen <SECOND> hatNebenbuhler(1,2) +<FIRST> hält bei Verwandten hatVerwandten(1,2) +<FIRST> ist einer Liebhaber hatGeliebten(1,2) +<FIRST> schloß Freundin hatFreund(1,2) +<FIRST> schickte Magd hatAngestellten(1,2) +<FIRST> schmiegte an Sohn hatSohn(1,2) +<FIRST> trat Verlust Freundes hatFreund(1,2) \ No newline at end of file diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/matrixPaths/matrixpaths.txt b/de.uniwue.mk.kall.ruleBasedRelationClassification/matrixPaths/matrixpaths.txt new file mode 100644 index 0000000..e69de29 diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/possessives/possessives.txt b/de.uniwue.mk.kall.ruleBasedRelationClassification/possessives/possessives.txt new file mode 100644 index 0000000..6b7d79f --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/possessives/possessives.txt @@ -0,0 +1,232 @@ +Vater hatVater(1,2) +Papa hatVater(1,2) +Vaters hatVater(1,2) +Vader hatVater(1,2) +Vadern hatVater(1,2) + + + +Mama hatMutter(1,2) +Mutti hatMutter(1,2) +Mutter hatMutter(1,2) + +Frau hatEhefrau(1,2) +Gemahlin hatEhefrau(1,2) +Gattin hatEhefrau(1,2) +Weib hatEhefrau(1,2) +Weibes hatEhefrau(1,2) +Ehefrau hatEhefrau(1,2) + +Mann hatEhemann(1,2) +Männer hatEhemann(1,2) +Manne hatEhemann(1,2) +Mannes hatEhemann(1,2) +Gemahl hatEhemann(1,2) +Gemahls hatEhemann(1,2) +Herr Gemahl hatEhemann(1,2) +Herrn Gemahls hatEhemann(1,2) +Herrn Gemahl hatEhemann(1,2) +Gatte hatEhemann(1,2) +Gatten hatEhemann(1,2) +Neuvermählten hatEhemann(1,2) +Eheherrn hatEhemann(1,2) +eeman hatEhemann(1,2) +Manen hatEhemann(1,2) + +Chef hatVorgesetzten(1,2) +Chefs hatVorgesetzten(1,2) +Vorgesetzten hatVorgesetzten(1,2) +Hauptmann hatVorgesetzten(1,2) + +Freund hatFreund(1,2) +Wohtäter hatFreund(1,2) +Freundin hatFreund(1,2) +Freundes hatFreund(1,2) +Freunde hatFreund(1,2) +Schulfreund hatFreund(1,2) +Schulfreundin hatFreund(1,2) + +Vetter hatVerwandten(1,2) +Vettern hatVerwandten(1,2) +Schwiegermutter hatVerwandten(1,2) +Schwager hatVerwandten(1,2) +Schwäher hatVerwandten(1,2) +Schwieger hatVerwandten(1,2) +Schwägerin gatVerwandten(1,2) +Verwandten hatVerwandten(1,2) + +Tante hatTante(1,2) +Base hatTante(1,2) + +Onkel hatOnkel(1,2) +Oheim hatOnkel(1,2) +Oheims hatOnkel(1,2) + +Frau Tochter hatTochter(1,2) +Tochter hatTochter(1,2) +Toch-ter hatTochter(1,2) +Töchter hatTochter(1,2) +Töchtern hatTochter(1,2) +Mädchen hatTochter(1,2) +Mädle hatTochter(1,2) + +Sohn hatSohn(1,2) +Söhnen hatSohn(1,2) +Sohne hatSohn(1,2) +Sohnes hatSohn(1,2) +Bube hatSohn(1,2) +Buben hatSohn(1,2) +Bub hatSohn(1,2) +Bubn hatSohn(1,2) +Erstgeborenen hatSohn(1,2) + +Kind hatKind(1,2) +Kinde hatKind(1,2) +Kindes hatKind(1,2) +Kinder hatKind(1,2) +Kindern hatKind(1,2) + +Bruder hatBruder(1,2) +Bruders hatBruder(1,2) +Brůder hatBruder(1,2) +brůder hatBruder(1,2) +Herzbruder hatBruder(1,2) +Brüdern hatBruder(1,2) + +Schwester hatSchwester(1,2) + +Neffe hatNeffe(1,2) +Neffen hatNeffe(1,2) + +Nichte hatNichte(1,2) + +Lehrer hatLehrer(1,2) +Lehrern hatLehrer(1,2) +Lehrers hatLehrer(1,2) +Lehrmeister hatLehrer(1,2) +Lehrerin hatLehrer(1,2) +Lehrmeisterin hatLehrer(1,2) + +Banquier hatDienstleister(1,2) +Anwalt hatDienstleister(1,2) +Doktor hatDienstleister(1,2) +Untergebenen hatDienstleister(1,2) +Briefträger hatDienstleister(1,2) +Wirtin hatDienstleister(1,2) +Arztes hatDienstleister(1,2) +Pflegerin hatDienstleister(1,2) + + +Geliebte hatGeliebte(1,2) +Geliebter hatGeliebte(1,2) +Geliebten hatGeliebten(1,2) +Liebhaber hatGeliebten(1,2) +Angebetete hatGeliebten(1,2) +Angebeteter hatGeliebten(1,2) +Jugendliebe hatGeliebten(1,2) + +Nebenbuhler hatRivale(1,2) +Nebnbuhlerin hatRivale(1,2) +Gegenspieler hatRivale(1,2) +Widersacher hatRivale(1,2) + +Braut hatVerlobten(1,2) +Bräutigam hatVerlobten(1,2) +Verlobter hatVerlobten(1,2) +Verlobten hatVerlobten(1,2) +Verlobte hatVerlobten(1,2) + +Feind hatFeind(1,2) +Feindes hatFeind(1,2) +Verfolger hatFeind(1,2) + +Gast hatSozialeRelation(1,2) +Begleiterin hatSozialeRelation(1,2) +Begleiter hatSozialeRelation(1,2) +Gaste hatSozialeRelation(1,2) +Nebenmenschen hatSozialeRelation(1,2) +Schulkameraden hatSozialeRelation(1,2) +Waldleute hatSozialeRelation(1,2) +Entführer hatSozialeRelation(1,2) +Mitmenschen hatSozialeRelation(1,2) +Nachbar hatSozialeRelation(1,2) +Nachbarin hatSozialeRelation(1,2) +Nachbarinnen hatSozialeRelation(1,2) +Nachbaren hatSozialeRelation(1,2) +Nachbarn hatSozialeRelation(1,2) +Gäste hatSozialeRelation(1,2) +Jäger hatSozialeRelation(1,2) +Gastfreund hatSozialeRelation(1,2) +Gastfreundes hatSozialeRelation(1,2) +Beichtvater hatSozialeRelation(1,2) +Bekannter hatSozialeRelation(1,2) +Bekannte hatSozialeRelation(1,2) +Bekannten hatSozialeRelation(1,2) +Altersgenossen hatSozialeRelation(1,2) + +dienerin hatDiener(1,2) +Diener hatDiener(1,2) +Dieners hatDiener(1,2) +Dienerin hatDiener(1,2) +Gehilfen hatDiener(1,2) + +Amme hatAngestellten(1,2) +Arbeiter hatAngestellten(1,2) +Magd hatAngestellten(1,2) +Mägde hatAngestellten(1,2) +Angestellten hatAngestellten(1,2) +Muhme hatAngestellten(1,2) + +Jugendfreund hatFreund(1,2) +Jugendfreundes hatFreund(1,2) +Jugendgenossen hatFreund(1,2) +Jugendgenossens hatFreund(1,2) + +Familie hatFamilienteil(1,2) + +Volk hatGebieter(2,1) +König hatGebieter(1,2) +Herrn hatGebieter(1,2) +Herrin hatGebieter(1,2) +Volke hatGebieter(2,1) +Lehnsherrn hatGebieter(1,2) +Gebieterin hatGebieter(1,2) +Gebieter hatGebieter(1,2) +Reitknecht hatGebieter(2,1) +Tyrannen hatgebieter(1,2) +Tyrann hatGebieter(1,2) + +Ziehvater hatPflegeelternteil(1,2) +Ziehvaters hatPflegeelternteil(1,2) +Pflegetochter hatPflegeelternteil(2,1) + +Kollegen hatArbeitskollegen(1,2) +Mitarbeiter hatArbeitskollegen(1,2) +Mitarbeiterinnen hatArbeitskollegen(1,2) +Stellvertreterin hatArbeitskollegen(1,2) +Berater hatArbeitskollegen(1,2) +Beraters hatArbeitskollegen(1,2) + +Vorfahren hatVorfahre(1,2) +Vorfahre hatVorfahre(1,2) +Ahn hatVorfahre(1,2) +Ahnen hatVorfahre(1,2) +Ahne hatVorfahre(1,2) + +Meister hatMeister(1,2) +Meisters hatMeister(1,2) + +Eltern hatElternteil(1,2) +Aeltern hatElternteil(1,2) + +Nachkommen hatNachfahre(1,2) + +Großvater hatGroßelternteil(1,2) +Großmutter hatGroßelternteil(1,2) + +Stiefschwester hatStiefgesschwisterteil(1,2) +Halbbruder hatStiefgesschwisterteil(1,2) +Ziehbruder hatStiefgesschwisterteil(1,2) + +Schüler hatSchüler(1,2) +Schülerin hatSchüler(1,2) diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/preciseConstructs/preciseConstructs.txt b/de.uniwue.mk.kall.ruleBasedRelationClassification/preciseConstructs/preciseConstructs.txt new file mode 100644 index 0000000..39a34d2 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/preciseConstructs/preciseConstructs.txt @@ -0,0 +1,96 @@ +Vater als dienender Sohn hatVater(2,1) +er liebte sie hatGeliebten(1,2) +Ich will dem Vater hatVater(1,2) +ihm saßen die Mutter hatMutter(1,2) +Witwe, die zwei Kinder hatKind(1,2) +deren Eltern hatElternteil(1,2) +Frau und Tochter hatTochter(1,2);hatMutter(2,1) +Mutter und Tochter hatTochter(1,2);hatMutter(2,1) +Mutter und Sohn hatSohn(1,2);hatMutter(2,1) +Vater und Tochter hatTochter(1,2);hatVater(2,1) +Säugling auf ihrem hatMutter(1,2) +Mutter und Sohn hatSohn(1,2);hatMutter(2,1) +Eltern eines solchen Sohnes hatSohn(1,2) +sein Weib sampt dem Sohn hatSohn(1,2);hatVater() +Kind den Großvater hatGroßvater(1,2) +Mentor seiner hatLehrer(2,1) +sie den Liebenden hatGeliebten(1,2) +sie den Liebenden und Geliebten hatGeliebten(1,2) +Mann und Frau hatEhemann(2,1);hatEhefrau(1,2) + + +Frau eines <SECOND> hatEhefrau(2,1) +Tochter eines <SECOND> hatTochter(2,1);hatVater(1,2) +Tochter des <SECOND> hatTochter(2,1) +Geliebte des <SECOND> hatGeliebten(1,2); +Schwester der <SECOND> hatSchwester(2,1) +Sohn des <SECOND> hatSohn(2,1);hatVater(1,2) +Sohn <SECOND> hatSohn(2,1) +einem Verwandten der <SECOND> hatVerwandten(2,1) +Königin der <SECOND> hatGebieter(2,1) +Freundin des Abtes hatFreund(2,1) +Tante <SECOND> hatTante(2,1) +Bruder <SECOND> hatBruder(2,1) +Kind von <SECOND> hatKind(2,1) +Sohn eines <SECOND> hatSohn(2,1) +Sohn der <SECOND> hatSohn(2,1) +Ehemann <SECOND> hatEhemann(2,1) +Adoptivtochter des <SECOND> hatPflegeelternteil(1,2) +ihm geliebten <SECOND> hatGeliebten(2,1) +Vater <SECOND> hatVater(2,1) +Komplizin <SECOND> hatArbeitskollegen(2,1) +Liebhaber <SECOND> hatGeliebten(2,1) +Feldherr <SECOND> hatGebieter(1,2) +Nichte des <SECOND> hatNichte(2,1) +Magd der <SECOND> hatGebieter(1,2) +Witwe eines <SECOND> hatEhemann(1,2) +Mutter von diesem <SECOND> hatMutter(2,1) +meine ehemalige Liebe zu <SECOND> hatGeliebten(1,2) +Frau des <SECOND> hatEhefrau(2,1) + + +<FIRST> Diener hatDiener(1,2) +<FIRST> Nichte hatNichte(1,2) +<FIRST> des Herzogs hatGebieter(1,2) +<FIRST> Frau hatEhefrau(1,2) +<FIRST> mit den Eltern hatElternteil(1,2) +<FIRST> Eheherrn hatEhemann(1,2) +<FIRST> Tochter hatTochter(1,2) +<FIRST> Eigentümerin hatGebieter(1,2) +<FIRST> Neffe hatNeffen(1,2) +<FIRST> Tochter hatTochter(1,2) +<FIRST> Großvater hatGroßvater(1,2) +<FIRST> einen Freund hatFreund(1,2) +<FIRST> mit einem Enkel hatEnkel(1,2) +<FIRST> Ehemann hatEhemann(1,2) +<FIRST> Verlobter hatVerlobten(1,2) +<FIRST> eine treue Ehefrau hatEhefrau(1,2) +<FIRST> als treuester Freund hatFreund(1,2) +<FIRST> ein einziger Sohn hatSohn(1,2) + + +<FIRST> ehelicht <SECOND> hatEhepartner(1,2) +<FIRST> Liebe zu <SECOND> hatGeliebten(1,2) + + +Freund des <GENITIV> hatFreund(1,2) +Bruder des <GENITIV> hatBruder(1,2) +Schwester <GENITIV> hatSchwester(2,1) +Bruder <GENITIV> hatBruder(2,1) +Verwandten der <GENITIV> hatVerwandten(2,1) +Söhne des <GENITIV> hatVater(1,2) +Schwester ihrer <GENITIV> hatSchwester(2,1) +Frau eines <GENITIV> hatEhefrau(2,1) +Frau <GENITIV> hatEhefrau(2,1) +Magd deines <GENITIV> hatGebieter(1,2) + + +<GENITIV> Mutter hatMutter(1,2) +<GENITIV> Sohn hatSohn(1,2) +<GENITIV> Vater hatVater(1,2) +<GENITIV> Großvater hatGroßelternteil(1,2) +<GENITIV> Vetter hatVerwandten(1,2) +<GENITIV> Köchin hatAngestellten(1,2) +<GENITIV> Lehrer hatLehrer(1,2) +<GENITIV> Herr hatGebieter(1,2) +<GENITIV> Bruder hatBruder(1,2) diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/relationGeneral/ruleset.txt b/de.uniwue.mk.kall.ruleBasedRelationClassification/relationGeneral/ruleset.txt new file mode 100644 index 0000000..fb0fda1 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/relationGeneral/ruleset.txt @@ -0,0 +1,484 @@ +<NE> angehörte <NE> hatUntergebenen(2,1) +Oberin hatte mit <NE> hatUntergebenen(1,2) +Regiment hatUntergebenen(1,2) +Volke hatUntergebenen(1,2) + +Tante hatTante(1,2) +ich bin , Tante hatTante(1,2) +Tante <GENITIV> hatTante(2,1) + +<BERUF> hatDienstleister(1,2) +Anwalts hatDienstleister(1,2) +Pflegerin hatDienstleister(1,2) +Anwalt hatDienstleister(1,2) +<GENITIV> <BERUF> hatDienstleister(1,2) +<NE> pflegt <NE> hatDienstleister(1,2) +Schreiber hatDienstleister(1,2) +Knechten hatDienstleister(1,2) + +<NE> Zwillinge und <NE> hatGeschwisterteil(1,2) +Sohn und eine Tochter hatGeschwisterteil(1,2) + +<NE> Adoption durch <NE> hatPflegeelternteil(1,2) + +<NE> eine Tochter hatTochter(1,2) +<NE> gebiert Tochter hatTochter(1,2) +Tochter eines <GENITIV> hatTochter(1,2) +beiden Töchtern hatTochter(1,2) +<ENDS-S> Tochter hatTochter(1,2) +Mutter ermahnte sie hatTochter(1,2) +Mutter und Tochter hatTochter(1,2) +<NE> geschenkt Tochter hatTochter(1,2) +<NE> die Tochter hatTochter(1,2) +Tochter <GENITIV> hatTochter(1,2) +dessen Tochter hatTochter(1,2) +Tochter hatTochter(1,2) +Tochter lässt <NE> hatTochter(1,2) +Töchter hatTochter(1,2) +<GENITIV> Tochter hatTochter(1,2) + +Knaben hatSohn(1,2) +Eltern solchen Sohnes hatSohn(1,2) +<NE> haben Sohn hatSohn(1,2) +Sohn <GENITIV> hatSohn(2,1) +Buben hatSohn(1,2) +Sohn eines <NE> hatSohn(2,1) +Sohne hatSohn(1,2) +Vater seines Freundes hatSohn(1,2) +<NE> gebiert Sohn hatSohn(1,2) +<NE> beim Sohn hatSohn(1,2) +Söhne des <NE> hatSohn(1,2) +Sohn des <NE> hatSohn(1,2) +Sohn hatSohn(1,2) +Vater weist ihn hatSohn(1,2) +dessen Sohn hatSohn(1,2) +Söhnen hatSohn(1,2) +<GENITIV> Knabe hatSohn(1,2) + +Magd der <NE> hatGebieter(1,2) +<NE> des <ADELSTITEL> hatGebieter(1,2) +Gebieterinn hatGebieter(1,2) +Fürsten hatGebieter(1,2) +<GENITIV> Herr hatGebieter(1,2) +Gebieterin hatGebieter(1,2) +<GENITIV> Eigentümerin hatGebieter(1,2) +König hatGebieter(1,2) +Herrn hatGebieter(1,2) +Volker hatGebieter(2,1) +Gebieters hatGebieter(1,2) +<ADELSTITEL> hatGebieter(1,2) +Sein Herr hatGebieter(1,2) +Magd des <NE> hatGebieter(1,2) +Feldherr <GENITIV> hatGebieter(1,2) +Schutzbefohlene hatGebieter(1,2) +sein Herr hatGebieter(1,2) +unsern Herrn hatGebieter(1,2) +Knecht bei <NE> hatGebieter(1,2) +Herrin hatGebieter(1,2) +<NE> an Oberinnen hatGebieter(1,2) +<NE> mit Oberin hatGebieter(1,2) +<NE> mit , Oberin hatGebieter(1,2) +Volk hatGebieter(1,2) + +Widersacher hatRivale(1,2) + +<NE> bittet den Bruder hatBruder(1,2) +Halbbruders hatBruder(1,2) +Bruder hatBruder(1,2) +<GENITIV> Bruder hatBruder(1,2) +Bruder des <NE> hatBruder(1,2) +Bruder <GENITIV> hatBruder(1,2) +Bruders hatBruder(1,2) + +Vorfahren hatVorfahre(1,2) + +<NE> ein Schwiegersohn hatSchwiegerkind(1,2) +Schwiegersohn haben den alten <NE> hatSchwiegerkind(1,2) + +Lehrherrn hatLehrer(1,2) +<ENDS-S> Mentor hatLehrer(1,2) + +Ziehbruder hatStiefgeschwisterteil(1,2) + +Verlobten hatVerlobten(1,2) +<ENDS-S> Verlobter hatVerlobten(1,2) +<GENITIV> Verlobter hatVerlobten(1,2) +Zukünftiger hatVerlobten(1,2) +<PRONOUN> Verlobter hatVerlobten(1,2) + +Onkels hatOnkel(1,2) +Nichte des <NE> hatOnkel(1,2) +Oheims hatOnkel(1,2) + +Großvater hatGrosselternteil(1,2) +<NE> den Großvater hatGrosselternteil(1,2) +<NE> bei Großmama hatGrosselternteil(1,2) + +<GENITIV> Nichte hatNichte(1,2) + +deren Ehe mit <NE> hatEhemann(1,2) +<NE> und Ehemann hatEhemann(1,2) +<NE> Heirat mit <NE> hatEhemann(1,2) +Mannes hatEhemann(1,2) +, Mann hatEhemann(1,2) +Bräutigam hatEhemann(1,2) +<NE> Ehe mit <NE> hatEhemann(1,2) +Gatten hatEhemann(1,2) +Witwe eines <NE> hatEhemann(1,2) +Mann hatEhemann(1,2) +Frau <GENITIV> hatEhemann(1,2) +deren Mann hatEhemann(1,2) +<NE> heiratet er hatEhemann(1,2) +Manne hatEhemann(1,2) +Frauen solcher Männer hatEhemann(1,2) + +Zukünftige hatVerlobte(1,2) + +<GENITIV> Neffe hatNeffen(1,2) +dessen Neffen hatNeffen(1,2) +Bruderskind hatNeffen(1,2) + +<GENITIV> Dorfsekretär hatAngestellten(1,2) +Mägde hatAngestellten(1,2) +<NE> schickte <APPELLATIV> hatAngestellten(1,2) +Ausgeberin hatAngestellten(1,2) +meine <BERUF> hatAngestellten(1,2) +Leuten hatAngestellten(1,2) +Arbeiter hatAngestellten(1,2) +<NE> auf die Haushälterin hatAngestellten(1,2) +Knappen hatAngestellten(1,2) +Magd hatAngestellten(1,2) +<GENITIV> Köchin hatAngestellten(1,2) +dessen Ratgeber hatAngestellten(1,2) +Gehilfe hatAngestellten(1,2) +<NE> gewinnen <BERUF> hatAngestellten(1,2) +<NE> Vermittlung Magd hatAngestellten(1,2) +Untergebenen hatAngestellten(1,2) +Angestellten hatAngestellten(1,2) +Herr und <BERUF> hatAngestellten(1,2) +<GENITIV> Sekretär hatAngestellten(1,2) + +Schülerin hatSchueler(1,2) +seinem Schützling hatSchueler(1,2) +Lehrers , den Schülern hatSchueler(1,2) +Schulmeister zu <NE> hatSchueler(1,2) +Schüler hatSchueler(1,2) + +Gemahlin hatEhefrau(1,2) +Mann und Frau hatEhefrau(1,2) +er heiratet <NE> hatEhefrau(1,2) +Braut hatEhefrau(1,2) +<NE> hat geheiratet <NE> hatEhefrau(1,2) +<GENITIV> Weib hatEhefrau(1,2) +Weib hatEhefrau(1,2) +Vater widerspricht , Mutter hatEhefrau(1,2) +<NE> von Geburt bis zur Heirat mit der <NE> hatEhefrau(1,2) +, Frau hatEhefrau(1,2) +<GENITIV> Frau hatEhefrau(1,2) +dessen Braut hatEhefrau(1,2) +<NE> , , als Gemahlin hatEhefrau(1,2) +<GENITIV> Braut hatEhefrau(1,2) +Gattin hatEhefrau(1,2) +Frau hatEhefrau(1,2) +Ehefrau hatEhefrau(1,2) +Männer seiner Töchter hatEhefrau(1,2) +<NE> Sehnsucht nach Frau hatEhefrau(1,2) + +<NE> diesen Feind hatFeind(1,2) +<NE> wollten Feind hatFeind(1,2) +<NE> hofft besiegen <NE> hatFeind(1,2) +<NE> hassten <NE> hatFeind(1,2) +<NE> haben Feinde hatFeind(1,2) +Feind hatFeind(1,2) +Erbfeind der <NE> hatFeind(2,1) +Nebenbuhler hatFeind(1,2) +<NE> schafft Feind hatFeind(1,2) +Gegenspieler hatFeind(1,2) +<NE> stellt sich <NE> hatFeind(1,2) +<NE> angreift <NE> hatFeind(1,2) +<ENDS-S> Antipodin hatFeind(1,2) + +<NE> sich mit Kind hatKind(1,2) +Kinde hatKind(1,2) +Kind der <NE> hatKind(2,1) +<NE> hat Kind hatKind(1,2) +<NE> konnte nähren Kind hatKind(1,2) +Ich hab ein Kind hatKind(1,2) +seiner Frau und Kindern hatKind(1,2) +<NE> wünschte Kind hatKind(1,2) +Kindern des <NE> hatKind(2,1) +Kinder hatKind(1,2) +Kindes hatKind(1,2) +Kindern hatKind(1,2) +Kind hatKind(1,2) +<NE> und Kindern hatKind(1,2) +<NE> ein Kind hatKind(1,2) +Kind von <NE> hatKind(1,2) +<NE> mit Kindern hatKind(1,2) +<NE> Sorge um Kind hatKind(1,2) +<NE> hatte geboren Kind hatKind(1,2) +Kind einer <NE> hatKind(2,1) +<NE> werde geboren Kind hatKind(1,2) +<NE> Sehnsucht nach und Kindern hatKind(1,2) +<NE> , Kinder hatKind(1,2) +Kind eines <NE> hatKind(2,1) +, , Kind hatKind(1,2) + +Tochter der , <NE> hatTochter(2,1) + +Nachkommen hatNachfahre(1,2) + +Pflegemutter hatPflegemutter(1,2) + +<NE> mit Eltern hatElternteil(1,2) +Eltern hatElternteil(1,2) +<GENITIV> Eltern hatElternteil(1,2) +Eltern , und <NE> hatElternteil(1,2) +Eltern , <NE> hatElternteil(1,2) + +<NE> entstammt Familie hatFamilienRelation(1,2) +<GENITIV> Familie hatFamilienRelation(1,2) +<NE> erlebt Verfall in der Familie hatFamilienRelation(1,2) +Familie eines <NE> hatFamilienRelation(2,1) +Familie des <NE> hatFamilienRelation(1,2) +<NE> redet in Familie hatFamilienRelation(1,2) +Familie hatFamilienRelation(1,2) + +Diener hatDiener(1,2) +Pflegerin hatDiener(1,2) +Knecht hatDiener(1,2) +<NE> sich und Dienerin hatDiener(1,2) +<NE> eine Dirn hatDiener(1,2) +Diener eines <NE> hatDiener(2,1) +<NE> mit Gehilfen hatDiener(1,2) +beide , mit Diener hatDiener(1,2) +Herr und Diener hatDiener(1,2) + +Schwester <GENITIV> hatSchwester(1,2) +Schwester seines <NE> hatSchwester(2,1) +<NE> Töchter und <NE> hatSchwester(1,2) +<NE> Schwestern und <NE> hatSchwester(1,2) +dessen Schwestern hatSchwester(1,2) +Schwester hatSchwester(1,2) +<GENITIV> Schwester hatSchwester(1,2) + +Meister hatMeister(1,2) + +<NE> den Adoptivsohn hatPflegekind(1,2) +Pflegetochter hatPflegekind(1,2) + +Vaters hatVater(1,2) +Sohn des <NE> hatVater(1,2) +Vater des <NE> hatVater(1,2) +er gegen den Vater hatVater(1,2) +<NE> begleitet und Vater hatVater(1,2) +Sohn dem Alten hatVater(1,2) +<GENITIV> Vater hatVater(1,2) +Vater hatVater(1,2) +Vater seines <NE> hatVater(2,1) +<NE> kehrt verrichten beim Vater hatVater(1,2) +<NE> will Vater hatVater(1,2) + +Kameraden hatArbeitskollegen(1,2) +Komplizin <ENDS-S> hatArbeitskollegen(1,2) +Kollegen hatArbeitskollegen(1,2) +Mitarbeiterinnen hatArbeitskollegen(1,2) + +<NE> waren war <FAMILY_RELATION> hatFamilienRelation(1,2) +<FAMILY_RELATION> von diesem <NE> hatFamilienRelation(2,1) +<NE> , wird von <FAMILY_RELATION> hatFamilienRelation(1,2) +<FAMILY_RELATION> hatFamilienRelation(1,2) +<FAMILY_RELATION> , « sagte <NE> hatFamilienRelation(2,1) +<FAMILY_RELATION> von <NE> hatFamilienRelation(2,1) +<NE> konnte <FAMILY_RELATION> hatFamilienRelation(1,2) +er fiel <FAMILY_RELATION> hatFamilienRelation(1,2) +<NE> könnte <FAMILY_RELATION> hatFamilienRelation(1,2) +<FAMILY_RELATION> jenes <NE> hatFamilienRelation(2,1) +<FAMILY_RELATION> und <FAMILY_RELATION> hatFamilienRelation(1,2) +<FAMILY_RELATION> des <NE> hatFamilienRelation(1,2) +<NE> an <FAMILY_RELATION> hatFamilienRelation(1,2) +<NE> suchte wegen <FAMILY_RELATION> hatFamilienRelation(1,2) +seine Sehnsucht und <FAMILY_RELATION> hatFamilienRelation(1,2) +<NE> eine treue <FAMILY_RELATION> hatFamilienRelation(1,2) +<NE> dem <FAMILY_RELATION> hatFamilienRelation(1,2) +<ENDS-S> <FAMILY_RELATION> hatFamilienRelation(1,2) +<FAMILY_RELATION> der <NE> hatFamilienRelation(1,2) +<NE> gegen <FAMILY_RELATION> hatFamilienRelation(1,2) +<NE> , wenn <FAMILY_RELATION> hatFamilienRelation(1,2) +<NE> zu <FAMILY_RELATION> hatFamilienRelation(1,2) +<FAMILY_RELATION> <GENITIV> hatFamilienRelation(1,2) +<NE> der <FAMILY_RELATION> hatFamilienRelation(1,2) +<NE> beide <FAMILY_RELATION> hatFamilienRelation(1,2) +<GENITIV> <FAMILY_RELATION> hatFamilienRelation(1,2) +<FAMILY_RELATION> dieser <NE> hatFamilienRelation(2,1) +<FAMILY_RELATION> eines <GENITIV> hatFamilienRelation(1,2) + +<GENITIV> Mutter hatMutter(1,2) +Sohn eines und Mutter hatMutter(1,2) +Mutter <ENDS-S> hatMutter(2,1) +Sohn war ihrer hatMutter(1,2) +<NE> waren Mutter hatMutter(1,2) +<NE> die Mutter hatMutter(1,2) +<NE> ist Mutter hatMutter(1,2) +<NE> Kindheit endet Mutter hatMutter(1,2) +Mutter hatMutter(1,2) +<NE> saßen Mutter hatMutter(1,2) +<NE> , wird von Mutter hatMutter(1,2) + +Ziehvaters hatPflegeelternteil(1,2) + +Führer hatVorgesetzten(1,2) +<BERUF> des Herrn hatVorgesetzten(1,2) +Vorgesetzten hatVorgesetzten(1,2) +Vorsteher hatVorgesetzten(1,2) +Hauptmann hatVorgesetzten(1,2) +Magd deines <NE> hatVorgesetzten(1,2) +Herrin hatVorgesetzten(1,2) +<NE> tritt in Dienste <NE> hatVorgesetzten(1,2) +Brotherrn hatVorgesetzten(1,2) +<NE> läuft und tritt in Dienst <NE> hatVorgesetzten(1,2) +<NE> in Dienst des <NE> hatVorgesetzten(1,2) +<BERUF> von <NE> hatVorgesetzten(1,2) +Novizen hatVorgesetzten(1,2) +<NE> und Advokaten hatVorgesetzten(1,2) +Oberin hatVorgesetzten(1,2) +Magd des <NE> hatVorgesetzten(1,2) +<NE> der Kaiser hatVorgesetzten(1,2) +<NE> hatte vorgestellt <ADELSTITEL> hatVorgesetzten(1,2) + +Mutter und Tante hatVerwandten(1,2) +Base hatVerwandten(1,2) +Verwandten meines <NE> hatVerwandten(1,2) +<NE> einen Vetter hatVerwandten(1,2) +Angehörigen hatVerwandten(1,2) +deren Vetter hatVerwandten(1,2) +<PRONOUN> Vetter hatVerwandten(1,2) +<GENITIV> Vetter hatVerwandten(1,2) +Verwandten hatVerwandten(1,2) +Verwandte <GENITIV> hatVerwandten(1,2) +Großtante hatVerwandten(1,2) + +Altersgenossen hatSozialeRelation(1,2) +<NE> dem <ADELSTITEL> hatSozialeRelation(1,2) +Gästen hatSozialeRelation(1,2) +Gefährtinnen hatSozialeRelation(1,2) +Beichtvaters hatSozialeRelation(1,2) +Zimmernachbarin hatSozialeRelation(1,2) +Peiniger hatSozialeRelation(1,2) +Gast hatSozialeRelation(1,2) +Gläubigen hatSozialeRelation(1,2) +<GENITIV> Nachfolger hatSozialeRelation(1,2) +<GENITIV> Befreier hatSozialeRelation(1,2) +Mitmenschen hatSozialeRelation(1,2) +<NE> Gunst der <NE> hatSozialeRelation(1,2) +Pate hatSozialeRelation(1,2) +Mätressen hatSozialeRelation(1,2) +Schulkameraden hatSozialeRelation(1,2) +Nachfolger <ENDS-S> hatSozialeRelation(1,2) +Schwäher hatSozialeRelation(1,2) +Gefährtin hatSozialeRelation(1,2) +Gäset hatSozialeRelation(1,2) +Nachfolgerin <GENITIV> hatSozialeRelation(1,2) +Schwägerin hatSozialeRelation(1,2) + +Vertraute <GENITIV> hatFreund(2,1) +Freund des <NE> hatFreund(1,2) +<NE> befreundeten <NE> hatFreund(1,2) +<NE> schließt Freundschaft mit <NE> hatFreund(1,2) +Freunden hatFreund(1,2) +Freundes hatFreund(1,2) +<GENITIV> Jugendfreund hatFreund(1,2) +Unterweltsgenossen hatFreund(1,2) +Jugendfreund hatFreund(1,2) +<NE> als Freund hatFreund(1,2) +<NE> schloß Freundin hatFreund(1,2) +Kameraden hatFreund(1,2) +<NE> geliebter Freund hatFreund(1,2) +Schulfreundin hatFreund(1,2) +<NE> , begleitet von Freund hatFreund(1,2) +Vertraute des , <NE> hatFreund(1,2) +Freund hatFreund(1,2) +<NE> vereint und <NE> hatFreund(1,2) +<NE> Verlust des Freundes hatFreund(1,2) +Kameraden <ENDS-S> hatFreund(1,2) +Lieber hatFreund(1,2) +<GENITIV> Schulfreund hatFreund(1,2) +Wohltäter hatFreund(1,2) +<NE> in Begleitung eines Freundes hatFreund(1,2) +<NE> leben verbunden mit <NE> hatFreund(1,2) +Freundin des <NE> hatFreund(1,2) +<GENITIV> Freund hatFreund(1,2) +Freundin hatFreund(1,2) +Freunden <GENITIV> hatFreund(1,2) +<NE> aufnimmt in Freundeskreis <NE> hatFreund(1,2) +konvertierten Freunden hatFreund(1,2) +<NE> folgten einige Freunde hatFreund(1,2) +Freunde hatFreund(1,2) +<NE> anfreundet mit <NE> hatFreund(1,2) +unsern Befreundten hatFreund(1,2) +<NE> einen Freund hatFreund(1,2) +Jugendfreund <ENDS-S> hatFreund(2,1) +<NE> einen Kameraden hatFreund(1,2) + +<NE> heiratet <NE> hatEhepartner(1,2) +<NE> Hochzeit mit <NE> hatEhepartner(1,2) +mir gebar <NE> hatEhepartner(1,2) +<NE> kann heiraten <NE> hatEhepartner(1,2) +<NE> bis zur Heirat mit <NE> hatEhepartner(1,2) +<NE> geht und heiratet <NE> hatEhepartner(1,2) +<NE> hat und heiratet <NE> hatEhepartner(1,2) +<NE> vermählt mit <NE> hatEhepartner(1,2) +<NE> heiratete <NE> hatEhepartner(1,2) +<NE> Jawort und <NE> hatEhepartner(1,2) +<NE> geheiratet hat <NE> hatEhepartner(1,2) +<NE> Weg führt in Ehe mit <NE> hatEhepartner(1,2) +<NE> hätten gibt und heiratet <NE> hatEhepartner(1,2) + +<NE> erwählt <NE> hatGeliebten(1,2) +<NE> liebt <NE> hatGeliebten(1,2) +Jugendliebe hatGeliebten(1,2) +Liebhaber hatGeliebten(1,2) +<NE> der Liebsten hatGeliebten(1,2) +Geliebte des <NE> hatGeliebten(1,2) +Freier hatGeliebten(1,2) +<NE> verliebt in <NE> hatGeliebten(1,2) +<NE> liebe <NE> hatGeliebten(1,2) +<NE> Liebschaft mit <NE> hatGeliebten(1,2) +Geliebte <NE> hatGeliebten(1,2) +Anbeter hatGeliebten(1,2) +<NE> gelingt anbetete <NE> hatGeliebten(1,2) +<NE> Liebe <NE> hatGeliebten(1,2) +Geliebte hatGeliebten(1,2) +<NE> nicht Liebschaft mit <NE> hatGeliebten(1,2) +<NE> Zuneigung zu <NE> hatGeliebten(1,2) +Liebling der <NE> hatGeliebten(1,2) +Liebe hatGeliebten(1,2) +<NE> Liebe als <NE> hatGeliebten(1,2) +<NE> Geliebte hatGeliebten(1,2) +<NE> verlebt in Liebe zu <NE> hatGeliebten(1,2) +Liebhaber <NE> hatGeliebten(1,2) +<NE> Liebe zu <NE> hatGeliebten(1,2) +<NE> in Leidenschaft zu <NE> hatGeliebten(1,2) +<NE> Beziehung zu <NE> hatGeliebten(1,2) +<NE> war verliebt in <NE> hatGeliebten(1,2) +<NE> und Geliebten hatGeliebten(1,2) +<NE> leidet unter Liebe zur <NE> hatGeliebten(1,2) +<NE> liebte <NE> hatGeliebten(1,2) +<NE> den Liebenden hatGeliebten(1,2) +<NE> lässt von Liebe zu <NE> hatGeliebten(1,2) +Liebhaber <GENITIV> hatGeliebten(1,2) +<NE> aus Liebe zur <NE> hatGeliebten(1,2) +seine Neigung zu <NE> hatGeliebten(1,2) +<NE> in verliebt <NE> hatGeliebten(1,2) +Angebetete hatGeliebten(1,2) +Geliebte <GENITIV> hatGeliebten(1,2) +geliebte <NE> hatGeliebten(1,2) +Vertrauten des <NE> hatGeliebten(1,2) +<NE> Zuneigung wird erwidert von <NE> hatGeliebten(1,2) +Geliebten <ENDS-S> hatGeliebten(1,2) +<NE> liebt und <NE> hatGeliebten(1,2) +<NE> verliebte in <NE> hatGeliebten(1,2) +<NE> bandelt mit <NE> hatGeliebten(1,2) +<NE> Liaison zu <NE> hatGeliebten(1,2) +<NE> geliebten <NE> hatGeliebten(1,2) +Geliebten hatGeliebten(1,2) diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/relationGeneral1/ruleset.txt b/de.uniwue.mk.kall.ruleBasedRelationClassification/relationGeneral1/ruleset.txt new file mode 100644 index 0000000..6230591 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/relationGeneral1/ruleset.txt @@ -0,0 +1,507 @@ +Tochter <GENITIV> hatVater(1,2) +seiner <FAMILY_RELATION> hatRelation2(1,2) +Verfolger hatFeind(1,2) +dessen Ratgeber hatAngestellten(1,2) +<GENITIV> Neffe hatNeffen(1,2) +Sohn hatSohn(1,2) +Vaters hatVater(1,2) +Vater hatVater(1,2) +<NE> verliebt sich in <NE> hatGeliebten(1,2) +Sohn des <GENITIV> hatVater(1,2) +Sohn von <NE> hatVater(1,2) +Kollegen hatArbeitskollegen(1,2) +Bruders hatBruder(1,2) +Mutter hatMutter(1,2) +Schwester hatSchwester(1,2) +Arbeiter hatAngestellten(1,2) +<GENITIV> Eigentümerin hatGebieter(1,2) +<GENITIV> Bewunderer hatVerehrer(1,2) +Schwester der <NE> hatSchwester(2,1) +<NE> einen Freund hatFreund(1,2) +Miester hatMeister(1,2) +Schulkameraden hatSozialeRelation(1,2) +deren Sohn hatSohn(1,2) +Geliebten von <NE> hatGeliebten(1,2) +Tante mehrerer <NE> hatTante(2,1) +Vertrauten <GENITIV> hatFreund(1,2) +Geliebten hatGeliebten(1,2) +Liebhaber hatGeliebten(1,2) +Bräutigam hatEhemann(1,2) +<GENITIV> Tochter hatTochter(1,2) +<GENITIV> Jugendfreund hatFreund(1,2) +Frau hatEhefrau(1,2) +sie den Liebenden hatGeliebten(1,2) +sie den Liebenden und Geliebten hatGeliebten(1,2) +Familie hatFamilienteil(1,2) +<NE> Ehemann hatEhemann(1,2) +Sohn <GENITIV> hatMutter(1,2) +<GENITIV> Befreier hatSozialeRelation(1,2) +<GENITIV> Freund hatFreund(1,2) +Geliebte <GENITIV> hatGeliebte(2,1) +Beraters hatArbeitskollegen(1,2) +dessen Kanzler hatArbeitskollegen(1,2) +Mannes hatEhemann(1,2) +ihm eine Tochter hatTochter(1,2) +Tochter <GENITIV> hatTochter(1,2) +Freund hatFreund(1,2) +Erbfeind der <NE> hatFeind(1,2) +<NE> wollten den Feind hatFeind(1,2) +<BERUF> hatAngestellten(1,2) +deren Tochter hatTochter(1,2) +Waldleute hatSozialeRelation(1,2) +Anführers hatVorgesetzten(1,2) +Mann hatEhemann(1,2) +Mutter <GENITIV> hatTochter(1,2) +Schwester <GENITIV> hatSchwester(1,2) +beiden Töchtern hatTochter(1,2) +Pflegetochter hatPflegekind(1,2) +Kindes hatKind(1,2) +Kind hatKind(1,2) +<NE> , begleitet von dem Freund hatFreund(1,2) +<GENITIV> Sohn hatSohn(1,2) +ihr Vetter hatVerwandten(1,2) +Jugendfreundes hatFreund(1,2) +sich gegen die Mutter hatMutter(1,2) +Familie eines <NE> hatFamilienteil(2,1) +<NE> entstammt Familie hatFamilienteil(1,2) +Schwiegertochter hatSchwiegerkind(1,2) +Schwester ihrer <NE> hatSchwester(1,2) +Sohnes hatSohn(1,2) +<GENITIV> Vater hatVater(1,2) +Kind der <NE> hatKind(2,1) +<GENITIV> Frau hatEhefrau(1,2) +Vater dem Sohn hatSohn(1,2) +Eltern die Todkranke hatTochter(1,2) +Kind ist der Mutter hatMutter(1,2) +<GENITIV> Eltern hatElternteil(1,2) +<NE> in Begleitung eines Freundes hatFreund(1,2) +Tante hatTante(1,2) +Onkel hatOnkel(1,2) +Oheims hatOnkel(1,2) +Magd hatAngestellten(1,2) +<NE> den Adoptivsohn hatPflegekind(1,2) +Tochter eines <NE> hatVater(1,2) +<GENITIV> Familie hatFamilienteil(1,2) +Tante <GENITIV> hatTante(2,1) +deren Ehe mit <NE> hatEhemann(1,2) +Herrin hatGebieter(1,2) +Magd der <NE> hatGebieter(1,2) +Komplizin <NE> hatArbeitskollegen(1,2) +Liebhaber <GENITIV> hatGeliebten(1,2) +<NE> Neigung zu <NE> hatGeliebten(1,2) +<NE> der geliebten Frau hatGeliebten(1,2) +Ehemann <NE> hatEhefrau(1,2) +Adoptivtochter des <NE> hatPflegeelternteil(1,2) +<NE> mit Enkel hatEnkel(1,2) +ihm geliebten <NE> hatGeliebten(1,2) +Witwe eines <NE> hatEhemann(1,2) +sie den Liebenden hatGeliebten(1,2) +Geliebte <GENITIV> hatGeliebten(1,2) +<ADELSTITEL> hatGebieter(1,2) +Herrn hatGebieter(1,2) +<GENITIV> Diener hatDiener(1,2) +Brduer des <NE> hatBruder(1,2) +<NE> Antipodin hatFeind(1,2) +<NE> bittet Bruder hatBruder(1,2) +Gefährte <GENITIV> hatSozialeRelation(1,2) +Bruder hatBruder(1,2) +sein Volk hatGebieter(2,1) +Erstgeborenen hatSohn(1,2) +<NE> bei Vetter hatVerwandten(1,2) +Gemahlin hatEhefrau(1,2) +Gemahl hatEhemann(1,2) +Vater hatVater(1,2) +Papa hatVater(1,2) +Vaters hatVater(1,2) +Vader hatVater(1,2) +Vadern hatVater(1,2) + + + +Mama hatMutter(1,2) +Mutti hatMutter(1,2) +Mutter hatMutter(1,2) + +Frau hatEhefrau(1,2) +Gemahlin hatEhefrau(1,2) +Gattin hatEhefrau(1,2) +Weib hatEhefrau(1,2) +Weibes hatEhefrau(1,2) +Ehefrau hatEhefrau(1,2) + +Mann hatEhemann(1,2) +Männer hatEhemann(1,2) +Manne hatEhemann(1,2) +Mannes hatEhemann(1,2) +Gemahl hatEhemann(1,2) +Gemahls hatEhemann(1,2) +Herr Gemahl hatEhemann(1,2) +Herrn Gemahls hatEhemann(1,2) +Herrn Gemahl hatEhemann(1,2) +Gatte hatEhemann(1,2) +Gatten hatEhemann(1,2) +Neuvermählten hatEhemann(1,2) +Eheherrn hatEhemann(1,2) +eeman hatEhemann(1,2) +Manen hatEhemann(1,2) + +Chef hatVorgesetzten(1,2) +Chefs hatVorgesetzten(1,2) +Vorgesetzten hatVorgesetzten(1,2) +Hauptmann hatVorgesetzten(1,2) + +Freund hatFreund(1,2) +Wohtäter hatFreund(1,2) +Freundin hatFreund(1,2) +Freundes hatFreund(1,2) +Freunde hatFreund(1,2) +Schulfreund hatFreund(1,2) +Schulfreundin hatFreund(1,2) + +Vetter hatVerwandten(1,2) +Vettern hatVerwandten(1,2) +Schwiegermutter hatVerwandten(1,2) +Schwager hatVerwandten(1,2) +Schwäher hatVerwandten(1,2) +Schwieger hatVerwandten(1,2) +Schwägerin gatVerwandten(1,2) +Verwandten hatVerwandten(1,2) + +Tante hatTante(1,2) +Base hatTante(1,2) + +Onkel hatOnkel(1,2) +Oheim hatOnkel(1,2) +Oheims hatOnkel(1,2) + +Frau Tochter hatTochter(1,2) +Tochter hatTochter(1,2) +Toch-ter hatTochter(1,2) +Töchter hatTochter(1,2) +Töchtern hatTochter(1,2) +Mädchen hatTochter(1,2) +Mädle hatTochter(1,2) + +Sohn hatSohn(1,2) +Söhnen hatSohn(1,2) +Sohne hatSohn(1,2) +Sohnes hatSohn(1,2) +Bube hatSohn(1,2) +Buben hatSohn(1,2) +Bub hatSohn(1,2) +Bubn hatSohn(1,2) +Erstgeborenen hatSohn(1,2) + +Kind hatKind(1,2) +Kinde hatKind(1,2) +Kindes hatKind(1,2) +Kinder hatKind(1,2) +Kindern hatKind(1,2) + +Bruder hatBruder(1,2) +Bruders hatBruder(1,2) +Brůder hatBruder(1,2) +brůder hatBruder(1,2) +Herzbruder hatBruder(1,2) +Brüdern hatBruder(1,2) + +Schwester hatSchwester(1,2) + +Neffe hatNeffe(1,2) +Neffen hatNeffe(1,2) + +Nichte hatNichte(1,2) + +Lehrer hatLehrer(1,2) +Lehrern hatLehrer(1,2) +Lehrers hatLehrer(1,2) +Lehrmeister hatLehrer(1,2) +Lehrerin hatLehrer(1,2) +Lehrmeisterin hatLehrer(1,2) + +Banquier hatDienstleister(1,2) +Anwalt hatDienstleister(1,2) +Doktor hatDienstleister(1,2) +Untergebenen hatDienstleister(1,2) +Briefträger hatDienstleister(1,2) +Wirtin hatDienstleister(1,2) +Arztes hatDienstleister(1,2) +Pflegerin hatDienstleister(1,2) + + +Geliebte hatGeliebte(1,2) +Geliebter hatGeliebte(1,2) +Geliebten hatGeliebten(1,2) +Liebhaber hatGeliebten(1,2) +Angebetete hatGeliebten(1,2) +Angebeteter hatGeliebten(1,2) +Jugendliebe hatGeliebten(1,2) + +Nebenbuhler hatRivale(1,2) +Nebnbuhlerin hatRivale(1,2) +Gegenspieler hatRivale(1,2) +Widersacher hatRivale(1,2) + +Braut hatVerlobten(1,2) +Bräutigam hatVerlobten(1,2) +Verlobter hatVerlobten(1,2) +Verlobten hatVerlobten(1,2) +Verlobte hatVerlobten(1,2) + +Feind hatFeind(1,2) +Feindes hatFeind(1,2) +Verfolger hatFeind(1,2) + +Gast hatSozialeRelation(1,2) +Begleiterin hatSozialeRelation(1,2) +Begleiter hatSozialeRelation(1,2) +Gaste hatSozialeRelation(1,2) +Nebenmenschen hatSozialeRelation(1,2) +Schulkameraden hatSozialeRelation(1,2) +Waldleute hatSozialeRelation(1,2) +Entführer hatSozialeRelation(1,2) +Mitmenschen hatSozialeRelation(1,2) +Nachbar hatSozialeRelation(1,2) +Nachbarin hatSozialeRelation(1,2) +Nachbarinnen hatSozialeRelation(1,2) +Nachbaren hatSozialeRelation(1,2) +Nachbarn hatSozialeRelation(1,2) +Gäste hatSozialeRelation(1,2) +Jäger hatSozialeRelation(1,2) +Gastfreund hatSozialeRelation(1,2) +Gastfreundes hatSozialeRelation(1,2) +Beichtvater hatSozialeRelation(1,2) +Bekannter hatSozialeRelation(1,2) +Bekannte hatSozialeRelation(1,2) +Bekannten hatSozialeRelation(1,2) +Altersgenossen hatSozialeRelation(1,2) +Nachfolger hatSozialeRelation(1,2) + +dienerin hatDiener(1,2) +Diener hatDiener(1,2) +Dieners hatDiener(1,2) +Dienerin hatDiener(1,2) +Gehilfen hatDiener(1,2) + +Amme hatAngestellten(1,2) +Arbeiter hatAngestellten(1,2) +Magd hatAngestellten(1,2) +Mägde hatAngestellten(1,2) +Angestellten hatAngestellten(1,2) +Muhme hatAngestellten(1,2) + +Jugendfreund hatFreund(1,2) +Jugendfreundes hatFreund(1,2) +Jugendgenossen hatFreund(1,2) +Jugendgenossens hatFreund(1,2) + +Familie hatFamilienteil(1,2) + +Volk hatGebieter(2,1) +König hatGebieter(1,2) +Herrn hatGebieter(1,2) +Herrin hatGebieter(1,2) +Volke hatGebieter(2,1) +Lehnsherrn hatGebieter(1,2) +Gebieterin hatGebieter(1,2) +Gebieter hatGebieter(1,2) +Reitknecht hatGebieter(2,1) +Tyrannen hatgebieter(1,2) +Tyrann hatGebieter(1,2) + +Ziehvater hatPflegeelternteil(1,2) +Ziehvaters hatPflegeelternteil(1,2) +Pflegetochter hatPflegeelternteil(2,1) + +Kollegen hatArbeitskollegen(1,2) +Mitarbeiter hatArbeitskollegen(1,2) +Mitarbeiterinnen hatArbeitskollegen(1,2) +Stellvertreterin hatArbeitskollegen(1,2) +Berater hatArbeitskollegen(1,2) +Beraters hatArbeitskollegen(1,2) + +Vorfahren hatVorfahre(1,2) +Vorfahre hatVorfahre(1,2) +Ahn hatVorfahre(1,2) +Ahnen hatVorfahre(1,2) +Ahne hatVorfahre(1,2) + +Meister hatMeister(1,2) +Meisters hatMeister(1,2) + +Eltern hatElternteil(1,2) +Aeltern hatElternteil(1,2) + +Nachkommen hatNachfahre(1,2) + +Großvater hatGroßelternteil(1,2) +Großmutter hatGroßelternteil(1,2) + +Stiefschwester hatStiefgesschwisterteil(1,2) +Halbbruder hatStiefgesschwisterteil(1,2) +Ziehbruder hatStiefgesschwisterteil(1,2) + +Schüler hatSchüler(1,2) +Schülerin hatSchüler(1,2) +Er verliebt sich in <NE> hatGeliebten(1,2) +Sohn von <NE> hatSohn(1,2) +Vater als dienender Sohn hatVater(2,1) +er liebte sie hatGeliebten(1,2) +Ich will dem Vater hatVater(1,2) +ihm saßen die Mutter hatMutter(1,2) +Witwe, die zwei Kinder hatKind(1,2) +deren Eltern hatElternteil(1,2) +Frau und Tochter hatTochter(1,2);hatMutter(2,1) +Mutter und Tochter hatTochter(1,2);hatMutter(2,1) +Mutter und Sohn hatSohn(1,2);hatMutter(2,1) +Vater und Tochter hatTochter(1,2);hatVater(2,1) +Säugling auf ihrem hatMutter(1,2) +Mutter und Sohn hatSohn(1,2);hatMutter(2,1) +Eltern eines solchen Sohnes hatSohn(1,2) +sein Weib sampt dem Sohn hatSohn(1,2);hatVater() +Kind den Großvater hatGroßvater(1,2) +Mentor seiner hatLehrer(2,1) +sie den Liebenden hatGeliebten(1,2) +sie den Liebenden und Geliebten hatGeliebten(1,2) +Mann und Frau hatEhemann(2,1);hatEhefrau(1,2) + + +Frau eines <NE> hatEhefrau(2,1) +Tochter eines <NE> hatTochter(2,1);hatVater(1,2) +Tochter des <NE> hatTochter(2,1) +Geliebte des <NE> hatGeliebten(1,2); +Schwester der <NE> hatSchwester(2,1) +Sohn des <NE> hatSohn(2,1);hatVater(1,2) +Sohn <NE> hatSohn(2,1) +einem Verwandten der <NE> hatVerwandten(2,1) +Königin der <NE> hatGebieter(2,1) +Freundin des Abtes hatFreund(2,1) +Tante <NE> hatTante(2,1) +Bruder <NE> hatBruder(2,1) +Kind von <NE> hatKind(2,1) +Sohn eines <NE> hatSohn(2,1) +Sohn der <NE> hatSohn(2,1) +Ehemann <NE> hatEhemann(2,1) +Adoptivtochter des <NE> hatPflegeelternteil(1,2) +ihm geliebten <NE> hatGeliebten(2,1) +Vater <NE> hatVater(2,1) +Komplizin <NE> hatArbeitskollegen(2,1) +Liebhaber <NE> hatGeliebten(2,1) +Feldherr <NE> hatGebieter(1,2) +Nichte des <NE> hatNichte(2,1) +Magd der <NE> hatGebieter(1,2) +Witwe eines <NE> hatEhemann(1,2) +Mutter von diesem <NE> hatMutter(2,1) +meine ehemalige Liebe zu <NE> hatGeliebten(1,2) +Frau des <NE> hatEhefrau(2,1) + + +<NE> Diener hatDiener(1,2) +<NE> Nichte hatNichte(1,2) +<NE> des Herzogs hatGebieter(1,2) +<NE> mit den Eltern hatElternteil(1,2) +<NE> Eheherrn hatEhemann(1,2) +<NE> Tochter hatTochter(1,2) +<NE> Eigentümerin hatGebieter(1,2) +<NE> Neffe hatNeffen(1,2) +<NE> Tochter hatTochter(1,2) +<NE> Großvater hatGroßvater(1,2) +<NE> einen Freund hatFreund(1,2) +<NE> mit einem Enkel hatEnkel(1,2) +<NE> Ehemann hatEhemann(1,2) +<NE> Verlobter hatVerlobten(1,2) +<NE> eine treue Ehefrau hatEhefrau(1,2) +<NE> als treuester Freund hatFreund(1,2) +<NE> ein einziger Sohn hatSohn(1,2) + + +<NE> ehelicht <NE> hatEhepartner(1,2) +<NE> Liebe zu <NE> hatGeliebten(1,2) + + +Freund des <GENITIV> hatFreund(1,2) +Bruder des <GENITIV> hatBruder(1,2) +Schwester <GENITIV> hatSchwester(2,1) +Bruder <GENITIV> hatBruder(2,1) +Verwandten der <GENITIV> hatVerwandten(2,1) +Söhne des <GENITIV> hatVater(1,2) +Schwester ihrer <GENITIV> hatSchwester(2,1) +Frau eines <GENITIV> hatEhefrau(2,1) +Frau <GENITIV> hatEhefrau(2,1) +Magd deines <GENITIV> hatGebieter(1,2) + + +<GENITIV> Mutter hatMutter(1,2) +<GENITIV> Sohn hatSohn(1,2) +<GENITIV> Vater hatVater(1,2) +<GENITIV> Großvater hatGroßelternteil(1,2) +<GENITIV> Vetter hatVerwandten(1,2) +<GENITIV> Köchin hatAngestellten(1,2) +<GENITIV> Lehrer hatLehrer(1,2) +<GENITIV> Herr hatGebieter(1,2) +<GENITIV> Bruder hatBruder(1,2) +<GENITIV> Nachfolger hatSozialeRelation(1,2) +Er verliebt sich in <NE> hatGeliebten(1,2) +ihre Schwester hatSchwester(1,2) +Bewunderer <GENITIV> hatVerehrer(2,1) +seine Jugendgeliebte hatGeliebten(1,2) +Jugendgeliebte hatGeliebten(1,2) +<NE> in den Dienst des <NE> hatVorgesetzten(1,2) +dessen Neffen hatNeffen(1,2) +<GENITIV> Jugendfreundin hatFreund(1,2) +deren Erzieherin hatLehrer(1,2) +Schutzbefohlene hatGebieter(1,2) +<NE> schließt Freundschaft mit <NE> hatFreund(1,2) +<NE> in Leidenschaft zu <NE> hatGeliebten(1,2) +seine anderen Komplicen hatArbeitskollegen(1,2) +Mitschüler hatSozialeRelation(1,2) +Kanzler hatAngestellten(1,2) +<PRONOUN> Schwester hatSchwester(1,2) +Stiefonkels hatOnkel(1,2) +<PRONOUN> Familie hatFamilienteil(1,2) +Familie des <NE> hatFamilienteil(2,1) +deren Gatten hatEhemann(1,2) +<PRONOUN> Vater hatVater(1,2) +Kinder dieses <NE> hatElternteil(1,2) +Männer Töchter hatEhefrau(1,2) +<GENITIV> Sekretär hatAngestellten(1,2) +dessen Schwestern hatSchwester(1,2) +dessen Schwester hatSchwester(1,2) +<GENITIV> Dorfsekretär hatAngestellten(1,2) +dessen Geliebten hatGeliebten(1,2) +der solche Freunde hatFreund(1,2) +Geschäftsfreunde hatFreund(1,2) +Zwillingsbruder hatBruder(1,2) +Geliebten <GENITIV> hatGeliebten(1,2) +Enkel des <NE> hatGroßelternteil(1,2) +<NE> liebt <NE> hatGeliebten(1,2) +Kind eines <NE> hatVater(1,2) +<GENITIV> Schüler hatSchüler(1,2) +Halbbruder von <NE> hatBruder(2,1) +<NE> Liebe zu <NE> hatGeliebten(1,2) +Onkels hatOnkel(1,2) +<NE> Hochzeit mit <NE> hatEhefrau(1,2) +Tochter jener <NE> hatMutter(1,2) +Verwandte <GENITIV> hatVerwandten(1,2) +<NE> heiratet <NE> hatEhepartner(1,2) +deren Mann hatEhemann(1,2) +Knecht bei <NE> hatGebieter(1,2) +deren Großmutter hatGroßelternteil(1,2) +sie einen Sohn hatSohn(1,2) +ihm befreundeten <NE> hatFreund(1,2) +<GENITIV> Schwester hatSchwester(1,2) +<PRONOUN> Herkunftsfamilie hatFamilienteil(1,2) +<NE> einen Sohn hatSohn(1,2) +Freund ihres <NE> hatFreund(1,2) +Kinder <GENITIV> hatMutter(1,2) +<NE> Ehe mit <NE> hatEhepartner(1,2) +<NE> bandelt mit <NE> hatGeliebten(1,2) +<PRONOUN> Lehrherrn hatLehrer(1,2) +Vater des <NE> hatVater(2,1) +<PRONOUN> Pflegemutter hatPflegemutter(1,2) +Kindern des <NE> hatVater(1,2) +<PRONOUN> beiden Töchter hatTochter(1,2) +<PRONOUN> Halbbruders hatBruder(1,2) +<NE> verliebt in <NE> hatGeliebten(1,2) +<NE> vermählt mit <NE> hatEhepartner(1,2) +<NE> hat uneheliches Kind hatkind(1,2) \ No newline at end of file diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/relationGeneral1/ruleset_temp.txt b/de.uniwue.mk.kall.ruleBasedRelationClassification/relationGeneral1/ruleset_temp.txt new file mode 100644 index 0000000..c2ac76e --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/relationGeneral1/ruleset_temp.txt @@ -0,0 +1,456 @@ +<NE> ist Mutter hatMutter(1,2) +<GENITIV> <BERUF> hatDienstleister(1,2) +<GENITIV> Nachfolger hatSozialeRelation(1,2) +Gemahlin hatEhefrau(1,2) +<GENITIV> Neffe hatNeffen(1,2) +Sohn hatSohn(1,2) +<NE> verliebt in <NE> hatGeliebten(1,2) +Vaters hatVater(1,2) +Vater hatVater(1,2) +Sohn des <NE> hatVater(1,2) +Kollegen hatArbeitskollegen(1,2) +Bruders hatBruder(1,2) +Mutter hatMutter(1,2) +Schwester hatSchwester(1,2) +<NE> verliebt in <NE> hatGeliebten(1,2) +Brotherrn hatVorgesetzten(1,2) +Mannes hatEhemann(1,2) +<NE> geschenkt Tochter hatTochter(1,2) +Tochter <GENITIV> hatTochter(1,2) +Familie hatFamilienteil(1,2) +<NE> geliebter Freund hatFreund(1,2) +Erbfeind der <NE> hatFeind(2,1) +<NE> wollten Feind hatFeind(1,2) +<NE> angehörte <NE> hatUntergebenen(2,1) +meine <BERUF> hatAngestellten(1,2) +<NE> in verliebt <NE> hatGeliebten(1,2) +<NE> eine Tochter hatTochter(1,2) +Bruder hatBruder(1,2) +<NE> einen Freund hatFreund(1,2) +Geliebte des <NE> hatGeliebten(1,2) +Kindern hatKind(1,2) +<NE> waren Mutter hatMutter(1,2) +Sohn und eine Tochter hatGeschwisterteil(1,2) +dessen Ratgeber hatAngestellten(1,2) +<NE> verliebt in <NE> hatGeliebten(1,2) +Arbeiter hatAngestellten(1,2) +<GENITIV> Eigentümerin hatGebieter(1,2) +Schulkameraden hatSozialeRelation(1,2) +<NE> von Geburt bis zur Heirat mit der <NE> hatEhefrau(1,2) +er heiratet <NE> hatEhefrau(1,2) +Gegenspieler hatFeind(1,2) +Kind hatKind(1,2) +Feind hatFeind(1,2) +<NE> heiratet er hatEhemann(1,2) +dessen Tochter hatTochter(1,2) +<NE> in Dienst des <NE> hatVorgesetzten(1,2) +<NE> liebt <NE> hatGeliebten(1,2) +Sohn eines <NE> hatSohn(2,1) +Geliebten hatGeliebten(1,2) +Kind von <NE> hatKind(1,2) +Vorfahren hatVorfahre(1,2) +Großvater hatGroßelternteil(1,2) +Tante hatTante(1,2) +<NE> den Großvater hatGroßelternteil(1,2) +Mitmenschen hatSozialeRelation(1,2) +Diener hatDiener(1,2) +<NE> Zuneigung zu <NE> hatGeliebten(1,2) +Oheims hatOnkel(1,2) +Herrin hatVorgesetzten(1,2) +Geliebte hatGeliebten(1,2) +Schutzbefohlene hatGebieter(1,2) +Jugendliebe hatGeliebten(1,2) +Freundes hatFreund(1,2) +Vater seines <NE> hatVater(2,1) +Bräutigam hatEhemann(1,2) +<NE> schließt Freundschaft mit <NE> hatFreund(1,2) +Gast hatSozialeRelation(1,2) +<GENITIV> Familie hatFamilienteil(1,2) +Tante <GENITIV> hatTante(2,1) +deren Ehe mit <NE> hatEhemann(1,2) +seine Neigung zu <NE> hatGeliebten(1,2) +<NE> in Leidenschaft zu <NE> hatGeliebten(1,2) +Vertrauten des <NE> hatGeliebten(1,2) +Herrin hatGebieter(1,2) +Magd der <NE> hatGebieter(1,2) +Liebhaber hatGeliebten(1,2) +Liebhaber <GENITIV> hatGeliebten(1,2) +<NE> geliebten <NE> hatGeliebten(1,2) +Base hatVerwandten(1,2) +Witwe eines <NE> hatEhemann(1,2) +<NE> den Liebenden hatGeliebten(1,2) +Angebetete hatGeliebten(1,2) +Feldherr <GENITIV> hatGebieter(1,2) +Sohn <GENITIV> hatSohn(2,1) +<GENITIV> Befreier hatSozialeRelation(1,2) +Vater weist ihn hatSohn(1,2) +Frau hatEhefrau(1,2) +<GENITIV> Frau hatEhefrau(1,2) +<NE> schafft Feind hatFeind(1,2) +Geliebte <GENITIV> hatGeliebten(1,2) +Kindes hatKind(1,2) +König hatGebieter(1,2) +<ADELSTITEL> hatGebieter(1,2) +Herrn hatGebieter(1,2) +Vertraute <GENITIV> hatFreund(2,1) +Bruder des <NE> hatBruder(1,2) +<NE> bittet den Bruder hatBruder(1,2) +<NE> vermählt mit <NE> hatEhepartner(1,2) +<GENITIV> Bruder hatBruder(1,2) +Freund hatFreund(1,2) +Volk hatGebieter(1,2) +<NE> hat Kind hatKind(1,2) +<NE> beim Sohn hatSohn(1,2) +<NE> kehrt verrichten beim Vater hatVater(1,2) +Tochter hatTochter(1,2) +Bruder des <NE> hatBruder(1,2) +Nichte des <NE> hatOnkel(1,2) +dessen Sohn hatSohn(1,2) +Ziehvaters hatPflegeeltenrteil(1,2) +Eltern hatElternteil(1,2) +Kindes hatKind(1,2) +<GENITIV> Verlobter hatVerlobten(1,2) +Familie des <NE> hatFamilienteil(1,2) +Onkels hatOnkel(1,2) +<GENITIV> Tochter hatTochter(1,2) +<NE> des <ADELSTITEL> hatGebieter(1,2) +<GENITIV> Vater hatVater(1,2) +<NE> Hochzeit mit <NE> hatEhepartner(1,2) +Verwandte <GENITIV> hatVerwandten(1,2) +<NE> heiratet <NE> hatEhepartner(1,2) +deren Mann hatEhemann(1,2) +<GENITIV> Vetter hatVerwandten(1,2) +Meister hatMeister(1,2) +Knecht bei <NE> hatGebieter(1,2) +Schwiegersohn haben den alten <NE> hatSchwiegerkind(1,2) +<GENITIV> Vater hatVater(1,2) +Altersgenossen hatSozialeRelation(1,2) +<NE> haben Sohn hatSohn(1,2) +<NE> hat geheiratet <NE> hatEhefrau(1,2) +Braut hatEhefrau(1,2) +<NE> befreundeten <NE> hatFreund(1,2) +deren Vetter hatVerwandten(1,2) +<GENITIV> Tochter hatTochter(1,2) +<GENITIV> Nichte hatNichte(1,2) +<GENITIV> Jugendfreund hatFreund(1,2) +<NE> gebiert Sohn hatSohn(1,2) +<NE> gebiert Tochter hatTochter(1,2) +Verlobten hatVerlobten(1,2) +Vorgesetzten hatVorgesetzten(1,2) +<PRONOUN> Verlobter hatVerlobten(1,2) +<NE> Ehe mit <NE> hatEhemann(1,2) +<NE> geht und heiratet <NE> hatEhepartner(1,2) +<NE> bandelt mit <NE> hatGeliebten(1,2) +Kinder hatKind(1,2) +<NE> mit Gehilfen hatDiener(1,2) +Lehrherrn hatLehrer(1,2) +Schwester seines <NE> hatSchwester(2,1) +Gattin hatEhefrau(1,2) +Vater des <NE> hatVater(1,2) +Ehefrau hatEhefrau(1,2) +Pflegemutter hatPflegemutter(1,2) +Pflegetochter hatPflegekind(1,2) +Bruder <GENITIV> hatBruder(1,2) +<FAMILY_RELATION> <GENITIV> hatFamilyRelation(1,2) +Kindern des <NE> hatKind(2,1) +Angestellten hatAngestellten(1,2) +<FAMILY_RELATION> hatFamilyRelation(1,2) +<FAMILY_RELATION> des <NE> hatFamilyRelation(1,2) +<FAMILY_RELATION> der <NE> hatFamilyRelation(1,2) +<FAMILY_RELATION> <GENITIV> hatFamilyRelation(1,2) +<ADELSTITEL> hatGebieter(1,2) +<BERUF> hatDienstleister(1,2) +<NE> leben verbunden mit <NE> hatFreund(1,2) +<GENITIV> Freund hatFreund(1,2) +<NE> Weg führt in Ehe mit <NE> hatEhepartner(1,2) +Halbbruders hatBruder(1,2) +<GENITIV> <FAMILY_RELATION> hatFamilyRelation(1,2) +<GENITIV> <BERUF> hatDienstleister(1,2) +<PRONOUN> Vetter hatVerwandten(1,2) +<NE> vereint und <NE> hatFreund(1,2) +<NE> gegen <FAMILY_RELATION> hatFamilyRelation(1,2) +Familie eines <NE> hatFamilienteil(2,1) +<NE> entstammt Familie hatFamilienteil(1,2) +Tochter lässt <NE> hatTochter(1,2) +Mann hatEhemann(1,2) +<GENITIV> Eltern hatElternteil(1,2) +<NE> in Begleitung eines Freundes hatFreund(1,2) +Magd hatAngestellten(1,2) +<NE> den Adoptivsohn hatPflegekind(1,2) +Kind der <NE> hatKind(2,1) +Tochter eines <GENITIV> hatTochter(1,2) +<FAMILY_RELATION> eines <GENITIV> hatFamilyRelation(1,2) +<GENITIV> Schwester hatSchwester(1,2) +<NE> dem <FAMILY_RELATION> hatFamilyRelation(1,2) +<NE> der <FAMILY_RELATION> hatFamilyRelation(1,2) +<NE> bis zur Heirat mit <NE> hatEhepartner(1,2) +Mutter ermahnte sie hatTochter(1,2) +er gegen den Vater hatVater(1,2) +Angehörigen hatVerwandten(1,2) +Bruderskind hatNeffen(1,2) +Schwäher hatSozialeRelation(1,2) +Frau <GENITIV> hatEhemann(1,2) +<NE> will Vater hatVater(1,2) +<NE> liebte <NE> hatGeliebten(1,2) +Mutter und Tante hatVerwandten(1,2) +Unterweltsgenossen hatFreund(1,2) +Liebling der <NE> hatGeliebten(1,2) +<NE> Gunst der <NE> hatSozialeRelation(1,2) +<NE> Liaison zu <NE> hatGeliebten(1,2) +Gehilfe hatAngestellten(1,2) +<GENITIV> Köchin hatAngestellten(1,2) +Schulmeister zu <NE> hatSchüler(1,2) +Lehrers , den Schülern hatSchüler(1,2) +Herr und Diener hatDiener(1,2) +<NE> gegen <FAMILY_RELATION> hatFamilyRelation(1,2) +beide , mit Diener hatDiener(1,2) +Sohne hatSohn(1,2) +Schreiber hatDienstleister(1,2) +<FAMILY_RELATION> , « sagte <NE> hatFamilyRelation(2,1) +unsern Befreundten hatFreund(1,2) +Freunde hatFreund(1,2) +Knechten hatDienstleister(1,2) +Leuten hatAngestellten(1,2) +<NE> aufnimmt in Freundeskreis <NE> hatFreund(1,2) +<NE> Liebe zu <NE> hatGeliebten(1,2) +<NE> kann heiraten <NE> hatEhepartner(1,2) +, Mann hatEhemann(1,2) +Freund des <NE> hatFreund(1,2) +<GENITIV> Dorfsekretär hatAngestellten(1,2) +dessen Schwestern hatSchwester(1,2) +<GENITIV> Sekretär hatAngestellten(1,2) +Zimmernachbarin hatSozialeRelation(1,2) +Verwandten hatVerwandten(1,2) +Männer seiner Töchter hatEhefrau(1,2) +Töchter hatTochter(1,2) +<NE> Zwillinge und <NE> hatGeschwisterteil(1,2) +Jugendfreund hatFreund(1,2) +<NE> erlebt Verfall in der Familie hatFamilienteil(1,2) +<NE> verlebt in Liebe zu <NE> hatGeliebten(1,2) +<NE> vermählt mit <NE> hatEhepartner(1,2) +Sohn eines und Mutter hatMutter(1,2) +<NE> schafft Feind hatFeind(1,2) +Schüler hatSchüler(1,2) +Tochter der , <NE> hatTocher(2,1) +<NE> und Geliebten hatGeliebten(1,2) +<NE> Heirat mit <NE> hatEhemann(1,2) +<ENDS-S> <FAMILY_RELATION> hatFamilyRelation(1,2) +<ENDS-S> Tochter hatTochter(1,2) +Vater seines Freundes hatSohn(1,2) +Kameraden <ENDS-S> hatFreund(1,2) +<NE> , begleitet von Freund hatFreund(1,2) +, Frau hatEhefrau(1,2) +<NE> Zuneigung wird erwidert von <NE> hatGeliebten(1,2) +Jugendfreund <ENDS-S> hatFreund(2,1) +Ziehbruder hatStiefgeschwisterteil(1,2) +<NE> Adoption durch <NE> hatPflegeelternteil(1,2) +<NE> ein Schwiegersohn hatSchwiegerkind(1,2) +Sohn dem Alten hatVater(1,2) +konvertierten Freunden hatFreund(1,2) +<ENDS-S> Mentor hatLehrer(1,2) +mir gebar <NE> hatEhepartner(1,2) +Komplizin <ENDS-S> hatArbeitskollegen(1,2) +<ENDS-S> Antipodin hatFeind(1,2) +<NE> tritt in Dienste <NE> hatVorgesetzten(1,2) +<ENDS-S> Verlobter hatVerlobten(1,2) +<NE> Töchter und <NE> hatSchwester(1,2) +<NE> und Advokaten hatVorgesetzten(1,2) +Geliebten <ENDS-S> hatGeliebten(1,2) +seinem Schützling hatSchüler(1,2) +Schwägerin hatSozialeRelation(1,2) +<NE> liebt und <NE> hatGeliebten(1,2) +Kind eines <NE> hatKind(2,1) +<FAMILY_RELATION> von <NE> hatFamilyRelation(2,1) +<NE> leidet unter Liebe zur <NE> hatGeliebten(1,2) +Schwester <GENITIV> hatSchwester(1,2) +Mutter <ENDS-S> hatMutter(2,1) +<NE> geheiratet hat <NE> hatEhepartner(1,2) +beiden Töchtern hatTochter(1,2) +<NE> hätten gibt und heiratet <NE> hatEhepartner(1,2) +Weib hatEhefrau(1,2) +Gebieterinn hatGebieter(1,2) +Liebe hatGeliebten(1,2) +Freundin hatFreund(1,2) +Fürsten hatGebieter(1,2) +Freier hatGeliebten(1,2) +Vater widerspricht , Mutter hatEhefrau(1,2) +Gefährtin hatSozialeRelation(1,2) +<NE> konnte nähren Kind hatKind(1,2) +<FAMILY_RELATION> dieser <NE> hatFamilyRelation(2,1) +Volke hatUntergebenen(1,2) +Sohn war ihrer hatMutter(1,2) +Nachfolgerin <GENITIV> hatSozialeRelation(1,2) +Pflegerin hatDiener(1,2) +<NE> eine treue <FAMILY_RELATION> hatFamilyRelation(1,2) +<NE> als Freund hatFreund(1,2) +Ausgeberin hatAngestellten(1,2) +<NE> werde geboren Kind hatKind(1,2) +er fiel <FAMILY_RELATION> hatFamilyRelation(1,2) +<NE> suchte wegen <FAMILY_RELATION> hatFamilyRelation(1,2) +Mägde hatAngestellten(1,2) +<NE> Sehnsucht nach und Kindern hatKind(1,2) +Schülerin hatSchüler(1,2) +<NE> auf die Haushälterin hatAngestellten(1,2) +Lieber hatFreund(1,2) +Kinde hatKind(1,2) +Gäset hatSozialeRelation(1,2) +<NE> Liebe als <NE> hatGeliebten(1,2) +<GENITIV> Weib hatEhefrau(1,2) +<NE> Verlust des Freundes hatFreund(1,2) +<NE> an <FAMILY_RELATION> hatFamilyRelation(1,2) +<NE> schickte <APPELLATIV> hatAngestellten(1,2) +Gatten hatEhemann(1,2) +Untergebenen hatAngestellten(1,2) +<NE> schloß Freundin hatFreund(1,2) +<NE> sich mit Kind hatKind(1,2) +<NE> sich und Dienerin hatDiener(1,2) +Freunden <GENITIV> hatFreund(1,2) +Geliebte <NE> hatGeliebten(1,2) +<NE> aufnimmt in Freundeskreis <NE> hatFreund(1,2) +<NE> die Mutter hatMutter(1,2) +<NE> , , als Gemahlin hatEhefrau(1,2) +<NE> läuft und tritt in Dienst <NE> hatVorgesetzten(1,2) +<NE> gelingt anbetete <NE> hatGeliebten(1,2) +seine Sehnsucht und <FAMILY_RELATION> hatFamilyRelation(1,2) +<NE> ein Kind hatKind(1,2) +Kameraden hatArbeitskollegen(1,2) +<NE> haben Feinde hatFeind(1,2) +Volker hatGebieter(2,1) +<GENITIV> Braut hatEhefrau(1,2) +Manne hatEhemann(1,2) +<NE> Liebe <NE> hatGeliebten(1,2) +<NE> einen Kameraden hatFreund(1,2) +<NE> der Liebsten hatGeliebten(1,2) +<NE> eine Dirn hatDiener(1,2) +ich bin , Tante hatTante(1,2) +<NE> , wenn <FAMILY_RELATION> hatFamilyRelation(1,2) +<NE> redet in Familie hatFamilienteil(1,2) +<NE> erwählt <NE> hatGeliebten(1,2) +dessen Braut hatEhefrau(1,2) +<NE> hatte geboren Kind hatKind(1,2) +Herr und <BERUF> hatAngestellten(1,2) +Knappen hatAngestellten(1,2) +<NE> heiratete <NE> hatEhepartner(1,2) +<NE> aus Liebe zur <NE> hatGeliebten(1,2) +<NE> angreift <NE> hatFeind(1,2) +Diener eines <NE> hatDiener(2,1) +<NE> Sehnsucht nach Frau hatEhefrau(1,2) +<NE> könnte <FAMILY_RELATION> hatFamilyRelation(1,2) + +Freundin des <NE> hatFreund(1,2) +Mutter und Tochter hatTochter(1,2) +Novizen hatVorgesetzten(1,2) +unsern Herrn hatGebieter(1,2) +Buben hatSohn(1,2) +Söhne des <NE> hatSohn(1,2) +Söhnen hatSohn(1,2) +Vorsteher hatVorgesetzten(1,2) +Mitarbeiterinnen hatArbeitskollegen(1,2) +Sohn des <NE> hatSohn(1,2) +Eltern solchen Sohnes hatSohn(1,2) +<NE> einen Vetter hatVerwandten(1,2) +<GENITIV> Knabe hatSohn(1,2) +<NE> zu <FAMILY_RELATION> hatFamilyRelation(1,2) +<FAMILY_RELATION> und <FAMILY_RELATION> hatFamilyRelation(1,2) +<FAMILY_RELATION> von diesem <NE> hatFamilyRelation(2,1) +<NE> einen Vetter hatVerwandten(1,2) +Schulfreundin hatFreund(1,2) +Verwandten meines <NE> hatVerwandten(1,2) +Hauptmann hatVorgesetzten(1,2) +Sein Herr hatGebieter(1,2) +sein Herr hatGebieter(1,2) +Pate hatSozialeRelation(1,2) +Magd deines <NE> hatVorgesetzten(1,2) +<GENITIV> Herr hatGebieter(1,2) +<BERUF> des Herrn hatVorgesetzten(1,2) +<NE> verliebte in <NE> hatGeliebten(1,2) +Wohltäter hatFreund(1,2) +Beichtvaters hatSozialeRelation(1,2) +, , Kind hatKind(1,2) +<NE> folgten einige Freunde hatFreund(1,2) +<NE> lässt von Liebe zu <NE> hatGeliebten(1,2) +Vertraute des , <NE> hatFreund(1,2) +<NE> bei Großmama hatGroßelternteil(1,2) +Kameraden hatFreund(1,2) +<NE> und Kindern hatKind(1,2) +<NE> wünschte Kind hatKind(1,2) +<NE> Sorge um Kind hatKind(1,2) +Anwalts hatDienstleister(1,2) +Anwalt hatDienstleister(1,2) +<NE> an Oberinnen hatGebieter(1,2) +<NE> mit , Oberin hatGebieter(1,2) +<NE> mit Oberin hatGebieter(1,2) +Oberin hatte mit <NE> hatUntergebenen(1,2) +Kind einer <NE> hatKind(2,1) +<NE> , wird von Mutter hatMutter(1,2) +<NE> , wird von <FAMILY_RELATION> hatFamilyRelation(1,2) +Oberin hatVorgesetzten(1,2) +Gefährtinnen hatSozialeRelation(1,2) +Gläubigen hatSozialeRelation(1,2) +Gebieterin hatGebieter(1,2) +<NE> nicht Liebschaft mit <NE> hatGeliebten(1,2) +<NE> Liebschaft mit <NE> hatGeliebten(1,2) +<NE> diesen Feind hatFeind(1,2) +<NE> hofft besiegen <NE> hatFeind(1,2) +<NE> anfreundet mit <NE> hatFreund(1,2) +<GENITIV> Mutter hatMutter(1,2) +<NE> hat und heiratet <NE> hatEhepartner(1,2) +<NE> Kindheit endet Mutter hatMutter(1,2) +dessen Neffen hatNeffen(1,2) +<BERUF> von <NE> hatVorgesetzten(1,2) +geliebte <NE> hatGeliebten(1,2) +<GENITIV> Schulfreund hatFreund(1,2) +Großtante hatVerwandten(1,2) +Kinde hatKind(1,2) +Pflegerin hatDienstleister(1,2) +Magd des <NE> hatGebieter(1,2) +Ich hab ein Kind hatKind(1,2) +Eltern , und <NE> hatElternteil(1,2) +Eltern , <NE> hatElternteil(1,2) +<NE> beide <FAMILY_RELATION> hatFamilyRelation(1,2) +seiner Frau und Kindern hatKind(1,2) +//Precision 79.4% +Magd des <NE> hatVorgesetzten(1,2) +<NE> die Tochter hatTochter(1,2) +<NE> , Kinder hatKind(1,2) +<NE> Jawort und <NE> hatEhepartner(1,2) +<NE> mit Kindern hatKind(1,2) +<NE> mit Eltern hatElternteil(1,2) +<NE> konnte <FAMILY_RELATION> hatFamilyRelation(1,2) +<NE> und Ehemann hatEhemann(1,2) +<NE> Schwestern und <NE> hatSchwester(1,2) +Mätressen hatSozialeRelation(1,2) +Führer hatVorgesetzten(1,2) +Nachfolger <ENDS-S> hatSozialeRelation(1,2) +<FAMILY_RELATION> jenes <NE> hatFamilyRelation(2,1) +<NE> dem <ADELSTITEL> hatSozialeRelation(1,2) +<NE> hassten <NE> hatFeind(1,2) +<NE> liebe <NE> hatGeliebten(1,2) +<NE> Beziehung zu <NE> hatGeliebten(1,2) +Liebhaber <NE> hatGeliebten(1,2) +<NE> gewinnen <BERUF> hatAngestellten(1,2) +Freunden hatFreund(1,2) +<NE> pflegt <NE> hatDienstleister(1,2) +Knecht hatDiener(1,2) +Gästen hatSozialeRelation(1,2) +Anbeter hatGeliebten(1,2) +<NE> der Kaiser hatVorgesetzten(1,2) +<NE> war verliebt in <NE> hatGeliebten(1,2) +Gebieters hatGebieter(1,2) +Frauen solcher Männer hatEhemann(1,2) +<NE> hatte vorgestellt <ADELSTITEL> hatVorgesetzten(1,2) +Regiment hatUntergebenen(1,2) +Nebenbuhler hatFeind(1,2) +Zukünftiger hatVerlobten(1,2) +Zukünftige hatVerlobte(1,2) +Knaben hatSohn(1,2) +<NE> stellt sich <NE> hatFeind(1,2) +Nachkommen hatNachfahre(1,2) +Mann und Frau hatEhefrau(1,2) +Peiniger hatSozialeRelation(1,2) +<NE> saßen Mutter hatMutter(1,2) +<NE> begleitet und Vater hatVater(1,2) +<NE> Vermittlung Magd hatAngestellten(1,2) +<NE> waren war <FAMILY_RELATION> hatFamilyRelation(1,2) +Widersacher hatRivale(1,2) +<NE> Geliebte hatGeliebten(1,2) \ No newline at end of file diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/algo/ARelationDetectionPass.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/algo/ARelationDetectionPass.java new file mode 100644 index 0000000..11698bf --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/algo/ARelationDetectionPass.java @@ -0,0 +1,11 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.algo; + +import java.util.List; + +import de.uniwue.mk.kall.relationResources.util.MentionPair; + +public abstract class ARelationDetectionPass { + + public abstract void apply(List<MentionPair> pairs); + +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/algo/RelationPairFirstPass.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/algo/RelationPairFirstPass.java new file mode 100644 index 0000000..7a5d1ea --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/algo/RelationPairFirstPass.java @@ -0,0 +1,132 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.algo; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mk.kall.relationResources.util.MentionPair; +import de.uniwue.mk.kall.ruleBasedRelationClassification.firstpass.rules.ARelationDetectionRule; +import de.uniwue.mk.kall.ruleBasedRelationClassification.firstpass.rules.RepresentationNPRule; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class RelationPairFirstPass extends ARelationDetectionPass { + + private List<ARelationDetectionRule> rulesetVerbs; + private List<ARelationDetectionRule> ruleSetPhrases; + + public RelationPairFirstPass() { + rulesetVerbs = new ArrayList<ARelationDetectionRule>(); + ruleSetPhrases = new ArrayList<ARelationDetectionRule>(); + + // ruleset.add(new MatrixPathsRelationRule()); + + // ruleSetPhrases.add(new LookiLookiDetectionRule()); + // ruleSetPhrases.add(new PossessivesRelationRule()); + // ruleSetPhrases.add(new PreciseConstructsRule()); + ruleSetPhrases.add(new RepresentationNPRule()); + + // rule mit dep pfaden + // rulesetVerbs.add(new DependencyPathRule()); + // rulesetVerbs.add(new DefinitToSubjectRule()); + + } + + @Override + public void apply(List<MentionPair> pairs) { + + for (MentionPair pair : pairs) { + + int begin = pair.getNeFrom().getBegin(); + int end = pair.getNeTo().getEnd(); + Util_impl util = new Util_impl(pair.getCas()); + List<AnnotationFS> covered = util.getCovered(begin, end, util.getDependencyType()); + + boolean containsVerb = false; + for (AnnotationFS tok : covered) { + + if (util.isVerb(tok)) { + containsVerb = true; + } + } + int amountOutside = determineEdgesOutOfTextChunk(covered, pair, begin, end, util); + if (amountOutside == 1 && !containsVerb) { + pair.setResolveWithNPs(true); + } else { + pair.setResolveWithNPs(false); + } + + } + + for (MentionPair pair : pairs) { + + for (ARelationDetectionRule rule : ruleSetPhrases) { + if (!pair.isResolved()) { + rule.apply(pair); + } + + } + // if (pair.getResolveWithNPs() == false) { + // for (ARelationDetectionRule rule : rulesetVerbs) { + // if (!pair.isResolved()) { + // rule.apply(pair); + // } + // } + // } else { + // for (ARelationDetectionRule rule : ruleSetPhrases) { + // if (!pair.isResolved()) { + // rule.apply(pair); + // } + // } + // + // } + } + + } + + private int determineEdgesOutOfTextChunk(List<AnnotationFS> covered, MentionPair pair, int begin, int end, + Util_impl util) { + int amountOutside = 0; + for (AnnotationFS tok : covered) { + + AnnotationFS father = util.getFather(tok); + + if (father == null) { + amountOutside++; + continue; + } + + // check if father is outside!! + if (father.getEnd() < begin || father.getBegin() > end) { + amountOutside++; + } + } + + // this results is often not correct because the parser has issues, + // but we can fix a little bit + + // inside a NE only 1 edge can leave the textspan + int amountEdgesSecondNe = 0; + + for (AnnotationFS tok : util.getCovered(pair.getNeTo(), util.getDependencyType())) { + AnnotationFS father = util.getFather(tok); + + if (father == null) { + amountEdgesSecondNe++; + continue; + } + + if (father.getEnd() < begin || father.getBegin() > end) { + amountEdgesSecondNe++; + } + + } + + // now correct that result + amountOutside = amountOutside - Math.max(1, amountEdgesSecondNe) + 1; + + return amountOutside; + + } + +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/algo/RuleBasedRelationDetection.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/algo/RuleBasedRelationDetection.java new file mode 100644 index 0000000..8b92899 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/algo/RuleBasedRelationDetection.java @@ -0,0 +1,171 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.algo; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mk.kall.neCategoryDetermination.app.NECategoryDeterminationAlgorithm; +import de.uniwue.mk.kall.relationResources.util.MentionPair; +import de.uniwue.mk.kall.ruleBasedRelationClassification.filter.AMentionCreationFilter; +import de.uniwue.mk.kall.ruleBasedRelationClassification.filter.SecondisNotRelateableFilter; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class RuleBasedRelationDetection { + + private List<ARelationDetectionPass> passes; + private List<AMentionCreationFilter> filter; + + public RuleBasedRelationDetection() { + + passes = new ArrayList<ARelationDetectionPass>(); + + passes.add(new RelationPairFirstPass()); + filter = new ArrayList<AMentionCreationFilter>(); + + // filter.add(new BothArePronounsFilter()); + filter.add(new SecondisNotRelateableFilter()); + // filter.add(new FirstIsNotRelateableFilter()); + // filter.add(new PluralFilter()); + } + + public List<AnnotationFS> detectRelations(CAS cas) { + + NECategoryDeterminationAlgorithm algo = new NECategoryDeterminationAlgorithm(); + + algo.determineCategory(cas, new Util_impl(cas)); + + List<MentionPair> pairs = createMentionPairs(cas); + + List<AnnotationFS> rels = detectRelations(pairs); + + return rels; + } + + public List<String> detectRelationsPredictAll(List<MentionPair> pairs) { + for (ARelationDetectionPass pass : passes) { + + pass.apply(pairs); + } + + if (pairs.size() == 0) + return new ArrayList<>(); + + List<String> rels = new ArrayList<String>(); + + Util_impl util = new Util_impl(pairs.get(0).getCas()); + for (MentionPair pair : pairs) { + + if (pair.isResolved()) { + + String relationFromTo = pair.getRelationFromTo(); + String relationToFrom = pair.getRelationToFrom(); + + if (relationFromTo != null) { + + rels.add(relationFromTo); + + } + + else if (relationToFrom != null) { + rels.add(relationToFrom); + } + + else { + rels.add("O"); + } + + } else { + rels.add("O"); + } + } + return rels; + } + + public List<AnnotationFS> detectRelations(List<MentionPair> pairs) { + for (ARelationDetectionPass pass : passes) { + + pass.apply(pairs); + } + + if (pairs.size() == 0) + return new ArrayList<>(); + + List<AnnotationFS> rels = new ArrayList<AnnotationFS>(); + + Util_impl util = new Util_impl(pairs.get(0).getCas()); + for (MentionPair pair : pairs) { + + if (pair.isResolved()) { + + String relationFromTo = pair.getRelationFromTo(); + String relationToFrom = pair.getRelationToFrom(); + CAS cas = pair.getNeFrom().getCAS(); + + if (relationFromTo != null) { + + createRelation(cas, rels, util, pair, relationFromTo); + + } + + if (relationToFrom != null) { + createRelation(cas, rels, util, pair, relationToFrom); + } + + } + } + return rels; + } + + private void createRelation(CAS cas, List<AnnotationFS> rels, Util_impl util, MentionPair pair, + String relationFromTo) { + AnnotationFS fs = cas.createAnnotation(util.getRelationType(), pair.getNeFrom().getBegin(), pair.getNeTo() + .getEnd()); + + fs.setFeatureValueFromString(util.getRelationTypeFeature(), relationFromTo); + fs.setFeatureValue(util.getRelationAgensFeature(), pair.getNeFrom()); + fs.setFeatureValue(util.getRelationAgens2Feature(), pair.getNeTo()); + + rels.add(fs); + } + + private List<MentionPair> createMentionPairs(CAS cas) { + + List<MentionPair> pairs = new ArrayList<MentionPair>(); + + Util_impl util = new Util_impl(cas); + + // all inter-sentential + for (AnnotationFS sentence : cas.getAnnotationIndex(util.getSentenceType())) { + + List<AnnotationFS> covered = util.getCovered(sentence, util.getNamedEntityType()); + + for (int i = 0; i < covered.size(); i++) { + + AnnotationFS annoFrom = covered.get(i); + + for (int j = i + 1; j < covered.size(); j++) { + + AnnotationFS annoTo = covered.get(j); + + MentionPair p = new MentionPair(annoFrom, annoTo); + boolean isValidPair = true; + for (AMentionCreationFilter afilter : filter) { + if (afilter.isInvalidPair(p)) { + isValidPair = false; + } + } + + if (isValidPair) { + pairs.add(p); + } + + } + } + } + + return pairs; + } + +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/EvalStruct.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/EvalStruct.java new file mode 100644 index 0000000..aba3ee4 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/EvalStruct.java @@ -0,0 +1,12 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.app; + +import java.util.ArrayList; +import java.util.List; + +public class EvalStruct { + + int tp; + int fp; + List<String> fps = new ArrayList<String>(); + List<String> tps = new ArrayList<String>(); +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/EvaluateRulesMain.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/EvaluateRulesMain.java new file mode 100644 index 0000000..c963418 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/EvaluateRulesMain.java @@ -0,0 +1,158 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.app; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.impl.XmiCasDeserializer; +import org.apache.uima.cas.text.AnnotationFS; +import org.xml.sax.SAXException; + +import de.uniwue.mk.kall.relationResources.util.MentionPair; +import de.uniwue.mk.kall.relationResources.util.RelationUtil; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class EvaluateRulesMain { + + // gets a precision for each rule!! + public static void main(String[] args) throws Exception, SAXException, IOException { + + File in = new File("C:\\Users\\mkrug\\TESTNewpluginPrepsystem\\RelationenDaten\\NECategoryTest"); + + Map<String, String> preciseConstructs = new HashMap<String, String>(); + + readRuleset(preciseConstructs); + + Map<String, EvalStruct> evalMap = new HashMap<>(); + + // for each rule + for (File f : in.listFiles()) { + if (f.isDirectory() || !f.getName().endsWith(".xmi")) + continue; + CAS cas = Util_impl.createCas(); + XmiCasDeserializer.deserialize(new FileInputStream(f), cas); + Util_impl util = new Util_impl(cas); + + List<MentionPair> pairs = createMentionPairs(cas); + for (MentionPair p : pairs) { + + Set<String> reps = RelationUtil.generateAllRepresentations(p.getNeFrom(), p.getNeTo()); + for (String rule : preciseConstructs.keySet()) { + + if (reps.contains(rule)) { + // check if there is a relation + boolean ruleFound = false; + + for (AnnotationFS rel : cas.getAnnotationIndex(util.getRelationType())) { + + if (rel.getBegin() == p.getNeFrom().getBegin() && rel.getEnd() == p.getNeTo().getEnd()) { + + ruleFound = true; + break; + } + } + + if (evalMap.containsKey(rule)) { + EvalStruct point = evalMap.get(rule); + + if (ruleFound) { + point.tp++; + point.tps.add(p.getTextAndBetween()); + } else { + point.fp++; + point.fps.add(p.getTextAndBetween()); + } + } else { + EvalStruct es = new EvalStruct(); + if (ruleFound) { + es.tp++; + es.tps.add(p.getTextAndBetween()); + } else { + es.fp++; + es.fps.add(p.getTextAndBetween()); + } + evalMap.put(rule, es); + } + + } + } + + } + } + for (String rule : evalMap.keySet()) { + + int fp = evalMap.get(rule).fp; + if (fp > 0) { + System.out.println(rule); + System.out.println("TP: " + evalMap.get(rule).tp + "\t" + "FP: " + fp); + for (String s : evalMap.get(rule).fps) { + System.out.println(s); + } + System.out.println(); + } + } + + } + + private static void readRuleset(Map<String, String> preciseConstructs) { + File preciseConstrcutsFolder = new File("relationGeneral"); + for (File f : preciseConstrcutsFolder.listFiles()) { + try { + List<String> lines = Files.readAllLines(f.toPath()); + + for (String line : lines) { + if (line.isEmpty() || line.startsWith("//")) + continue; + + if (line.split("\t").length == 1) + System.out.println(line); + preciseConstructs.put(line.split("\t")[0], line.split("\t")[1]); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + private static List<MentionPair> createMentionPairs(CAS cas) { + + List<MentionPair> pairs = new ArrayList<MentionPair>(); + + Util_impl util = new Util_impl(cas); + + // all inter-sentential + for (AnnotationFS sentence : cas.getAnnotationIndex(util.getSentenceType())) { + + List<AnnotationFS> covered = util.getCovered(sentence, util.getNamedEntityType()); + + for (int i = 0; i < covered.size(); i++) { + + AnnotationFS annoFrom = covered.get(i); + + for (int j = i + 1; j < covered.size(); j++) { + + AnnotationFS annoTo = covered.get(j); + + MentionPair p = new MentionPair(annoFrom, annoTo); + boolean isValidPair = true; + + if (isValidPair) { + pairs.add(p); + } + + } + } + } + + return pairs; + } + +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/PrintRelationsMain.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/PrintRelationsMain.java new file mode 100644 index 0000000..be422bb --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/PrintRelationsMain.java @@ -0,0 +1,36 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.app; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.impl.XmiCasDeserializer; +import org.apache.uima.cas.text.AnnotationFS; +import org.xml.sax.SAXException; + +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class PrintRelationsMain { + + public static void main(String[] args) throws Exception, SAXException, IOException { + + File in = new File("C:\\Users\\mkrug\\TESTNewpluginPrepsystem\\RelationenDaten\\NECategory"); + // File in = new + // File("C:\\Users\\mkrug\\TESTNewpluginPrepsystem\\PaperNetzwerke\\romaneCR"); + + CAS cas = Util_impl.createCas(); + + for (File f : in.listFiles()) { + + XmiCasDeserializer.deserialize(new FileInputStream(f), cas); + + Util_impl util = new Util_impl(cas); + for (AnnotationFS rel : cas.getAnnotationIndex(util.getRelationType())) { + + String relType = rel.getFeatureValueAsString(util.getRelationTypeFeature()); + System.out.println(rel.getCoveredText() + "\t" + relType); + } + } + } +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/RefactorRuleset.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/RefactorRuleset.java new file mode 100644 index 0000000..8f62518 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/RefactorRuleset.java @@ -0,0 +1,55 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.app; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class RefactorRuleset { + + public static void main(String[] args) throws IOException { + + File in = new File( + "C:\\marian_eclipse\\workspace_kepler_j8\\de.uniwue.mk.kall.ruleBasedRelationClassification\\relationGeneral\\ruleset.txt"); + + HashMap<String, Set<String>> ruleMap = new HashMap<String, Set<String>>(); + + List<String> lines = Files.readAllLines(in.toPath()); + + for (String line : lines) { + if (line.isEmpty() || line.startsWith("//")) + continue; + String[] split = line.split("\t"); + + String key = split[1].replaceAll("\\(.*", ""); + if (ruleMap.containsKey(key)) { + + ruleMap.get(key).add(line); + } else { + Set<String> rules = new HashSet<>(); + rules.add(line); + ruleMap.put(key, rules); + } + } + + File out = new File(in.getAbsolutePath().replaceAll("\\.txt", "") + "refactored.txt"); + + FileWriter fw = new FileWriter(out); + + for (String key : ruleMap.keySet()) { + + for (String s : ruleMap.get(key)) { + fw.append(s + "\n"); + } + fw.append("\n"); + } + + fw.flush(); + fw.close(); + + } +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/RelationRuleBasedMain.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/RelationRuleBasedMain.java new file mode 100644 index 0000000..165a0bf --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/RelationRuleBasedMain.java @@ -0,0 +1,126 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.app; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.impl.XmiCasDeserializer; +import org.apache.uima.cas.text.AnnotationFS; +import org.xml.sax.SAXException; + +import de.uniwue.mk.kall.relationResources.util.RelationUtil; +import de.uniwue.mk.kall.ruleBasedRelationClassification.algo.RuleBasedRelationDetection; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class RelationRuleBasedMain { + + public static void main(String[] args) throws Exception, SAXException, IOException { + + // File in = new File("C:\\owncloud\\korpus-Annotationen\\NE-CR-self"); + // File in = new + // File("C:\\Users\\mkrug\\TESTNewpluginPrepsystem\\PaperNetzwerke\\romaneCR"); + + File in = new File("C:\\owncloud\\projekt romangeschichte\\ActiveLearningRelationen\\ontologie\\Fertige Romane"); + // File in = new + // File("C:\\Users\\mkrug\\TESTNewpluginPrepsystem\\RelationenDaten\\NECategoryTrain"); + // File in = new + // File("C:\\Users\\mkrug\\TESTNewpluginPrepsystem\\RelationenDaten\\unklar"); + + // File in = new + // File("C:\\Users\\mkrug\\TESTNewpluginPrepsystem\\RelationenDaten\\NECategoryTest"); + + RuleBasedRelationDetection relDet = new RuleBasedRelationDetection(); + + double tp = 0; + double fp = 0; + double fn = 0; + for (File f : in.listFiles()) { + if (f.isDirectory() || !f.getName().endsWith(".xmi")) + continue; + // System.out.println(f); + CAS cas = Util_impl.createCas(); + XmiCasDeserializer.deserialize(new FileInputStream(f), cas); + Util_impl util = new Util_impl(cas); + + double tpDoc = 0; + double fpDoc = 0; + double fnDoc = 0; + List<AnnotationFS> relations = relDet.detectRelations(cas); + + HashSet<AnnotationFS> usedResl = new HashSet<AnnotationFS>(); + for (AnnotationFS rel : relations) { + boolean found = false; + for (AnnotationFS goldRel : cas.getAnnotationIndex(util.getRelationType())) { + + if (rel.getBegin() == goldRel.getBegin() && rel.getEnd() == goldRel.getEnd() + && !usedResl.contains(goldRel)) { + + tpDoc++; + usedResl.add(goldRel); + found = true; + break; + + } + } + if (!found) { + System.out.println(util.getCoveringSentence(rel).getCoveredText()); + System.out.println("FP: " + rel.getCoveredText() + "\t" + + rel.getFeatureValueAsString(util.getRelationTypeFeature())); + + // printRelation(util, rel); + } + + } + for (AnnotationFS goldRel : cas.getAnnotationIndex(util.getRelationType())) { + + if (!usedResl.contains(goldRel)) { + System.out.println(util.getCoveringSentence(goldRel).getCoveredText()); + System.out.println("FN: " + goldRel.getCoveredText() + " " + + goldRel.getFeatureValueAsString(util.getRelationTypeFeature())); + + printRelation(util, goldRel); + } + } + + fpDoc = relations.size() - tpDoc; + fnDoc = cas.getAnnotationIndex(util.getRelationType()).size() - tpDoc; + + tp += tpDoc; + fn += fnDoc; + fp += fpDoc; + + } + + System.out.println("TP:" + tp); + System.out.println("FP:" + fp); + System.out.println("FN:" + fn); + double prec = tp / (tp + fp); + System.out.println("PRECISION: " + prec); + double rec = tp / (tp + fn); + System.out.println("RECALL: " + rec); + System.out.println("F1: " + 2 * prec * rec / (prec + rec)); + } + + private static void printRelation(Util_impl util, AnnotationFS goldRel) { + AnnotationFS agens = (AnnotationFS) goldRel.getFeatureValue(util.getRelationAgensFeature()); + + AnnotationFS agens2 = (AnnotationFS) goldRel.getFeatureValue(util.getRelationAgens2Feature()); + + if (agens != null && agens2 != null) { + Set<String> generateTextRepresentations = null; + if (agens.getBegin() < agens2.getBegin()) { + generateTextRepresentations = RelationUtil.generateAllRepresentations(agens, agens2); + } else { + generateTextRepresentations = RelationUtil.generateAllRepresentations(agens2, agens); + } + for (String s : generateTextRepresentations) { + System.out.println(s); + } + System.out.println(); + } + } +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/RenameRelations.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/RenameRelations.java new file mode 100644 index 0000000..75e2740 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/RenameRelations.java @@ -0,0 +1,60 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.app; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.impl.XmiCasDeserializer; +import org.apache.uima.cas.impl.XmiCasSerializer; +import org.apache.uima.cas.text.AnnotationFS; +import org.xml.sax.SAXException; + +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class RenameRelations { + + public static void main(String[] args) throws Exception, SAXException, IOException { + + File inTrain = new File("C:\\Users\\mkrug\\TESTNewpluginPrepsystem\\RelationenDaten\\NECategoryTrain"); + File inTest = new File("C:\\Users\\mkrug\\TESTNewpluginPrepsystem\\RelationenDaten\\NECategoryTest"); + + CAS cas = Util_impl.createCas(); + + Map<String, String> renameMap = new HashMap<>(); + + renameMap.put("RELATION", "hatRelation"); + renameMap.put("hatFamilienteil", "hatFamilienRelation"); + renameMap.put("hatSchüler", "hatSchueler"); + renameMap.put("hatGroßelternteil", "hatGrosselternteil"); + + rename(inTrain, cas, renameMap); + rename(inTest, cas, renameMap); + } + + private static void rename(File in, CAS cas, Map<String, String> renameMap) throws SAXException, IOException, + FileNotFoundException { + for (File f : in.listFiles()) { + + XmiCasDeserializer.deserialize(new FileInputStream(f), cas); + + Util_impl util = new Util_impl(cas); + + for (AnnotationFS rel : cas.getAnnotationIndex(util.getRelationType())) { + + String relType = rel.getFeatureValueAsString(util.getRelationTypeFeature()); + + if (renameMap.containsKey(relType)) { + rel.setFeatureValueFromString(util.getRelationTypeFeature(), renameMap.get(relType)); + } + } + + XmiCasSerializer.serialize(cas, new FileOutputStream(new File(in.getAbsolutePath()) + "/" + f.getName())); + } + } + +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/RescaleRelationsMain.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/RescaleRelationsMain.java new file mode 100644 index 0000000..18ea911 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/RescaleRelationsMain.java @@ -0,0 +1,67 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.app; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.Feature; +import org.apache.uima.cas.impl.XmiCasDeserializer; +import org.apache.uima.cas.impl.XmiCasSerializer; +import org.apache.uima.cas.text.AnnotationFS; +import org.xml.sax.SAXException; + +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class RescaleRelationsMain { + + public static void main(String[] args) throws Exception, SAXException, IOException { + + File in = new File("C:\\Users\\mkrug\\TESTNewpluginPrepsystem\\RelationenDaten\\NECategory"); + File out = new File("C:\\Users\\mkrug\\TESTNewpluginPrepsystem\\RelationenDaten\\NECategory"); + + CAS cas = Util_impl.createCas(); + + for (File f : in.listFiles()) { + + XmiCasDeserializer.deserialize(new FileInputStream(f), cas); + + Util_impl util = new Util_impl(cas); + + List<AnnotationFS> rels = new ArrayList<>(); + + for (AnnotationFS a : cas.getAnnotationIndex(util.getRelationType())) { + rels.add(a); + } + for (AnnotationFS rel : rels) { + + AnnotationFS agens = (AnnotationFS) rel.getFeatureValue(util.getRelationAgensFeature()); + + AnnotationFS agens2 = (AnnotationFS) rel.getFeatureValue(util.getRelationAgens2Feature()); + + if (agens != null && agens2 != null) { + + // check if rel + int min = Math.min(agens2.getBegin(), agens.getBegin()); + int max = Math.max(agens.getEnd(), agens2.getEnd()); + + if (rel.getBegin() != min || rel.getEnd() != max) { + Feature begFeature = rel.getType().getFeatureByBaseName("begin"); + System.out.println(rel.getCoveredText()); + + Feature endFeature = rel.getType().getFeatureByBaseName("end"); + rel.setIntValue(begFeature, min); + rel.setIntValue(endFeature, max); + } + + } + + } + + XmiCasSerializer.serialize(cas, new FileOutputStream(new File(out.getAbsolutePath() + "/" + f.getName()))); + } + } +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/TestRepresentation.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/TestRepresentation.java new file mode 100644 index 0000000..68f786c --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/app/TestRepresentation.java @@ -0,0 +1,142 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.app; + +import java.io.File; +import java.io.FileInputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.impl.XmiCasDeserializer; +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mk.kall.relationResources.util.MentionPair; +import de.uniwue.mk.kall.relationResources.util.RelationUtil; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class TestRepresentation { + + public static void main(String[] args) throws Exception { + + File in = new File("C:\\\\Users\\\\mkrug\\\\TESTNewpluginPrepsystem\\\\RelationenDaten\\\\NECategory"); + + for (File f : in.listFiles()) { + if (f.isDirectory() || !f.getName().endsWith(".xmi")) + continue; + // System.out.println(f); + CAS cas = Util_impl.createCas(); + XmiCasDeserializer.deserialize(new FileInputStream(f), cas); + Util_impl util = new Util_impl(cas); + + List<MentionPair> createMentionPairs = createMentionPairs(cas); + + for (MentionPair pair : createMentionPairs) { + + int begin = pair.getNeFrom().getBegin(); + int end = pair.getNeTo().getEnd(); + List<AnnotationFS> covered = util.getCovered(begin, end, util.getDependencyType()); + + boolean containsVerb = false; + for (AnnotationFS tok : covered) { + + if (util.isVerb(tok)) { + containsVerb = true; + } + } + int amountOutside = determineEdgesOutOfTextChunk(covered, pair, begin, end, util); + if (amountOutside == 1 && !containsVerb) { + + Set<String> generatePathRepresentations = RelationUtil.generateTextRepresentations( + pair.getNeFrom(), pair.getNeTo()); + + // System.out.println(generatePathRepresentations.size()); + for (String s : generatePathRepresentations) + System.out.println(s); + } + } + + } + + } + + private static List<MentionPair> createMentionPairs(CAS cas) { + + List<MentionPair> pairs = new ArrayList<MentionPair>(); + // TODO also add <Indicator> -> Sprecher + + Util_impl util = new Util_impl(cas); + + // all inter-sentential + for (AnnotationFS sentence : cas.getAnnotationIndex(util.getSentenceType())) { + + List<AnnotationFS> covered = util.getCovered(sentence, util.getNamedEntityType()); + + for (int i = 0; i < covered.size(); i++) { + + AnnotationFS annoFrom = covered.get(i); + + inner: for (int j = i + 1; j < covered.size(); j++) { + + AnnotationFS annoTo = covered.get(j); + + MentionPair p = new MentionPair(annoFrom, annoTo); + // for (AMentionCreationFilter afilter : filter) { + // if (afilter.isInvalidPair(p)) + // break inner; + // } + + pairs.add(p); + + } + } + } + + return pairs; + } + + private static int determineEdgesOutOfTextChunk(List<AnnotationFS> covered, MentionPair pair, int begin, int end, + Util_impl util) { + int amountOutside = 0; + for (AnnotationFS tok : covered) { + + AnnotationFS father = util.getFather(tok); + + if (father == null) { + amountOutside++; + continue; + } + + // check if father is outside!! + if (father.getEnd() < begin || father.getBegin() > end) { + amountOutside++; + } + } + + // this results is often not correct because the parser has issues, + // but we can fix a little bit + + // inside a NE only 1 edge can leave the textspan + int amountEdgesSecondNe = 0; + + for (AnnotationFS tok : util.getCovered(pair.getNeTo(), util.getDependencyType())) { + AnnotationFS father = util.getFather(tok); + + if (father == null) { + amountEdgesSecondNe++; + continue; + } + + if (father.getEnd() < begin || father.getBegin() > end) { + amountEdgesSecondNe++; + } + + } + + // now correct that result + amountOutside = amountOutside - Math.max(1, amountEdgesSecondNe) + 1; + + return amountOutside; + + } + +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/filter/AMentionCreationFilter.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/filter/AMentionCreationFilter.java new file mode 100644 index 0000000..88c5e04 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/filter/AMentionCreationFilter.java @@ -0,0 +1,9 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.filter; + +import de.uniwue.mk.kall.relationResources.util.MentionPair; + +public abstract class AMentionCreationFilter { + + public abstract boolean isInvalidPair(MentionPair pair); + +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/filter/BothArePronounsFilter.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/filter/BothArePronounsFilter.java new file mode 100644 index 0000000..95491eb --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/filter/BothArePronounsFilter.java @@ -0,0 +1,22 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.filter; + +import org.apache.uima.cas.CAS; + +import de.uniwue.mk.kall.relationResources.util.MentionPair; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class BothArePronounsFilter extends AMentionCreationFilter { + + @Override + public boolean isInvalidPair(MentionPair pair) { + + CAS cas = pair.getCas(); + Util_impl util = new Util_impl(cas); + + if (util.isPronoun(pair.getNeFrom()) && util.isPronoun(pair.getNeTo())) { + return true; + } + return false; + } + +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/filter/FirstIsNotRelateableFilter.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/filter/FirstIsNotRelateableFilter.java new file mode 100644 index 0000000..c1f3031 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/filter/FirstIsNotRelateableFilter.java @@ -0,0 +1,26 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.filter; + +import de.uniwue.mk.kall.relationResources.util.MentionPair; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class FirstIsNotRelateableFilter extends AMentionCreationFilter { + + @Override + public boolean isInvalidPair(MentionPair pair) { + + Util_impl util = new Util_impl(pair.getCas()); + + if (util.isPronoun(pair.getNeFrom())) { + + String posTag = util.getPosTag(pair.getNeFrom()); + + if (posTag != null && posTag.matches("PRF")) + return true; + + } + + if (pair.getNeFrom().getCoveredText().toLowerCase().matches("du")) + return true; + return false; + } +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/filter/PluralFilter.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/filter/PluralFilter.java new file mode 100644 index 0000000..7fbfcd6 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/filter/PluralFilter.java @@ -0,0 +1,38 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.filter; + +import org.apache.uima.cas.CAS; +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mk.kall.relationResources.util.MentionPair; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class PluralFilter extends AMentionCreationFilter { + + @Override + public boolean isInvalidPair(MentionPair pair) { + + boolean firstPlural = isPlural(pair.getNeFrom()); + boolean secondPlural = isPlural(pair.getNeTo()); + + if (firstPlural || secondPlural) + return true; + + return false; + } + + private boolean isPlural(AnnotationFS neFrom) { + + CAS cas = neFrom.getCAS(); + Util_impl util = new Util_impl(cas); + for (AnnotationFS rf : util.getCovered(neFrom, util.getRFType())) { + + String value = rf.getFeatureValueAsString(util.getRFTagFeature()); + if (value.toLowerCase().contains(".pl.")) + return true; + + } + + return false; + } + +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/filter/SecondisNotRelateableFilter.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/filter/SecondisNotRelateableFilter.java new file mode 100644 index 0000000..e80b206 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/filter/SecondisNotRelateableFilter.java @@ -0,0 +1,27 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.filter; + +import de.uniwue.mk.kall.relationResources.util.MentionPair; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class SecondisNotRelateableFilter extends AMentionCreationFilter { + + @Override + public boolean isInvalidPair(MentionPair pair) { + + Util_impl util = new Util_impl(pair.getCas()); + + if (util.isPronoun(pair.getNeTo())) { + + String posTag = util.getPosTag(pair.getNeTo()); + + if (posTag != null && posTag.matches("PRELS|PRELAT|PRF|PPOSAT")) { + return true; + } + } + + if (pair.getNeTo().getCoveredText().toLowerCase().matches("mir|dir|ich|du")) { + return true; + } + return false; + } +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/ARelationDetectionRule.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/ARelationDetectionRule.java new file mode 100644 index 0000000..1d6b5e7 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/ARelationDetectionRule.java @@ -0,0 +1,9 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.firstpass.rules; + +import de.uniwue.mk.kall.relationResources.util.MentionPair; + +public abstract class ARelationDetectionRule { + + public abstract void apply(MentionPair pair); + +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/DefinitToSubjectRule.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/DefinitToSubjectRule.java new file mode 100644 index 0000000..f201439 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/DefinitToSubjectRule.java @@ -0,0 +1,137 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.firstpass.rules; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mk.kall.relationResources.util.MentionPair; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class DefinitToSubjectRule extends ARelationDetectionRule { + + private static final String TO_FROM = "2,1"; + private static final String FROM_TO = "1,2"; + Map<String, String> possessivesConstructs; + + public DefinitToSubjectRule() { + + possessivesConstructs = new HashMap<String, String>(); + + File preciseConstrcutsFolder = new File("possessives"); + for (File f : preciseConstrcutsFolder.listFiles()) { + try { + List<String> lines = Files.readAllLines(f.toPath()); + + for (String line : lines) { + if (line.isEmpty()) + continue; + if (line.split("\t").length == 1) + System.out.println(line); + possessivesConstructs.put(line.split("\t")[0], line.split("\t")[1]); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + @Override + public void apply(MentionPair pair) { + + Util_impl util = new Util_impl(pair.getCas()); + if (possessivesConstructs.containsKey(pair.getNeFrom().getCoveredText())) { + + checkForDefinitToSubject(pair.getNeFrom(), pair.getNeTo(), util, pair); + } + + if (possessivesConstructs.containsKey(pair.getNeTo().getCoveredText())) { + checkForDefinitToSubject(pair.getNeTo(), pair.getNeFrom(), util, pair); + } + } + + private void checkForDefinitToSubject(AnnotationFS relationIndicator, AnnotationFS potentialSubject, + Util_impl util, MentionPair pair) { + // covering chunk + boolean containsDefinitArticle = determineIfDefinitArticle(util, relationIndicator); + + if (containsDefinitArticle) { + + boolean isSubject = determineIfAccordingSubject(util, relationIndicator, potentialSubject); + + if (isSubject && !potentialSubject.getCoveredText().matches("wer|ihn|ihm") + && !relationIndicator.getCoveredText().matches("Kinde|Kind|Kindes|Kinder|Mann|Frau|Braut")) { + String[] split = possessivesConstructs.get(relationIndicator.getCoveredText()).split(";"); + + for (String s : split) { + + String relation = null; + if (s.contains(FROM_TO)) { + relation = s.split("\\(")[0]; + pair.setRelationFromTo(relation); + } + + else if (s.contains(TO_FROM)) { + relation = s.split("\\(")[0]; + pair.setRelationToFrom(relation); + } + + } + } + } + } + + private boolean determineIfAccordingSubject(Util_impl util, AnnotationFS relationIndicator, + AnnotationFS potentialSubject) { + // + if (!util.isSubject(potentialSubject)) + return false; + + // we just check the immediate verb + + List<AnnotationFS> potSubjectFather = new ArrayList<AnnotationFS>(); + for (AnnotationFS dep : util.getCovered(potentialSubject, util.getDependencyType())) { + AnnotationFS father = util.getFather(dep); + if (father != null && util.isVerb(father)) + potSubjectFather.add(father); + } + + for (AnnotationFS dep : util.getCovered(relationIndicator, util.getDependencyType())) { + if (potSubjectFather.contains(util.getFather(dep))) + return true; + } + return false; + } + + private boolean determineIfDefinitArticle(Util_impl util, AnnotationFS ne) { + + List<AnnotationFS> covered = util.getCovered(util.getCoveringChunk(ne), util.getRFType()); + for (AnnotationFS rf : covered) { + + String rfFeat = rf.getFeatureValueAsString(util.getRFTagFeature()); + + if (rfFeat.contains("ART.Def") || rf.getCoveredText().toLowerCase().matches("")) { + + // next token may not be in genitiv + AnnotationFS nextAnnotation = util.getNextAnnotation(covered.get(covered.size() - 1)); + + if (nextAnnotation != null) { + String rfFeatNext = nextAnnotation.getFeatureValueAsString(util.getRFTagFeature()); + + if (rfFeatNext.toLowerCase().contains(".gen.")) { + return false; + } + } + return true; + } + } + + return false; + } +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/DependencyPathRule.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/DependencyPathRule.java new file mode 100644 index 0000000..e3022b7 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/DependencyPathRule.java @@ -0,0 +1,76 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.firstpass.rules; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import de.uniwue.mk.kall.relationResources.util.MentionPair; + +public class DependencyPathRule extends ARelationDetectionRule { + + private static final String TO_FROM = "2,1"; + private static final String FROM_TO = "1,2"; + Map<String, String> dependencyPaths; + + public DependencyPathRule() { + + dependencyPaths = new HashMap<String, String>(); + + File preciseConstrcutsFolder = new File("dependencypath"); + for (File f : preciseConstrcutsFolder.listFiles()) { + try { + List<String> lines = Files.readAllLines(f.toPath()); + + for (String line : lines) { + if (line.isEmpty()) + continue; + + if (line.split("\t").length == 1) + System.out.println(line); + dependencyPaths.put(line.split("\t")[0], line.split("\t")[1]); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + @Override + public void apply(MentionPair pair) { + + List<String> representations = pair.getDependencyPathRepresentations(); + + for (String ss : representations) { + + if (dependencyPaths.containsKey(ss)) { + + String[] split = dependencyPaths.get(ss).split(";"); + + for (String s : split) { + + String relation = null; + if (s.contains(FROM_TO)) { + relation = s.split("\\(")[0]; + pair.setRelationFromTo(relation); + } + + else if (s.contains(TO_FROM)) { + relation = s.split("\\(")[0]; + pair.setRelationToFrom(relation); + } + + } + } + } + + if (!pair.isResolved()) { + // System.out.println(pair.getTextAndBetween()); + } + + } + +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/LookiLookiDetectionRule.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/LookiLookiDetectionRule.java new file mode 100644 index 0000000..91410ab --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/LookiLookiDetectionRule.java @@ -0,0 +1,17 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.firstpass.rules; + +import de.uniwue.mk.kall.relationResources.util.MentionPair; + +public class LookiLookiDetectionRule extends ARelationDetectionRule { + + @Override + public void apply(MentionPair pair) { + + System.out.println(pair.getCas().getDocumentText() + .substring(pair.getNeFrom().getBegin(), pair.getNeTo().getEnd()).replaceAll("\\s+", " ")); + + System.out.println("==="); + + } + +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/MatrixPathsRelationRule.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/MatrixPathsRelationRule.java new file mode 100644 index 0000000..26b6440 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/MatrixPathsRelationRule.java @@ -0,0 +1,89 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.firstpass.rules; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import de.uniwue.mk.kall.relationResources.util.MentionPair; +import de.uniwue.mk.kall.ruleBasedRelationClassification.instructions.AConversionInsruction; +import de.uniwue.mk.kall.ruleBasedRelationClassification.instructions.ChunkTypeConversionINstruction; +import de.uniwue.mk.kall.ruleBasedRelationClassification.instructions.NETypeConversionINstruction; +import de.uniwue.mk.kall.ruleBasedRelationClassification.instructions.ToDepRelConversionInstruction; +import de.uniwue.mk.kall.ruleBasedRelationClassification.instructions.ToGermanNetConversionInstruction; +import de.uniwue.mk.kall.ruleBasedRelationClassification.instructions.ToLemmaConversionInstruction; +import de.uniwue.mk.kall.ruleBasedRelationClassification.instructions.ToPOSConversionInstruction; +import de.uniwue.mk.kall.ruleBasedRelationClassification.instructions.ToPureTextConversionInstruction; +import de.uniwue.mk.kall.ruleBasedRelationClassification.instructions.ToW2VConversionInstruction; +import de.uniwue.mk.kall.ruleBasedRelationClassification.matrix.structs.SentenceElementMatrix; +import de.uniwue.mk.kall.ruleBasedRelationClassification.matrix.structs.SentenceMatrixFactory; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class MatrixPathsRelationRule extends ARelationDetectionRule { + + private static final String TO_FROM = "2,1"; + private static final String FROM_TO = "1,2"; + Map<String, String> matrixPathConstructs; + private List<AConversionInsruction> instructionsTokens; + private List<AConversionInsruction> instructionsNEs; + + public MatrixPathsRelationRule() { + + matrixPathConstructs = new HashMap<String, String>(); + + File preciseConstrcutsFolder = new File("matrixPaths"); + for (File f : preciseConstrcutsFolder.listFiles()) { + try { + List<String> lines = Files.readAllLines(f.toPath()); + + for (String line : lines) { + if (line.isEmpty()) + continue; + matrixPathConstructs.put(line.split("\t")[0], line.split("\t")[1]); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + instructionsTokens = new ArrayList<AConversionInsruction>(); + instructionsTokens.add(new ToPureTextConversionInstruction()); + instructionsTokens.add(new ToLemmaConversionInstruction()); + instructionsTokens.add(new ToPOSConversionInstruction()); + instructionsTokens.add(new ToDepRelConversionInstruction()); + instructionsTokens.add(new ChunkTypeConversionINstruction()); + instructionsTokens.add(new ToGermanNetConversionInstruction()); + instructionsTokens.add(new ToW2VConversionInstruction()); + // instructionsTokens.add(new ToNullConversionInstruction()); + + instructionsNEs = new ArrayList<AConversionInsruction>(); + instructionsNEs.add(new ToPureTextConversionInstruction()); + instructionsNEs.add(new NETypeConversionINstruction()); + } + + @Override + public void apply(MentionPair pair) { + + List<SentenceElementMatrix> createAndReduce = SentenceMatrixFactory.createAndReduce(pair.getCas(), + new Util_impl(pair.getCas()), pair.getNeFrom(), pair.getNeTo(), instructionsNEs, instructionsTokens); + + // check if our map contains at least one of those!! + + for (String s : matrixPathConstructs.keySet()) { + for (SentenceElementMatrix matrix : createAndReduce) { + + if (matrix.hasMatrixPath(s)) { + // TODO we found a valid path => apply the actions + // System.out.println(s); + // System.out.println(matrix); + } + + } + } + + } +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/PossessivesRelationRule.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/PossessivesRelationRule.java new file mode 100644 index 0000000..0e89ba5 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/PossessivesRelationRule.java @@ -0,0 +1,111 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.firstpass.rules; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Pattern; + +import org.apache.uima.cas.text.AnnotationFS; + +import de.uniwue.mk.kall.relationResources.util.MentionPair; +import de.uniwue.mkrug.kall.typesystemutil.Util_impl; + +public class PossessivesRelationRule extends ARelationDetectionRule { + + private static final String TO_FROM = "2,1"; + private static final String FROM_TO = "1,2"; + Map<String, String> possessivesConstructs; + + public PossessivesRelationRule() { + + possessivesConstructs = new HashMap<String, String>(); + + File preciseConstrcutsFolder = new File("possessives"); + for (File f : preciseConstrcutsFolder.listFiles()) { + try { + List<String> lines = Files.readAllLines(f.toPath()); + + for (String line : lines) { + if (line.isEmpty()) + continue; + if (line.split("\t").length == 1) + System.out.println(line); + possessivesConstructs.put(line.split("\t")[0], line.split("\t")[1]); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + @Override + public void apply(MentionPair pair) { + + Util_impl util = new Util_impl(pair.getCas()); + + if (!util.isPronoun(pair.getNeFrom())) + return; + // assure nefrom is a possessive + String posTag = util.getPosTag(pair.getNeFrom()); + if (posTag != null && !posTag.matches("PPOSAT|PRELAT") + && !pair.getNeFrom().getCoveredText().toLowerCase().matches("deren|dessen")) + return; + + // TODO force that whenever another NE is inbetween we have a + // conjunction + + String textBetween = pair.getTextAndBetween(); + // replace the second with the reduced form + textBetween = textBetween.replaceAll(Pattern.quote(pair.getNeTo().getCoveredText()), pair.getNameNoCoreTo()); + textBetween = textBetween.replaceAll("\\s+", " ").trim(); + List<AnnotationFS> covered = util.getCovered(pair.getNeFrom().getBegin(), pair.getNeTo().getEnd(), + util.getNamedEntityType()); + + if (covered.size() > 2) { + + // we need to have a KONJ in between + boolean conjFound = false; + for (AnnotationFS tok : util.getCovered(pair.getNeFrom().getBegin(), pair.getNeTo().getEnd(), + util.getPOSType())) { + + if (util.getPosTag(tok).matches("KON")) + conjFound = true; + + } + + if (!conjFound) + return; + } + + String between = pair.getTextBetween(); + if (between.trim().isEmpty() && !possessivesConstructs.containsKey(pair.getNameNoCoreTo())) { + } + + if (possessivesConstructs.keySet().contains(pair.getNameNoCoreTo())) { + + String[] split = possessivesConstructs.get(pair.getNameNoCoreTo()).split(";"); + + for (String s : split) { + + String relation = null; + if (s.contains(FROM_TO)) { + relation = s.split("\\(")[0]; + pair.setRelationFromTo(relation); + } + + else if (s.contains(TO_FROM)) { + relation = s.split("\\(")[0]; + pair.setRelationToFrom(relation); + } + + } + } else { + // System.out.println(textBetween); + + } + } +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/PreciseConstructsRule.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/PreciseConstructsRule.java new file mode 100644 index 0000000..1547a51 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/PreciseConstructsRule.java @@ -0,0 +1,76 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.firstpass.rules; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import de.uniwue.mk.kall.relationResources.util.MentionPair; + +public class PreciseConstructsRule extends ARelationDetectionRule { + + private static final String TO_FROM = "2,1"; + private static final String FROM_TO = "1,2"; + Map<String, String> preciseConstructs; + + public PreciseConstructsRule() { + + preciseConstructs = new HashMap<String, String>(); + + File preciseConstrcutsFolder = new File("preciseConstructs"); + for (File f : preciseConstrcutsFolder.listFiles()) { + try { + List<String> lines = Files.readAllLines(f.toPath()); + + for (String line : lines) { + if (line.isEmpty()) + continue; + + if (line.split("\t").length == 1) + System.out.println(line); + preciseConstructs.put(line.split("\t")[0], line.split("\t")[1]); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + @Override + public void apply(MentionPair pair) { + + List<String> representations = pair.getAllRepresentations(); + + for (String ss : representations) { + + if (preciseConstructs.containsKey(ss)) { + + String[] split = preciseConstructs.get(ss).split(";"); + + for (String s : split) { + + String relation = null; + if (s.contains(FROM_TO)) { + relation = s.split("\\(")[0]; + pair.setRelationFromTo(relation); + } + + else if (s.contains(TO_FROM)) { + relation = s.split("\\(")[0]; + pair.setRelationToFrom(relation); + } + + } + } + } + + if (!pair.isResolved()) { + // System.out.println(pair.getTextAndBetween()); + } + + } + +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/RepresentationNPRule.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/RepresentationNPRule.java new file mode 100644 index 0000000..ab93390 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/firstpass/rules/RepresentationNPRule.java @@ -0,0 +1,76 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.firstpass.rules; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import de.uniwue.mk.kall.relationResources.util.MentionPair; +import de.uniwue.mk.kall.relationResources.util.RelationUtil; + +public class RepresentationNPRule extends ARelationDetectionRule { + + private static final String TO_FROM = "2,1"; + private static final String FROM_TO = "1,2"; + Map<String, String> preciseConstructs; + + public RepresentationNPRule() { + + preciseConstructs = new HashMap<String, String>(); + + File preciseConstrcutsFolder = new File("relationGeneral"); + for (File f : preciseConstrcutsFolder.listFiles()) { + try { + List<String> lines = Files.readAllLines(f.toPath()); + + for (String line : lines) { + if (line.isEmpty() || line.startsWith("//")) + continue; + + if (line.split("\t").length == 1) + System.out.println(line); + preciseConstructs.put(line.split("\t")[0], line.split("\t")[1]); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + @Override + public void apply(MentionPair pair) { + + Set<String> representations = RelationUtil.generateAllRepresentations(pair.getNeFrom(), pair.getNeTo()); + + for (String ss : representations) { + if (preciseConstructs.containsKey(ss)) { + + String[] split = preciseConstructs.get(ss).split(";"); + + for (String s : split) { + + String relation = null; + if (s.contains(FROM_TO)) { + relation = s.split("\\(")[0]; + pair.setRelationFromTo(relation); + } + + else if (s.contains(TO_FROM)) { + relation = s.split("\\(")[0]; + pair.setRelationToFrom(relation); + } + + } + } + } + + if (!pair.isResolved()) { + // System.out.println(pair.getTextAndBetween()); + } + } + +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/struct/IndicatorSets.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/struct/IndicatorSets.java new file mode 100644 index 0000000..8153720 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/de/uniwue/mk/kall/ruleBasedRelationClassification/struct/IndicatorSets.java @@ -0,0 +1,23 @@ +package de.uniwue.mk.kall.ruleBasedRelationClassification.struct; + +import java.util.HashSet; +import java.util.Set; + +public class IndicatorSets { + + // Vater + public static Set<String> fatherSet; + + static { + fatherSet = new HashSet<String>(); + fatherSet.add("Vater"); + } + + // Mutter + public static Set<String> motherSet; + + static { + motherSet = new HashSet<String>(); + motherSet.add("Mutter"); + } +} diff --git a/de.uniwue.mk.kall.ruleBasedRelationClassification/src/util/RescaleRelations.java b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/util/RescaleRelations.java new file mode 100644 index 0000000..c9987d7 --- /dev/null +++ b/de.uniwue.mk.kall.ruleBasedRelationClassification/src/util/RescaleRelations.java @@ -0,0 +1,12 @@ +package util; + +import java.io.File; + +public class RescaleRelations { + + public static void main(String[] args) { + + File in = new File(""); + } + +} -- GitLab