edu.stanford.nlp.trees.SynchronizedTreeTransformer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stanford-parser Show documentation
Show all versions of stanford-parser Show documentation
Stanford Parser processes raw text in English, Chinese, German, Arabic, and French, and extracts constituency parse trees.
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);
}
}
}