def test_not_equal(self): fetched_Q = fetch_query("llevaron", "Spanish") Llevaron = wx.graph(fetched_Q) fetched_Q = fetch_query("llevar", "Spanish") Llevar = wx.graph(fetched_Q) assert not nx.is_isomorphic(Llevar, Llevaron)
def test_safe_query(original_query, working_G=None): nonlocal total_queries nonlocal test_queries nonlocal run_queries nonlocal _EXIT if test_queries: if total_queries >= len(test_queries): return _EXIT _q1 = test_.fetch_query(*test_queries[total_queries], query_id=total_queries) elif run_queries: if total_queries >= len(run_queries): return _EXIT potential = run_queries[total_queries] if potential: print(f"querying:{potential}") _q1 = ety.query(me=potential, query_id=total_queries, working_G=working_G) else: print("Prematurely exiting!") return _EXIT else: _q1 = ety.query(me=original_query, query_id=total_queries, working_G=working_G) total_queries += 1 return _q1
def test_to_dict_of_lists_equivalence(): return True # this shouldn't change very much _Q = test_.fetch_query("prototype", "English") G = wikt_api.graph(_Q) wikt_api.draw_graph(G, pause=True) dl = nx.to_dict_of_lists(G) print(dl) G2 = nx.from_dict_of_lists(dl, create_using=nx.DiGraph) wikt_api.draw_graph(G2, pause=True) dl2 = nx.to_dict_of_lists(G2) assert dl == dl2
def test_missing_definition_graph(self): # etyobjects.reset_global_o_id() fetched_Q = fetch_query("statt", "German") # TODO: investigate the effect of flattening on this line G = wx.graph(fetched_Q) G2 = nx.DiGraph() G2.add_node(fetched_Q.origin) assert nx.is_isomorphic(G, G2) assert len(G.nodes) == 1 assert [n for n in G.nodes] == [n for n in G2.nodes]
def test_lemma_llevaron(self): # etyobjects.reset_global_o_id() fetched_Q = fetch_query("llevaron", "Spanish") G = wx.graph(fetched_Q) global G_llevaron G2 = G_llevaron # this is the repr() version of each node assert nx.is_isomorphic(G, G2) assert [repr(s) for s in G.nodes] == [s for s in reversed(list(G2.nodes))] # nx reversed the nodes for some reason assert [(repr(l), repr(r)) for l, r in G.edges] == [e for e in reversed(list(G2.edges))]
def test_graph(self, monkeypatch): # etyobjects.reset_global_o_id() # monkeypatch.setattr('builtins.input', lambda _: "1") #Multiple Definitions fetched_Q = fetch_query("llevar", "Spanish") G = wx.graph(fetched_Q) global G_llevar G2 = G_llevar assert nx.is_isomorphic(G, G2) assert [repr(s) for s in G.nodes] == [s for s in reversed(list(G2.nodes))] # nx reversed the nodes for some reason assert [(repr(l), repr(r)) for l, r in G.edges] == [e for e in reversed(list(G2.edges))]
def test_graph(self, monkeypatch): monkeypatch.setattr('builtins.input', lambda _: "1") # Multiple Definitions _Q = fetch_query("adelante", "Spanish") # TODO: investigate the effect of flattening on this line G = wx.graph(_Q) G2 = nx.DiGraph() nx.add_path( G2, ["adelante#Spanish$0", "$0{m|Spanish|delante ['in front']}"]) assert nx.is_isomorphic(G, G2) assert [repr(s) for s in G.nodes] == [s for s in G2.nodes]
def test_graph_eq(): # etyobjects.reset_global_o_id() _Q = test_.fetch_query("prototype", "English") G = wikt_api.graph(_Q) # wikt_api.draw_graph(G, pause=True) dl = nx.to_dict_of_lists(G) print(dl) assert repr(dl) == "{prototype#English$0: [], $0{der|French|prototype}: [prototype#English$0], $0{der|Late Latin|prototypon}: " \ "[$0{der|French|prototype}], $0{der|Ancient Greek|πρωτότυπος ['', 'original; prototype']}: " \ "[$0{der|Late Latin|prototypon}], $0{m|Ancient Greek|πρωτο- [\"''prefix meaning ‘first’''\"]}: " \ "[$0{der|Ancient Greek|πρωτότυπος ['', 'original; prototype']}], $0{m|Ancient Greek|πρῶτος ['first; earliest']}: " \ "[$0{m|Ancient Greek|πρωτο- [\"''prefix meaning ‘first’''\"]}], $0{m|Ancient Greek|τῠ́πος ['blow, pressing; sort, type']}: " \ "[$0{m|Ancient Greek|πρωτο- [\"''prefix meaning ‘first’''\"]}], $0{m|Ancient Greek|τύπτω ['to beat, strike']}: " \ "[$0{m|Ancient Greek|τῠ́πος ['blow, pressing; sort, type']}], $0{der|Proto-Indo-European|*(s)tewp- ['', 'to push; to stick']}: " \ "[$0{m|Ancient Greek|τύπτω ['to beat, strike']}]}"