def combine_features(a, b): """ Return an object that combines the feature labels a and b. For now, this only does string concatenation; it can be extended to unify 'featurelite' style dictionaries. """ def override_features(a, b): return b if isinstance(a, YAMLwrapper): a = a.value() if isinstance(b, YAMLwrapper): b = b.value() if isinstance(a, str) and isinstance(b, str): return a+b else: d = {} vars = {} return unify(a, b, vars, fail=override_features) return '%s%s' % (a, b)
def combine_features(a, b): """ Return an object that combines the feature labels a and b. For now, this only does string concatenation; it can be extended to unify 'featurelite' style dictionaries. """ def override_features(a, b): return b if isinstance(a, YAMLwrapper): a = a.value() if isinstance(b, YAMLwrapper): b = b.value() if isinstance(a, str) and isinstance(b, str): return a + b else: d = {} vars = {} return unify(a, b, vars, fail=override_features) return '%s%s' % (a, b)
def combine_features(a, b): """ Return an object that combines the feature labels a and b. If a and b are strings, they are combined by concatenation (as in the original PC-KIMMO). If they are feature dictionaries, then they are unified in a way that always succeeds: the newer dictionary, b, wins all conflicts. """ def override_features(a, b): return b if isinstance(a, YAMLwrapper): a = a.value() if isinstance(b, YAMLwrapper): b = b.value() if isinstance(a, str) and isinstance(b, str): return a+b else: d = {} vars = {} return unify(a, b, vars, fail=override_features) return '%s%s' % (a, b)