You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by jo...@apache.org on 2019/01/11 10:41:43 UTC
[opennlp-sandbox] branch relex created (now b5f228f)
This is an automated email from the ASF dual-hosted git repository.
joern pushed a change to branch relex
in repository https://gitbox.apache.org/repos/asf/opennlp-sandbox.git.
at b5f228f Add first draft of relex
This branch includes the following new commits:
new b5f228f Add first draft of relex
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[opennlp-sandbox] 01/01: Add first draft of relex
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
joern pushed a commit to branch relex
in repository https://gitbox.apache.org/repos/asf/opennlp-sandbox.git
commit b5f228f20c50e183af9f9bf2f11c6f8c486f7d26
Author: Jörn Kottmann <jo...@apache.org>
AuthorDate: Wed Jul 4 12:24:30 2018 +0200
Add first draft of relex
---
.../org/apache/opennlp/relex/EntityMention.java | 24 +++++++++++++++
.../java/org/apache/opennlp/relex/Relation.java | 14 +++++++++
.../apache/opennlp/relex/RelationExtractor.java | 12 ++++++++
tf-ner-poc/src/main/python/relex/relex.py | 35 ++++++++++++++++++++++
4 files changed, 85 insertions(+)
diff --git a/tf-ner-poc/src/main/java/org/apache/opennlp/relex/EntityMention.java b/tf-ner-poc/src/main/java/org/apache/opennlp/relex/EntityMention.java
new file mode 100644
index 0000000..fdc2d94
--- /dev/null
+++ b/tf-ner-poc/src/main/java/org/apache/opennlp/relex/EntityMention.java
@@ -0,0 +1,24 @@
+package org.apache.opennlp.relex;
+
+import java.util.Objects;
+
+import opennlp.tools.parser.Parse;
+
+public class EntityMention {
+
+ private final Parse parse;
+ private final int entityId;
+
+ public EntityMention(Parse parse, int entityId) {
+ this.parse = Objects.requireNonNull(parse);
+ this.entityId = entityId;
+ }
+
+ public Parse getParse() {
+ return parse;
+ }
+
+ public int getEntityId() {
+ return entityId;
+ }
+}
diff --git a/tf-ner-poc/src/main/java/org/apache/opennlp/relex/Relation.java b/tf-ner-poc/src/main/java/org/apache/opennlp/relex/Relation.java
new file mode 100644
index 0000000..68602ec
--- /dev/null
+++ b/tf-ner-poc/src/main/java/org/apache/opennlp/relex/Relation.java
@@ -0,0 +1,14 @@
+package org.apache.opennlp.relex;
+
+public class Relation {
+
+ private final int subject;
+ private final String predicate;
+ private final int object;
+
+ public Relation(int subject, String predicate, int object) {
+ this.subject = subject;
+ this.predicate = predicate;
+ this.object = object;
+ }
+}
diff --git a/tf-ner-poc/src/main/java/org/apache/opennlp/relex/RelationExtractor.java b/tf-ner-poc/src/main/java/org/apache/opennlp/relex/RelationExtractor.java
new file mode 100644
index 0000000..c371d3c
--- /dev/null
+++ b/tf-ner-poc/src/main/java/org/apache/opennlp/relex/RelationExtractor.java
@@ -0,0 +1,12 @@
+package org.apache.opennlp.relex;
+
+public class RelationExtractor {
+
+ // TODO: This type of interface would limit the extractor to look
+ // only at sentences that contains entities.
+ // This is borrowed from the old coref component.
+
+ public Relation[] extract(EntityMention[] mentions) {
+ return null;
+ }
+}
diff --git a/tf-ner-poc/src/main/python/relex/relex.py b/tf-ner-poc/src/main/python/relex/relex.py
new file mode 100644
index 0000000..62ca965
--- /dev/null
+++ b/tf-ner-poc/src/main/python/relex/relex.py
@@ -0,0 +1,35 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import tensorflow as tf
+
+
+# load_date
+# which format ??? we could write some java tool to extract data from brat corpus
+# and export it into a format that can be used easier to train the tool
+
+
+def main():
+ pass
+
+def create_graph():
+ pass
+
+if __name__ == "__main__":
+ main()