All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.stanford.nlp.trees.SynchronizedTreeTransformer Maven / Gradle / Ivy

Go to download

Stanford Parser processes raw text in English, Chinese, German, Arabic, and French, and extracts constituency parse trees.

There is a newer version: 3.9.2
Show newest version
package edu.stanford.nlp.trees;

/**
 * If you have a TreeTransformer which is not threadsafe, and you need
 * to call it from multiple threads, this will wrap it in a
 * synchronized manner.
 *
 * @author John Bauer
 */
public class SynchronizedTreeTransformer implements TreeTransformer {
  final TreeTransformer threadUnsafe;

  public SynchronizedTreeTransformer(TreeTransformer threadUnsafe) {
    this.threadUnsafe = threadUnsafe;
  }

  public Tree transformTree(Tree t) {
    synchronized(threadUnsafe) {
      return threadUnsafe.transformTree(t);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy