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

com.intersystems.iknow.languagemodel.slavic.SerializingMorphologicalAnalyzer Maven / Gradle / Ivy

The newest version!
/*-
 * $Id: fd8e0656d3b5713b9f653f4e64f481be3825c809 $
 */
package com.intersystems.iknow.languagemodel.slavic;

import java.rmi.RemoteException;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/**
 * @author Andrey Shcheglov (mailto:[email protected])
 */
public final class SerializingMorphologicalAnalyzer {
	private static final Gson GSON = new GsonBuilder()
			.registerTypeAdapter(MorphologicalAnalysisResult.class, new MorphologicalAnalysisResultSerializer())
			.setPrettyPrinting()
			.create();

	private final MorphologicalAnalyzer delegate;

	/**
	 * @param delegate
	 */
	public SerializingMorphologicalAnalyzer(final MorphologicalAnalyzer delegate) {
		this.delegate = delegate;
	}

	/**
	 * @param text
	 * @throws AnalysisException
	 * @throws RemoteException
	 * @see MorphologicalAnalyzer#analyze(String)
	 */
	public String analyze(final String text)
	throws AnalysisException, RemoteException {
		return GSON.toJson(this.delegate.analyze(text));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy