pyeeg.features.SyntacticFeatureExtractor.extract_to_array

SyntacticFeatureExtractor.extract_to_array(text: str, features: List[str] = None) Tuple[List[str], ndarray]

Extract features and return as arrays.

Splits the input text on whitespace to obtain the word list, then extracts the requested features via extract() and stacks them into a words-by-features matrix. Each column corresponds to one feature, in the order of features (or the canonical order ["depth", "opening", "closing", "tree_height"] when "all" is requested).

Parameters:
  • text (str) – Input text to process.

  • features (list of str, optional) – Feature names to extract; see extract() for valid values. If None, defaults to ["all"].

Returns:

  • words (list of str) – Words of the input text, in reading order, obtained by text.split(). Note that this may not exactly match the leaf count of the parse trees if tokenization differs from whitespace splitting.

  • feature_array (ndarray, shape (n_words, n_features)) – Feature values per word. Empty array (shape (0,)) if no features were extracted.