org.apache.jena.rdf.model.Model.isIsomorphicWith()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(12.1k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中org.apache.jena.rdf.model.Model.isIsomorphicWith()方法的一些代码示例,展示了Model.isIsomorphicWith()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Model.isIsomorphicWith()方法的具体详情如下:
包路径:org.apache.jena.rdf.model.Model
类名称:Model
方法名:isIsomorphicWith

Model.isIsomorphicWith介绍

[英]Compare this Model with another for equality ignoring the labels on bNodes. See RDF Concepts.

Two models are isomorphic when each statement in one can be matched with a statement in the other. Statements which are identical match.

Special treatment is given to anonymous nodes. A binding is a one to one mapping which maps each anonymous node in this model to an anonymous node in model. Two statements s1 and s2 match under a binding if s1.subject is anonymous and s2.subject is anonymous and the binding maps s1.subject to s2.subject.

Two models are isomorphic if there is a binding that allows all the statements in one model to match a a statement in the other.
[中]将此模型与另一个模型进行比较,以便忽略B节点上的标签。见RDF Concepts
当一个模型中的每个语句可以与另一个模型中的语句匹配时,两个模型是同构的。相同的语句匹配。
对匿名节点进行特殊处理。绑定是一种一对一的映射,它将this模型中的每个匿名节点映射到model模型中的一个匿名节点。两条语句s1和s2在绑定下匹配,如果s1。主题为匿名和s2。主题是匿名的,绑定映射为s1。以s2为准。主题
如果存在允许一个模型中的所有语句与另一个模型中的语句匹配的绑定,则两个模型是同构的。

代码示例

代码示例来源:origin: apache/jena

@Test public void dataset_03() {
  Dataset ds = createDataset();
  ds.setDefaultModel(model2);
  assertTrue(model2.isIsomorphicWith(ds.getDefaultModel()));
}

代码示例来源:origin: apache/jena

@Test
public void testEquality() throws Exception {
  Model ttl = ModelFactory.createDefaultModel().read(getTTLInput(), NS,
      "TTL");
  Model rdf = ModelFactory.createDefaultModel().read(getRDFInput(), NS,
      "RDF/XML-ABBREV");
  assertTrue(ttl.isIsomorphicWith(rdf));
  assertTrue(rdf.isIsomorphicWith(ttl));
}

代码示例来源:origin: org.apache.jena/jena-core

@Test
public void testEquality() throws Exception {
  Model ttl = ModelFactory.createDefaultModel().read(getTTLInput(), NS,
      "TTL");
  Model rdf = ModelFactory.createDefaultModel().read(getRDFInput(), NS,
      "RDF/XML-ABBREV");
  assertTrue(ttl.isIsomorphicWith(rdf));
  assertTrue(rdf.isIsomorphicWith(ttl));
}

代码示例来源:origin: apache/jena

/**
 * Test that we do not use an "" prefix in @Context.
 */
@Test public final void noEmptyPrefixInContext() {
  String ns = "http://www.a.com/foo/";
  Model m = simpleModel(ns);
  m.setNsPrefix("", ns);
  String jsonld = toString(m, RDFFormat.JSONLD_COMPACT_PRETTY, null);
  assertFalse(jsonld.contains("\"\""));
  Model m2 = parse(jsonld);
  assertTrue(m2.isIsomorphicWith(m));
}

代码示例来源:origin: apache/jena

@Test
public void rdfjson_read_simple_plainliteral_object()
{
  String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"literal\" , \"value\" : \"some text\" } ] } }" ;
  String s2 = "<http://example.org/subject> <http://example.org/predicate> \"some text\" ." ;
  assertEquals(1, parseCount(s)) ;
  Model m = parseToModelRdfJson(s) ;
  Model m2 = parseToModelNTriples(s2) ;
  assertTrue(m.isIsomorphicWith(m2)) ;
}

代码示例来源:origin: apache/jena

@Test
public void rdfjson_read_simple_typedliteral_object()
{
  String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"literal\" , \"value\" : \"some text\", \"datatype\" : \"http://example.org/datatype\" } ] } }" ;
  String s2 = "<http://example.org/subject> <http://example.org/predicate> \"some text\"^^<http://example.org/datatype> ." ;
  assertEquals(1, parseCount(s)) ;
  Model m = parseToModelRdfJson(s) ;
  Model m2 = parseToModelNTriples(s2) ;
  assertTrue(m.isIsomorphicWith(m2)) ;
}

代码示例来源:origin: apache/jena

@Test
public void rdfjson_read_predicatelist()
{
  String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"uri\" , \"value\" : \"http://example.org/object\" } ] , \"http://example.org/predicate2\" : [ { \"type\" : \"uri\" , \"value\" : \"http://example.org/object\" } ] } }" ;
  String s2 = "<http://example.org/subject> <http://example.org/predicate> <http://example.org/object> .\n"
       + "<http://example.org/subject> <http://example.org/predicate2> <http://example.org/object> ." ;
  assertEquals(2, parseCount(s)) ;
  Model m = parseToModelRdfJson(s) ;
  Model m2 = parseToModelNTriples(s2) ;
  assertTrue(m.isIsomorphicWith(m2)) ;
}

代码示例来源:origin: apache/jena

@Test
public void rdfjson_read_subjectlist()
{
  String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"uri\" , \"value\" : \"http://example.org/object\" } ] } , \"http://example.org/subject2\" : { \"http://example.org/predicate\" : [ { \"type\" : \"uri\" , \"value\" : \"http://example.org/object\" } ] } }" ;
  String s2 = "<http://example.org/subject> <http://example.org/predicate> <http://example.org/object> .\n"
       + "<http://example.org/subject2> <http://example.org/predicate> <http://example.org/object> ." ;
  assertEquals(2, parseCount(s)) ;
  Model m = parseToModelRdfJson(s) ;
  Model m2 = parseToModelNTriples(s2) ;
  assertTrue(m.isIsomorphicWith(m2)) ;
}

代码示例来源:origin: apache/jena

/**
 * Test the identity transform - RDF/XML to RDF/XML
 */
@Test
public void testRdfcatIdentity() {
  Model source = ModelFactory.createDefaultModel();
  source.read( "file:testing/cmd/rdfcat.xml", "RDF/XML" );
  OutputStream so = new ByteArrayOutputStream();
  rdfcatFixture rc = new rdfcatFixture( so );
  rc.testGo( new String[] {"file:testing/cmd/rdfcat.xml"} );
  Model output = asModel( so, "RDF/XML" );
  assertTrue( output.isIsomorphicWith( source ));
}

代码示例来源:origin: apache/jena

@Test
public void rdfjson_read_empty_graph()
{
  String s = "{}" ;
  String s2 = "" ;
  assertEquals(0, parseCount(s)) ;
  Model m = parseToModelRdfJson(s) ;
  Model m2 = parseToModelNTriples(s2) ;
  assertTrue(m.isIsomorphicWith(m2)) ;
}

代码示例来源:origin: apache/jena

@Test
public void rdfjson_read_objectlist_uris()
{
  String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"uri\" , \"value\" : \"http://example.org/object\" } , { \"type\" : \"uri\" , \"value\" : \"http://example.org/object2\" } ] } }" ;
  String s2 = "<http://example.org/subject> <http://example.org/predicate> <http://example.org/object> .\n"
       + "<http://example.org/subject> <http://example.org/predicate> <http://example.org/object2> ." ;
  assertEquals(2, parseCount(s)) ;
  Model m = parseToModelRdfJson(s) ;
  Model m2 = parseToModelNTriples(s2) ;
  assertTrue(m.isIsomorphicWith(m2)) ;
}

代码示例来源:origin: apache/jena

@Test
public void rdfjson_read_objectlist_literals()
{
  String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"literal\" , \"value\" : \"some text\" } , { \"type\" : \"literal\" , \"value\" : \"more text\" } ] } }" ;
  String s2 = "<http://example.org/subject> <http://example.org/predicate> \"some text\" .\n"
       + "<http://example.org/subject> <http://example.org/predicate> \"more text\" ." ;
  assertEquals(2, parseCount(s)) ;
  Model m = parseToModelRdfJson(s) ;
  Model m2 = parseToModelNTriples(s2) ;
  assertTrue(m.isIsomorphicWith(m2)) ;
}

代码示例来源:origin: apache/jena

@Test
public void rdfjson_read_bnode_identity2()
{
  String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"bnode\" , \"value\" : \"_:id\" } ] , \"http://example.org/predicate2\" : [ { \"type\" : \"bnode\" , \"value\" : \"_:id\" } ] } }" ;
  String s2 = "<http://example.org/subject> <http://example.org/predicate> _:id ."
       + "<http://example.org/subject> <http://example.org/predicate2> _:id ." ;
  assertEquals(2, parseCount(s)) ;
  Model m = parseToModelRdfJson(s) ;
  Model m2 = parseToModelNTriples(s2) ;
  assertTrue(m.isIsomorphicWith(m2)) ;
}

代码示例来源:origin: apache/jena

@Test
public void rdfjson_read_simple_uri_object()
{
  String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"uri\" , \"value\" : \"http://example.org/object\" } ] } }" ;
  String s2 = "<http://example.org/subject> <http://example.org/predicate> <http://example.org/object> ." ;
  assertEquals(1, parseCount(s)) ;
  Model m = parseToModelRdfJson(s) ;
  Model m2 = parseToModelNTriples(s2) ;
  assertTrue(m.isIsomorphicWith(m2)) ;
}

代码示例来源:origin: apache/jena

@Test
public void rdfjson_read_simple_bnode_subject()
{
  String s = "{ \"_:id\" : { \"http://example.org/predicate\" : [ { \"type\" : \"uri\" , \"value\" : \"http://example.org/object\" } ] } }" ;
  String s2 = "_:id <http://example.org/predicate> <http://example.org/object> ." ;
  assertEquals(1, parseCount(s)) ;
  Model m = parseToModelRdfJson(s) ;
  Model m2 = parseToModelNTriples(s2) ;
  assertTrue(m.isIsomorphicWith(m2)) ;
}

代码示例来源:origin: apache/jena

@Test
public void rdfjson_read_simple_langliteral_object()
{
  String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"literal\" , \"value\" : \"some text\", \"lang\" : \"en-gb\" } ] } }" ;
  String s2 = "<http://example.org/subject> <http://example.org/predicate> \"some text\"@en-gb ." ;
  assertEquals(1, parseCount(s)) ;
  Model m = parseToModelRdfJson(s) ;
  Model m2 = parseToModelNTriples(s2) ;
  assertTrue(m.isIsomorphicWith(m2)) ;
}

代码示例来源:origin: apache/jena

@Test
public void rdfjson_read_objectlist_bnodes()
{
  String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"bnode\" , \"value\" : \"_:one\" } , { \"type\" : \"bnode\" , \"value\" : \"_:two\" } ] } }" ;
  String s2 = "<http://example.org/subject> <http://example.org/predicate> _:a .\n"
       + "<http://example.org/subject> <http://example.org/predicate> _:b ." ;
  assertEquals(2, parseCount(s)) ;
  Model m = parseToModelRdfJson(s) ;
  Model m2 = parseToModelNTriples(s2) ;
  assertTrue(m.isIsomorphicWith(m2)) ;
}

代码示例来源:origin: apache/jena

@Test
public void rdfjson_read_objectlist_mixed()
{
  String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"uri\" , \"value\" : \"http://example.org/object\" } , { \"type\" : \"literal\" , \"value\" : \"some text\" } , { \"type\" : \"bnode\" , \"value\" : \"_:id\" } ] } }" ;
  String s2 = "<http://example.org/subject> <http://example.org/predicate> <http://example.org/object> .\n"
       + "<http://example.org/subject> <http://example.org/predicate> \"some text\" .\n"
       + "<http://example.org/subject> <http://example.org/predicate> _:id ." ;
  assertEquals(3, parseCount(s)) ;
  Model m = parseToModelRdfJson(s) ;
  Model m2 = parseToModelNTriples(s2) ;
  assertTrue(m.isIsomorphicWith(m2)) ;
}

代码示例来源:origin: apache/jena

/**
 * Test the basic concatenation
 */
@Test
public void testRdfcatConcat() {
  Model source = ModelFactory.createDefaultModel();
  source.read( "file:testing/cmd/rdfcat.xml", "RDF/XML" );
  OutputStream so = new ByteArrayOutputStream();
  rdfcatFixture rc = new rdfcatFixture( so );
  rc.testGo( new String[] {"file:testing/cmd/rdfcat_1.xml", "file:testing/cmd/rdfcat_2.xml"} );
  Model output = asModel( so, "RDF/XML" );
  assertTrue( output.isIsomorphicWith( source ));
}

代码示例来源:origin: apache/jena

@Test
public void rdfjson_read_simple_bnode_object()
{
  String s = "{ \"http://example.org/subject\" : { \"http://example.org/predicate\" : [ { \"type\" : \"bnode\" , \"value\" : \"_:id\" } ] } }" ;
  String s2 = "<http://example.org/subject> <http://example.org/predicate> _:id ." ;
  assertEquals(1, parseCount(s)) ;
  Model m = parseToModelRdfJson(s) ;
  Model m2 = parseToModelNTriples(s2) ;
  assertTrue(m.isIsomorphicWith(m2)) ;
}

相关文章

Model类方法