def setUp(self): self.the_cat = examples_dmrs.the_cat().convert_to( abstractSortDictDmrs(node_key=span_pred_key)) # Checks if the matching code converts to SortDictDmrs with span_pred_key self.the_cat_chases_the_dog = examples_dmrs.the_cat_chases_the_dog().convert_to( abstractSortDictDmrs(node_key=span_pred_key)) self.the_dog_chases_the_cat = examples_dmrs.the_dog_chases_the_cat().convert_to( abstractSortDictDmrs(node_key=span_pred_key))
def setUp(self): self.the_cat = examples_dmrs.the_cat().convert_to( abstractSortDictDmrs(node_key=span_pred_key)) # Checks if the matching code converts to SortDictDmrs with span_pred_key self.the_cat_chases_the_dog = examples_dmrs.the_cat_chases_the_dog( ).convert_to(abstractSortDictDmrs(node_key=span_pred_key)) self.the_dog_chases_the_cat = examples_dmrs.the_dog_chases_the_cat( ).convert_to(abstractSortDictDmrs(node_key=span_pred_key)) self.the_mouse = examples_dmrs.the_mouse() \ .convert_to(abstractSortDictDmrs(node_key=span_pred_key)) self.dog_cat = examples_dmrs.dog_cat() \ .convert_to(abstractSortDictDmrs(node_key=span_pred_key))
def setUp(self): self.test_dmrs = examples_dmrs.the_dog_chases_the_cat()
from pydmrs.pydelphin_interface import parse, generate from pydmrs.mapping.mapping import dmrs_mapping from pydmrs.graphlang.graphlang import parse_graphlang import examples.examples_dmrs as examples if __name__ == '__main__': # basic functionality dmrs = examples.the_dog_chases_the_cat() search_dmrs = parse_graphlang('[1]:_the_q') replace_dmrs = parse_graphlang('[1]:_a_q') # iterative, all assert 'A dog chases a cat.' in generate( dmrs_mapping(dmrs, search_dmrs, replace_dmrs, copy_dmrs=True, iterative=True, all_matches=True)) # not iterative, all assert all(sent in sents for sent, sents in zip( ['A dog chases the cat.', 'The dog chases a cat.'], [ generate(dmrs) for dmrs in dmrs_mapping(dmrs, search_dmrs, replace_dmrs, copy_dmrs=True, iterative=False, all_matches=True) ])) # iterative, not all
def setUp(self): self.large_dmrs = examples_dmrs.the_dog_chases_the_cat_and_the_cat_chases_the_mouse( ) self.small_dmrs = examples_dmrs.the_dog_chases_the_cat() self.cat_dmrs = examples_dmrs.the_cat() self.reverse_dmrs = examples_dmrs.the_cat_chases_the_dog()
def setUp(self): self.large_dmrs = examples_dmrs.the_dog_chases_the_cat_and_the_cat_chases_the_mouse() self.small_dmrs = examples_dmrs.the_dog_chases_the_cat() self.cat_dmrs = examples_dmrs.the_cat() self.reverse_dmrs = examples_dmrs.the_cat_chases_the_dog()
from pydmrs.matching.exact_matching import dmrs_exact_matching import examples.examples_dmrs as examples if __name__ == '__main__': # "the" - "the dog chases the cat" assert len(list(dmrs_exact_matching(examples.the(), examples.the_dog_chases_the_cat()))) == 2 # "the cat" - "the dog chases the cat" assert len(list(dmrs_exact_matching(examples.the_cat(), examples.the_dog_chases_the_cat()))) == 1 # "dog cat" - "the dog chases the cat" assert len(list(dmrs_exact_matching(examples.dog_cat(), examples.the_dog_chases_the_cat()))) == 1 # "the dog chases the cat" - "the dog chases the cat" assert len(list(dmrs_exact_matching(examples.the_dog_chases_the_cat(), examples.the_dog_chases_the_cat()))) == 1 # "the cat chases the dog" - "the dog chases the cat" assert not len(list(dmrs_exact_matching(examples.the_cat_chases_the_dog(), examples.the_dog_chases_the_cat()))) # "the dog chases the cat" - "the dog chases the cat and the mouse" assert not len(list(dmrs_exact_matching(examples.the_dog_chases_the_cat(), examples.the_dog_chases_the_cat_and_the_mouse()))) # "the dog chases the cat" - "the dog chases the cat and the cat chases the mouse" assert len(list(dmrs_exact_matching(examples.the_dog_chases_the_cat(), examples.the_dog_chases_the_cat_and_the_cat_chases_the_mouse()))) == 1 # "the cat" - "the dog chases the cat and the cat chases the mouse" assert len(list(dmrs_exact_matching(examples.the_cat(), examples.the_dog_chases_the_cat_and_the_cat_chases_the_mouse()))) == 2 # "dog cat" - "the dog chases the cat and the cat chases the mouse"
def setUp(self): self.test_dmrs = examples_dmrs.the_dog_chases_the_cat()
from pydmrs.pydelphin_interface import parse, generate from pydmrs.mapping.mapping import dmrs_mapping from pydmrs.graphlang.graphlang import parse_graphlang import examples.examples_dmrs as examples if __name__ == '__main__': # basic functionality dmrs = examples.the_dog_chases_the_cat() search_dmrs = parse_graphlang('[1]:_the_q') replace_dmrs = parse_graphlang('[1]:_a_q') # iterative, all assert 'A dog chases a cat.' in generate(dmrs_mapping(dmrs, search_dmrs, replace_dmrs, copy_dmrs=True, iterative=True, all_matches=True)) # not iterative, all assert all(sent in sents for sent, sents in zip(['A dog chases the cat.', 'The dog chases a cat.'], [generate(dmrs) for dmrs in dmrs_mapping(dmrs, search_dmrs, replace_dmrs, copy_dmrs=True, iterative=False, all_matches=True)])) # iterative, not all assert 'A dog chases the cat.' in generate(dmrs_mapping(dmrs, search_dmrs, replace_dmrs, copy_dmrs=True, iterative=True, all_matches=False)) # not iterative, not all assert 'A dog chases the cat.' in generate(dmrs_mapping(dmrs, search_dmrs, replace_dmrs, copy_dmrs=True, iterative=False, all_matches=False)) # original dmrs did not change so far assert 'The dog chases the cat.' in generate(dmrs) # iterative, not all dmrs = examples.the_dog_chases_the_cat() dmrs_mapping(dmrs, search_dmrs, replace_dmrs, copy_dmrs=False, iterative=True, all_matches=False) assert 'A dog chases the cat.' in generate(dmrs) # iterative, all dmrs = examples.the_dog_chases_the_cat() dmrs_mapping(dmrs, search_dmrs, replace_dmrs, copy_dmrs=False, iterative=True, all_matches=True) assert 'A dog chases a cat.' in generate(dmrs)
from pydmrs.matching.exact_matching import dmrs_exact_matching import examples.examples_dmrs as examples if __name__ == '__main__': # "the" - "the dog chases the cat" assert len( list( dmrs_exact_matching(examples.the(), examples.the_dog_chases_the_cat()))) == 2 # "the cat" - "the dog chases the cat" assert len( list( dmrs_exact_matching(examples.the_cat(), examples.the_dog_chases_the_cat()))) == 1 # "dog cat" - "the dog chases the cat" assert len( list( dmrs_exact_matching(examples.dog_cat(), examples.the_dog_chases_the_cat()))) == 1 # "the dog chases the cat" - "the dog chases the cat" assert len( list( dmrs_exact_matching(examples.the_dog_chases_the_cat(), examples.the_dog_chases_the_cat()))) == 1 # "the cat chases the dog" - "the dog chases the cat" assert not len(