public class CodecUtilities extends Object
| Constructor and Description |
|---|
CodecUtilities() |
| Modifier and Type | Method and Description |
|---|---|
static String |
extractName(org.antlr.v4.runtime.RuleContext context,
boolean isQuoted)
Extracts a name from a given ANTLR rule context.
|
static Constructor<FeatureFunction> |
findFeatureConstructor(String className,
int n)
Retrieves a constructor for a
FeatureFunction. |
static Method |
findStaticFeatureFactory(String className,
String methodName,
int n)
Retrieves a static factory method by name and number of arguments.
|
String |
gensym(String prefix)
Generate a new string with the given prefix.
|
List<String> |
introduceAnonymousStates(ConcreteTreeAutomaton<String> auto,
List<String> children,
Set<String> states)
Normalizes a list of strings by introducing new anonymous states
where necessary.
|
static <I,C extends org.antlr.v4.runtime.ParserRuleContext,O> |
processList(C context,
Function<C,List<I>> extractList,
Function<I,O> map)
Extracts a list of values from an ANTLR context representing a list.
|
static <O,C extends org.antlr.v4.runtime.ParserRuleContext> |
processTree(C context,
Function<C,O> label,
Function<C,List<C>> children)
Extracts a tree of values from an ANTLR context.
|
static String |
stripOuterChars(String s)
Removes the first and last character from a string.
|
static <C extends org.antlr.v4.runtime.ParserRuleContext> |
weight(C weight,
Function<C,String> extractStr)
Extracts a weight from a string specifying the weight.
|
public static String stripOuterChars(String s)
s - public static String extractName(org.antlr.v4.runtime.RuleContext context, boolean isQuoted)
context - isQuoted - public List<String> introduceAnonymousStates(ConcreteTreeAutomaton<String> auto, List<String> children, Set<String> states)
auto - children - states - public String gensym(String prefix)
prefix - public static <I,C extends org.antlr.v4.runtime.ParserRuleContext,O> List<O> processList(C context, Function<C,List<I>> extractList, Function<I,O> map)
I - C - O - context - extractList - map - public static <C extends org.antlr.v4.runtime.ParserRuleContext> double weight(C weight,
Function<C,String> extractStr)
C - weight - extractStr - public static <O,C extends org.antlr.v4.runtime.ParserRuleContext> Tree<O> processTree(C context, Function<C,O> label, Function<C,List<C>> children)
O - C - context - label - children - public static Constructor<FeatureFunction> findFeatureConstructor(String className, int n) throws ClassNotFoundException, NoSuchMethodException
FeatureFunction. The "className"
argument specifies the fully qualified name of a subclass of FeatureFunction.
The method then looks for a constructor for this class with "n" parameters
of type String.className - n - ClassNotFoundException - no subclass of FeatureFunction could be foundNoSuchMethodException - no constructor with n String parameters could be foundpublic static Method findStaticFeatureFactory(String className, String methodName, int n) throws ClassNotFoundException, NoSuchMethodException
className - methodName - n - ClassNotFoundException - the class could not be foundNoSuchMethodException - no method with this name of parameter list could be foundCopyright © 2017. All rights reserved.