forked from D-Net/dnet-hadoop
Merge pull request '[Graph Dump] fixed issue on extraction of relation between entities and contexts: the relationship name and type were swapped' (#176) from dump into beta
Reviewed-on: D-Net/dnet-hadoop#176
This commit is contained in:
commit
5c4fee3533
|
@ -89,7 +89,7 @@ public class Extractor implements Serializable {
|
||||||
value.getId(), contextId,
|
value.getId(), contextId,
|
||||||
Constants.RESULT_ENTITY,
|
Constants.RESULT_ENTITY,
|
||||||
Constants.CONTEXT_ENTITY,
|
Constants.CONTEXT_ENTITY,
|
||||||
ModelConstants.RELATIONSHIP, ModelConstants.IS_RELATED_TO, provenance);
|
ModelConstants.IS_RELATED_TO, ModelConstants.RELATIONSHIP, provenance);
|
||||||
if (!hashCodes.contains(r.hashCode())) {
|
if (!hashCodes.contains(r.hashCode())) {
|
||||||
relationList
|
relationList
|
||||||
.add(r);
|
.add(r);
|
||||||
|
@ -99,8 +99,8 @@ public class Extractor implements Serializable {
|
||||||
contextId, value.getId(),
|
contextId, value.getId(),
|
||||||
Constants.CONTEXT_ENTITY,
|
Constants.CONTEXT_ENTITY,
|
||||||
Constants.RESULT_ENTITY,
|
Constants.RESULT_ENTITY,
|
||||||
ModelConstants.RELATIONSHIP,
|
ModelConstants.IS_RELATED_TO,
|
||||||
ModelConstants.IS_RELATED_TO, provenance);
|
ModelConstants.RELATIONSHIP, provenance);
|
||||||
if (!hashCodes.contains(r.hashCode())) {
|
if (!hashCodes.contains(r.hashCode())) {
|
||||||
relationList
|
relationList
|
||||||
.add(
|
.add(
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.spark.SparkConf;
|
import org.apache.spark.SparkConf;
|
||||||
import org.apache.spark.api.java.JavaRDD;
|
import org.apache.spark.api.java.JavaRDD;
|
||||||
import org.apache.spark.api.java.JavaSparkContext;
|
import org.apache.spark.api.java.JavaSparkContext;
|
||||||
|
import org.apache.spark.api.java.function.FilterFunction;
|
||||||
import org.apache.spark.sql.Encoders;
|
import org.apache.spark.sql.Encoders;
|
||||||
import org.apache.spark.sql.SparkSession;
|
import org.apache.spark.sql.SparkSession;
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.*;
|
||||||
|
@ -96,6 +97,76 @@ public class ExtractRelationFromEntityTest {
|
||||||
9,
|
9,
|
||||||
verificationDataset.filter("source.id = '50|dedup_wf_001::15270b996fa8fd2fb5723daxab3685c3'").count());
|
verificationDataset.filter("source.id = '50|dedup_wf_001::15270b996fa8fd2fb5723daxab3685c3'").count());
|
||||||
|
|
||||||
|
Assertions
|
||||||
|
.assertEquals(
|
||||||
|
"IsRelatedTo", verificationDataset
|
||||||
|
.filter((FilterFunction<Relation>) row -> row.getSource().getId().startsWith("00"))
|
||||||
|
.collectAsList()
|
||||||
|
.get(0)
|
||||||
|
.getReltype()
|
||||||
|
.getName());
|
||||||
|
|
||||||
|
Assertions
|
||||||
|
.assertEquals(
|
||||||
|
"relationship", verificationDataset
|
||||||
|
.filter((FilterFunction<Relation>) row -> row.getSource().getId().startsWith("00"))
|
||||||
|
.collectAsList()
|
||||||
|
.get(0)
|
||||||
|
.getReltype()
|
||||||
|
.getType());
|
||||||
|
|
||||||
|
Assertions
|
||||||
|
.assertEquals(
|
||||||
|
"context", verificationDataset
|
||||||
|
.filter((FilterFunction<Relation>) row -> row.getSource().getId().startsWith("00"))
|
||||||
|
.collectAsList()
|
||||||
|
.get(0)
|
||||||
|
.getSource()
|
||||||
|
.getType());
|
||||||
|
|
||||||
|
Assertions
|
||||||
|
.assertEquals(
|
||||||
|
"result", verificationDataset
|
||||||
|
.filter((FilterFunction<Relation>) row -> row.getSource().getId().startsWith("00"))
|
||||||
|
.collectAsList()
|
||||||
|
.get(0)
|
||||||
|
.getTarget()
|
||||||
|
.getType());
|
||||||
|
Assertions
|
||||||
|
.assertEquals(
|
||||||
|
"IsRelatedTo", verificationDataset
|
||||||
|
.filter((FilterFunction<Relation>) row -> row.getTarget().getId().startsWith("00"))
|
||||||
|
.collectAsList()
|
||||||
|
.get(0)
|
||||||
|
.getReltype()
|
||||||
|
.getName());
|
||||||
|
|
||||||
|
Assertions
|
||||||
|
.assertEquals(
|
||||||
|
"relationship", verificationDataset
|
||||||
|
.filter((FilterFunction<Relation>) row -> row.getTarget().getId().startsWith("00"))
|
||||||
|
.collectAsList()
|
||||||
|
.get(0)
|
||||||
|
.getReltype()
|
||||||
|
.getType());
|
||||||
|
|
||||||
|
Assertions
|
||||||
|
.assertEquals(
|
||||||
|
"context", verificationDataset
|
||||||
|
.filter((FilterFunction<Relation>) row -> row.getTarget().getId().startsWith("00"))
|
||||||
|
.collectAsList()
|
||||||
|
.get(0)
|
||||||
|
.getTarget()
|
||||||
|
.getType());
|
||||||
|
|
||||||
|
Assertions
|
||||||
|
.assertEquals(
|
||||||
|
"result", verificationDataset
|
||||||
|
.filter((FilterFunction<Relation>) row -> row.getTarget().getId().startsWith("00"))
|
||||||
|
.collectAsList()
|
||||||
|
.get(0)
|
||||||
|
.getSource()
|
||||||
|
.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue