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

gov.nih.nlm.nls.lvg.Flows.ToConvertOutput Maven / Gradle / Ivy

The newest version!
package gov.nih.nlm.nls.lvg.Flows;
import java.util.*;
import java.sql.*;
import gov.nih.nlm.nls.lvg.Util.*;
import gov.nih.nlm.nls.lvg.Lib.*;
import gov.nih.nlm.nls.lvg.Db.*;
/*****************************************************************************
* This class converts the output of the Xerox Parc stochastic tagger to lvg 
* style pipe delimited format.
* 
The format of Xerox Parc stochastic tagger is: ['term', 'category'] *
The format of Lvg style pipe delimite format is: * in term|out term|category|inflection|Flow History| * *

History: *

    *
* * @author NLM NLS Development Team * * @see * Design Document * * @version V-2010 ****************************************************************************/ public class ToConvertOutput extends Transformation implements Cloneable { // public methods /** * Performs the mutation of this flow component. * * @param in a LexItem as the input for this flow component * @param conn LVG database connection * @param detailsFlag a boolean flag for processing details information * @param mutateFlag a boolean flag for processing mutate information * * @return Vector - results from this flow component * * @exception SQLException if errors occurr while connect to LVG database. * * @see DbBase */ public static Vector Mutate(LexItem in, Connection conn, boolean detailsFlag, boolean mutateFlag) throws SQLException { Vector out = new Vector(); // mutate the term XeroxParc xp = new XeroxParc(in.GetSourceTerm()); String term = xp.GetTerm(); long cat = Category.ALL_BIT_VALUE; long infl = Inflection.ALL_BIT_VALUE; if(xp.IsLegal() == true) { cat = xp.GetCategoryValue(); infl = DbInflection.GetInflByCat(term, (int)cat, conn); } // details & mutate String details = null; String mutate = null; if(detailsFlag == true) { details = INFO; } if(mutateFlag == true) { mutate = Transformation.NO_MUTATE_INFO; } // updatea target LexItem temp = UpdateLexItem(in, term, Flow.CONVERT_OUTPUT, cat, infl, details, mutate); out.addElement(temp); return out; } /** * A unit test driver for this flow component. */ public static void main(String[] args) { // read in configuration file: for data base info Configuration conf = new Configuration("data.config.lvg", true); String testStr = GetTestStr(args, "['elderly', 'adj']"); // mutate: connect to DB LexItem in = new LexItem(testStr); Vector outs = new Vector(); try { Connection conn = DbBase.OpenConnection(conf); if(conn != null) { outs = ToConvertOutput.Mutate(in, conn, true, true); } DbBase.CloseConnection(conn, conf); } catch (Exception e) { System.err.println(e.getMessage()); } PrintResults(in, outs); // print out results } // private methods // data members private static final String INFO = "Convert"; }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy