Package net.sf.okapi.common.resource
Class CodeSimplifier
- java.lang.Object
-
- net.sf.okapi.common.resource.CodeSimplifier
-
public class CodeSimplifier extends Object
- Author:
- Fredrik Liden, Sergei Vasilyev, Jim Hargrave
-
-
Field Summary
Fields Modifier and Type Field Description protected static intMAXprotected booleanpostSegmentationprotected SimplifierRulesruleEvaluatorprotected Stringrules
-
Constructor Summary
Constructors Constructor Description CodeSimplifier()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisPostSegmentation()voidsetPostSegmentation(boolean postSegmentation)voidsetRules(String rules)TextFragment[]simplifyAll(TextContainer tc, boolean removeLeadingTrailingCodes, boolean mergeCodes)Simplifies all possible tags in a given possibly segmented text container.TextFragment[]simplifyAll(TextFragment tf, boolean removeLeadingTrailingCodes)Simplifies all possible tags in a given text fragment.TextFragment[]simplifyAll(TextFragment tf, boolean removeLeadingTrailingCodes, boolean mergeCodes)Simplifies all possible tags in a given text fragment.TextFragment[]simplifyAll(TextFragment tf, int maxIterations, boolean removeLeadingTrailingCodes, boolean mergeCodes)Simplifies all possible tags in a given text fragment.voidsimplifyEmptyOpeningClosing(TextFragment tf)voidsimplifyIsolated(TextFragment tf)Simplifies the place-holders in a given text fragment.voidsimplifyOpeningClosing(TextFragment tf)
-
-
-
Field Detail
-
MAX
protected static final int MAX
- See Also:
- Constant Field Values
-
postSegmentation
protected boolean postSegmentation
-
rules
protected String rules
-
ruleEvaluator
protected SimplifierRules ruleEvaluator
-
-
Method Detail
-
simplifyAll
public TextFragment[] simplifyAll(TextFragment tf, int maxIterations, boolean removeLeadingTrailingCodes, boolean mergeCodes)
Simplifies all possible tags in a given text fragment.- Parameters:
tf- the text fragment to modify.maxIterations- maximum number of iterations in merging of adjacent codes.removeLeadingTrailingCodes- true to remove the leading and/or the trailing codes of the fragment and place their text in the result. This works for isolated codes only for now. It is the responsibility of the caller to put the leading/trailing data into the skeleton.mergeCodes- true to merge adjacent codes, false to leave as-is- Returns:
- Null (no leading or trailing code removal was) or a string array with the original data of the codes removed. The first string if there was a leading code, the second string if there was a trailing code. Both or either can be null.
-
simplifyAll
public TextFragment[] simplifyAll(TextContainer tc, boolean removeLeadingTrailingCodes, boolean mergeCodes)
Simplifies all possible tags in a given possibly segmented text container.- Parameters:
tc- the given text container to modifyremoveLeadingTrailingCodes- true to remove the leading and/or the trailing code of the fragment and place their text in the result. It is the responsibility of the caller to put the leading/trailing data into the skeleton.mergeCodes- true to merge adjacent codes, false to leave as-is original data of the codes removed. The first string if there was a leading code, the second string if there was a trailing code. Both or either can be null.- Returns:
- Null (no leading or trailing code removal was) or a string array with the
-
simplifyAll
public TextFragment[] simplifyAll(TextFragment tf, boolean removeLeadingTrailingCodes, boolean mergeCodes)
Simplifies all possible tags in a given text fragment.- Parameters:
tf- the text fragment to modify.removeLeadingTrailingCodes- true to remove the leading and/or the trailing code of the fragment and place their text in the result. It is the responsibility of the caller to put the leading/trailing data into the skeleton.mergeCodes- true to merge adjacent codes, false to leave as-is- Returns:
- Null (no leading or trailing code removal was) or a string array with the original data of the codes removed. The first string if there was a leading code, the second string if there was a trailing code. Both or either can be null.
-
simplifyAll
public TextFragment[] simplifyAll(TextFragment tf, boolean removeLeadingTrailingCodes)
Simplifies all possible tags in a given text fragment.- Parameters:
tf- the text fragment to modify.removeLeadingTrailingCodes- true to remove the leading and/or the trailing code of the fragment and place their text in the result. It is the responsibility of the caller to put the leading/trailing data into the skeleton.- Returns:
- Null (no leading or trailing code removal was) or a string array with the original data of the codes removed. The first string if there was a leading code, the second string if there was a trailing code. Both or either can be null.
-
simplifyIsolated
public void simplifyIsolated(TextFragment tf)
Simplifies the place-holders in a given text fragment.- Parameters:
tf- the text fragment to modify.
-
simplifyOpeningClosing
public void simplifyOpeningClosing(TextFragment tf)
-
simplifyEmptyOpeningClosing
public void simplifyEmptyOpeningClosing(TextFragment tf)
-
setRules
public void setRules(String rules)
-
isPostSegmentation
public boolean isPostSegmentation()
-
setPostSegmentation
public void setPostSegmentation(boolean postSegmentation)
-
-