示例#1
0
 def visit_singletonstatement(self, node, children):
     """
     Instantiates a singleton statement from a statement in the form (q_id)
     """
     if self.debug:
         print(f"Instantiating a Statement from {children}.")
     return model.Statement(*children)
示例#2
0
def test_transcribe_multiple_Statements():
    assert parsing.transcribe(
        "(Q5)(P31 Q42 Q5) (Q5 Q42) (P106 Q3236990 Q5482740)") == [
            m.Statement(m.WikidataItem("Q5")),
            m.LabeledEdge(
                m.WikidataProperty("P31"),
                m.WikidataItem("Q42"),
                m.WikidataItem("Q5"),
            ),
            m.Edge(m.WikidataItem("Q5"), m.WikidataItem("Q42")),
            m.LabeledEdge(
                m.WikidataProperty("P106"),
                m.WikidataItem("Q3236990"),
                m.WikidataItem("Q5482740"),
            ),
        ]
示例#3
0
def singleton_statement():
    return m.Statement(m.WikidataItem("Q2013"))
示例#4
0
 def test_describe(self, example_statement):
     assert (m.Statement(example_statement).describe("en") ==
             "[Douglas Adams → human (instance of)].")
示例#5
0
 def test_str(self, example_statement):
     assert str(m.Statement(example_statement)) == "((P31 Q42 Q5))"
示例#6
0
 def test_repr(self, example_statement):
     assert (
         repr(m.Statement(example_statement)) ==
         'Statement(LabeledEdge(WikidataProperty("P31"), WikidataItem("Q42"), WikidataItem("Q5")))'
     )
示例#7
0
 def test_describe_lvl(self, cached_WikidataItem_Q42):
     s = m.Statement(cached_WikidataItem_Q42)
     assert s.describe("en", lvl=1) == "[Douglas Adams]"
示例#8
0
 def test_describe(self, cached_WikidataItem_Q42):
     s = m.Statement(cached_WikidataItem_Q42)
     assert s.describe("en") == "Douglas Adams."
示例#9
0
 def test_str(self, cached_WikidataItem_Q42):
     s = m.Statement(cached_WikidataItem_Q42)
     assert str(s) == "(Q42)"
示例#10
0
 def test_repr(self, cached_WikidataItem_Q42):
     s = m.Statement(cached_WikidataItem_Q42)
     assert repr(s) == 'Statement(WikidataItem("Q42"))'
示例#11
0
def test_transcribe_singletonStatement():
    assert parsing.transcribe("(Q5)") == [m.Statement(m.WikidataItem("Q5"))]