def testExtractCandidateMWEs(self): bilExpr=BilingualExpr() bilExpr.set_exprs(self.extExpr,self.extExpr) self.assertTrue(bilExpr.is_equal_sides()) candidateMWEs=bilExpr.extract_candidate_mwes() self.assertEqual(len(candidateMWEs), 4) for mwestr in candidateMWEs: mwe =ParallelMWE() mwe.parse(" | ".join(mwestr.split(" | ")[2:])) self.assertTrue(mwe.is_equal_sides())
args = parser.parse_args(sys.argv[1:]) inputSource=sys.stdin if args.use_synonyms: ParallelMWE.load_synonym_dict(args.use_synonyms, args.inverse_synonyms) for line in inputSource: line=line.strip() mwe=ParallelMWE() mwe.parse(line) isValid=True if args.different_sides: isValid = isValid and not mwe.is_equal_sides() if args.contains_lexical: isValid = isValid and ( len(mwe.slexpr.get_open_leaf_functions())>0 or len(mwe.tlexpr.get_open_leaf_functions())>0 ) if args.not_contains_lexical: isValid = isValid and not ( len(mwe.slexpr.get_open_leaf_functions())>0 or len(mwe.tlexpr.get_open_leaf_functions())>0 ) if args.contains_non_wildcard: isValid = isValid and ( len(mwe.slexpr.get_non_wildcard_leaf_functions())>0 and len(mwe.tlexpr.get_non_wildcard_leaf_functions())>0 ) if args.contains_wildcard: isValid = isValid and mwe.get_total_wildcards() > 0 if args.not_contains_wildcard: isValid = isValid and mwe.get_total_wildcards() == 0