# Path: tupa/features/feature_extractor.py
# class FeatureExtractor:
#     """
#     Object to extract features from the parser state to be used in action classification
#     """
# 
#     def __init__(self, feature_templates=(), params=None, omit_features=None):
#         assert all(FEATURE_TEMPLATE_PATTERN.match(f) for f in feature_templates), \
#             "Features do not match pattern: " + ", ".join(
#                 f for f in feature_templates if not FEATURE_TEMPLATE_PATTERN.match(f))
#         # convert the list of features textual descriptions to the actual fields
#         self.feature_templates = [
#             FeatureTemplate(feature_name, tuple(FeatureTemplateElement(*m.group(1, 2, 3, 4), omit_features)
#                                                 for m in re.finditer(FEATURE_ELEMENT_PATTERN, feature_name)))
#             for feature_name in feature_templates]
#         self.params = {} if params is None else params
#         self.omit_features = omit_features
# 
#     def extract_features(self, state):
#         """
#         Calculate feature values according to current state
#         :param state: current state of the parser
#         """
#         raise NotImplementedError()
# 
#     def init_features(self, state):
#         """
#         Calculate feature values for initial state
#         :param state: initial state of the parser
#         """
#         pass
# 
#     def init_param(self, key):
#         pass
# 
#     def finalize(self):
#         return self
# 
#     def unfinalize(self):
#         pass
# 
#     def save(self, filename, save_init=True):
#         pass
# 
#     def load(self, filename, order=None):
#         pass
# 
#     def all_features(self):
#         return sorted(list(map(str, self.feature_templates)))


from .feature_extractor import FeatureExtractor
    # extended (Zhu et al. 2013):
    "s0llwe", "s0lrwe", "s0rlwe", "s0rrwe", "s1llwe", "s1lrwe", "s1rlwe", "s1rrwe",
    # parents:
    "s0Lwe", "s0Rwe", "s1Lwe", "s1Rwe", "b0Lwe", "b0Rwe",
    # separator (Zhu et al. 2013):
    "s0wp", "s0wep", "s0wq", "s0weq", "s0es1ep", "s0es1eq", "s1wp", "s1wep", "s1wq", "s1weq",
    # disco, unigrams (Maier 2015):
    "s0xwe", "s1xwe", "s2xwe", "s3xwe", "s0xtde", "s1xtde", "s2xtde", "s3xtde", "s0xy", "s1xy", "s2xy", "s3xy",
    # disco, bigrams (Maier 2015):
    "s0xs1e", "s0xs1w", "s0xs1x", "s0ws1x", "s0es1x", "s0xs2e", "s0xs2w", "s0xs2x", "s0es2x",
    "s0ys1y", "s0ys2y", "s0xb0td", "s0xb0w",
    # counts (Tokgöz and Eryiğit 2015):
    "s0P", "s0C", "s0wP", "s0wC", "b0P", "b0C", "b0wP", "b0wC",
    # existing edges (Tokgöz and Eryiğit 2015):
    "s0s1x", "s1s0x", "s0b0x", "b0s0x", "s0b0e", "b0s0e",
    # dependency distance:
    "s0s1d", "s0b0d",
    # past actions (Tokgöz and Eryiğit 2015):
    "a0Ae", "a1Ae",
    # implicit and remote
    "s0I", "s0E", "s0M", "s0wI", "s0wE", "s0wM", "b0I", "b0E", "b0M", "b0wI", "b0wE", "b0wM",
    # node labels
    "s0n", "s0wn", "s0c", "b0n", "b0wn", "b0c", "s0Ln", "s0Rn", "s1Ln", "s1Rn", "b0Ln", "b0Rn",
    # height
    "s0h", "s1h", "b0h", "b1h",
    # NER
    "s0NT", "s1NT", "b0NT", "b1NT",
)



# Path: tupa/features/feature_extractor.py
# class FeatureExtractor:
#     """
#     Object to extract features from the parser state to be used in action classification
#     """
# 
#     def __init__(self, feature_templates=(), params=None, omit_features=None):
#         assert all(FEATURE_TEMPLATE_PATTERN.match(f) for f in feature_templates), \
#             "Features do not match pattern: " + ", ".join(
#                 f for f in feature_templates if not FEATURE_TEMPLATE_PATTERN.match(f))
#         # convert the list of features textual descriptions to the actual fields
#         self.feature_templates = [
#             FeatureTemplate(feature_name, tuple(FeatureTemplateElement(*m.group(1, 2, 3, 4), omit_features)
#                                                 for m in re.finditer(FEATURE_ELEMENT_PATTERN, feature_name)))
#             for feature_name in feature_templates]
#         self.params = {} if params is None else params
#         self.omit_features = omit_features
# 
#     def extract_features(self, state):
#         """
#         Calculate feature values according to current state
#         :param state: current state of the parser
#         """
#         raise NotImplementedError()
# 
#     def init_features(self, state):
#         """
#         Calculate feature values for initial state
#         :param state: initial state of the parser
#         """
#         pass
# 
#     def init_param(self, key):
#         pass
# 
#     def finalize(self):
#         return self
# 
#     def unfinalize(self):
#         pass
# 
#     def save(self, filename, save_init=True):
#         pass
# 
#     def load(self, filename, order=None):
#         pass
# 
#     def all_features(self):
#         return sorted(list(map(str, self.feature_templates)))


# Path: tupa/features/sparse_features.py
from .feature_extractor import FeatureExtractor

    # extended (Zhu et al. 2013):
    "s0llwe", "s0lrwe", "s0rlwe", "s0rrwe", "s1llwe", "s1lrwe", "s1rlwe", "s1rrwe",
    # parents:
    "s0Lwe", "s0Rwe", "s1Lwe", "s1Rwe", "b0Lwe", "b0Rwe",
    # separator (Zhu et al. 2013):
    "s0wp", "s0wep", "s0wq", "s0weq", "s0es1ep", "s0es1eq", "s1wp", "s1wep", "s1wq", "s1weq",
    # disco, unigrams (Maier 2015):
    "s0xwe", "s1xwe", "s2xwe", "s3xwe", "s0xtde", "s1xtde", "s2xtde", "s3xtde", "s0xy", "s1xy", "s2xy", "s3xy",
    # disco, bigrams (Maier 2015):
    "s0xs1e", "s0xs1w", "s0xs1x", "s0ws1x", "s0es1x", "s0xs2e", "s0xs2w", "s0xs2x", "s0es2x",
    "s0ys1y", "s0ys2y", "s0xb0td", "s0xb0w",
    # counts (Tokgöz and Eryiğit 2015):
    "s0P", "s0C", "s0wP", "s0wC", "b0P", "b0C", "b0wP", "b0wC",
    # existing edges (Tokgöz and Eryiğit 2015):
    "s0s1x", "s1s0x", "s0b0x", "b0s0x", "s0b0e", "b0s0e",
    # dependency distance:
    "s0s1d", "s0b0d",
    # past actions (Tokgöz and Eryiğit 2015):
    "a0Ae", "a1Ae",
    # implicit and remote
    "s0I", "s0E", "s0M", "s0wI", "s0wE", "s0wM", "b0I", "b0E", "b0M", "b0wI", "b0wE", "b0wM",
    # node labels
    "s0n", "s0wn", "s0c", "b0n", "b0wn", "b0c", "s0Ln", "s0Rn", "s1Ln", "s1Rn", "b0Ln", "b0Rn",
    # height
    "s0h", "s1h", "b0h", "b1h",
    # NER
    "s0NT", "s1NT", "b0NT", "b1NT",
)



class SparseFeatureExtractor(FeatureExtractor):