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 stocastic tagger to lvg * style pipe delimited format. *
The format of Xerox Parc stocastic tagger is: ['term', 'category'] *
The format of Lvg style pipe delimite format is: * in term|out term|category|inflection|Flow History| * *

History: * * @author NLM LVG Development Team * * @see * Design Document * * @version V-2004 ****************************************************************************/ 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 the results from this flow component - a collection (Vector) * of LexItems * * @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); } catch (Exception e) { System.err.println(e.getMessage()); } PrintResults(in, outs); // print out results } // private methods // data members private static final String INFO = "Convert"; }