![JAR search and dependency download from the Maven repository](/logo.png)
gov.nih.nlm.nls.lvg.Flows.ToReplacePunctuationWithSpace Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lvg2010dist Show documentation
Show all versions of lvg2010dist Show documentation
LVG tools is used by Apache cTAKES.
The newest version!
package gov.nih.nlm.nls.lvg.Flows;
import java.util.*;
import gov.nih.nlm.nls.lvg.Lib.*;
import gov.nih.nlm.nls.lvg.Util.*;
/*****************************************************************************
* This class replaces punctuations with spaces for the input term.
* Puunctuations include:
*
* - DASH_PUNCTUATION (20): -
*
- START_PUNCTUATION (21): ( { [
*
- END_PUNCTUATION (22): ) } ]
*
- CONNECTOR_PUNCTUATION (23): _
*
- OTHER_PUNCTUATION (24): ! @ # % & * \ : ; " ' , . ? /
*
- MATH_SYMBOL (25): ~ + = | < >
*
- CURRENCY_SYMBOL (26): $
*
- MODIFIER_SYMBOL (27): ` ^
*
*
* History:
*
*
*
* @author NLM NLS Development Team
*
* @see
* Design Document
*
* @version V-2010
****************************************************************************/
public class ToReplacePunctuationWithSpace 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 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
*/
public static Vector Mutate(LexItem in, boolean detailsFlag,
boolean mutateFlag)
{
// mutate the term
String term = ReplacePunctuationWithSpace(in.GetSourceTerm());
// details & mutate
String details = null;
String mutate = null;
if(detailsFlag == true)
{
details = INFO;
}
if(mutateFlag == true)
{
mutate = Transformation.NO_MUTATE_INFO;
}
// updatea target
Vector out = new Vector();
LexItem temp = UpdateLexItem(in, term,
Flow.REPLACE_PUNCTUATION_WITH_SPACE,
Transformation.UPDATE, Transformation.UPDATE, details, mutate);
out.addElement(temp);
return out;
}
/**
* A unit test driver for this flow component.
*/
public static void main(String[] args)
{
String testStr = GetTestStr(args, "2-aryl-1,3-dithiolane");
// Mutate
LexItem in = new LexItem(testStr);
Vector outs
= ToReplacePunctuationWithSpace.Mutate(in, true, true);
PrintResults(in, outs); // print out results
}
// private method
// replace punctuation with space in a string
static String ReplacePunctuationWithSpace(String inStr)
{
char[] temp = inStr.toCharArray();
for(int i = 0; i < temp.length; i++)
{
if(Char.IsPunctuation(temp[i]) == true)
{
temp[i] = ' ';
}
}
String out = new String(temp);
return out;
}
// data members
private static final String INFO = "Replace Punctuation With Space";
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy