pyeeg.features.SyntacticFeatureExtractor.get_stanford_tree

SyntacticFeatureExtractor.get_stanford_tree(sentences: List[str], path_to_jar: str | None = None) List[None]

Parse sentences using the Stanford Parser.

Loads the Stanford Parser via NLTK and parses each sentence, returning one parse tree per sentence. The parser classpath is derived from path_to_jar (or config.parser_path); if the path does not exist, an attempt is made to locate stanford-parser.jar with the locate command. The STANDFORD_MODELS environment variable must be set, pointing to the Stanford models directory.

Based on parseMetrics.py.

Parameters:
  • sentences (list of str) – Sentences to parse. Each element is parsed independently.

  • path_to_jar (str, optional) – Path to stanford-parser.jar. If None, config.parser_path is used. Default: None.

Returns:

trees – One parse tree per sentence, in input order.

Return type:

list of nltk.tree.Tree

Raises:
  • ImportError – If NLTK is not available.

  • IOError – If stanford-parser.jar cannot be found or the STANFORD_MODELS environment variable is not set.