import importlib


def get_extractor_implementation(cls, pkg=None):
    """
    Get the implementation of an Extractor.
    :param cls: class name (str)
    :param pkg: package where implementation is found (str)
    :return: class implementation
    """
    # known extractors
    # others must be fully specified through pkg.cls
    if pkg:
        try:
            module = importlib.import_module(pkg)
            impl = getattr(module, cls)
        except:
            raise ValueError('Could not load feature definitions from file %s', pkg)
    else:
        impl = eval(cls)
    return impl