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)
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"), ), ]
def singleton_statement(): return m.Statement(m.WikidataItem("Q2013"))
def test_describe(self, example_statement): assert (m.Statement(example_statement).describe("en") == "[Douglas Adams → human (instance of)].")
def test_str(self, example_statement): assert str(m.Statement(example_statement)) == "((P31 Q42 Q5))"
def test_repr(self, example_statement): assert ( repr(m.Statement(example_statement)) == 'Statement(LabeledEdge(WikidataProperty("P31"), WikidataItem("Q42"), WikidataItem("Q5")))' )
def test_describe_lvl(self, cached_WikidataItem_Q42): s = m.Statement(cached_WikidataItem_Q42) assert s.describe("en", lvl=1) == "[Douglas Adams]"
def test_describe(self, cached_WikidataItem_Q42): s = m.Statement(cached_WikidataItem_Q42) assert s.describe("en") == "Douglas Adams."
def test_str(self, cached_WikidataItem_Q42): s = m.Statement(cached_WikidataItem_Q42) assert str(s) == "(Q42)"
def test_repr(self, cached_WikidataItem_Q42): s = m.Statement(cached_WikidataItem_Q42) assert repr(s) == 'Statement(WikidataItem("Q42"))'
def test_transcribe_singletonStatement(): assert parsing.transcribe("(Q5)") == [m.Statement(m.WikidataItem("Q5"))]