public class NumberEP extends ExpansionPattern
Modifier and Type | Field and Description |
---|---|
protected Pattern |
reDigits |
protected Pattern |
reFloat |
protected Pattern |
reInteger |
protected Pattern |
reOrdinal |
protected Pattern |
reRoman |
protected static String |
sCardinal |
protected static String |
sDigits |
protected static String |
sFloat |
protected static String |
sInteger |
protected static String |
sOrdinal |
protected static String |
sRoman |
Constructor and Description |
---|
NumberEP() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
allowMultipleTokens()
Simple numbers are expected to be entire tokens.
|
protected int |
canDealWith(String input,
int typeCode)
Decide whether we can expand a string according to type
typeCode . |
protected List<Element> |
expand(List<Element> tokens,
String s,
int type)
Subclasses do their expansion in this class.
|
protected List<Element> |
expandDigits(Document doc,
String s,
boolean createMtu) |
protected String |
expandDigits(String digits) |
protected List<Element> |
expandFloat(Document doc,
String s,
boolean createMtu)
This will correctly expand integers as well, although matchFloat() does not match them.
|
protected String |
expandFloat(String number) |
protected List<Element> |
expandInteger(Document doc,
long value,
boolean createMtu,
String orig) |
protected List<Element> |
expandInteger(Document doc,
String s,
boolean createMtu) |
protected String |
expandInteger(long value) |
protected String |
expandInteger(String s) |
protected List<Element> |
expandOrdinal(Document doc,
long value,
boolean createMtu,
String orig) |
protected List<Element> |
expandOrdinal(Document doc,
String s,
boolean createMtu)
For ordinals we put the expanded form in the sounds_like attribute and keep the surface form.
|
protected List<Element> |
expandRoman(Document doc,
String number,
boolean createMtu) |
protected List<Element> |
expandRoman(Document doc,
String number,
boolean createMtu,
boolean isOrdinal) |
protected boolean |
isCandidate(Element t) |
List<String> |
knownTypes()
Returns the types known by this ExpansionPattern.
|
protected int |
match(String s,
int type)
Subclasses do their matching in this class.
|
protected boolean |
matchDigits(String s) |
protected boolean |
matchFloat(String s) |
protected boolean |
matchInteger(String s) |
protected boolean |
matchOrdinal(String s) |
protected boolean |
matchRoman(String s) |
Pattern |
reMatchingChars()
Returns the regular expression object matching any of the chars occurring in the pattern.
|
allPatterns, doesFullExpansion, getPattern, getSplitAtChars, makeNewTokens, makeNewTokens, makeNewTokens, match, process, replaceTokens, reSplitAtChars, slowDown, slowDown
protected static final String sFloat
protected static final String sInteger
protected static final String sOrdinal
protected static final String sRoman
protected static final String sDigits
protected static final String sCardinal
protected final Pattern reFloat
protected final Pattern reInteger
protected final Pattern reOrdinal
protected final Pattern reRoman
protected final Pattern reDigits
public List<String> knownTypes()
ExpansionPattern
type
attribute to the
say-as
element, as defined in MaryXML.dtd. Each subclass needs to override this to return something
meaningful.knownTypes
in class ExpansionPattern
public Pattern reMatchingChars()
ExpansionPattern
reMatchingChars
in class ExpansionPattern
protected boolean allowMultipleTokens()
allowMultipleTokens
in class ExpansionPattern
protected boolean isCandidate(Element t)
isCandidate
in class ExpansionPattern
protected int match(String s, int type)
ExpansionPattern
match
in class ExpansionPattern
s
- is the String to be matched,type
- is the index in knownTypes
to match with.typeCode
is a general type (
typeCode == 0
), it may have matched with a more specific subtype). On failure, -1
is
returned.protected int canDealWith(String input, int typeCode)
ExpansionPattern
typeCode
. This is important in cases where a
particular expansion is requested via a say-as
element. As a default, reply that a string can be expanded if
it would be matched by the pattern recogniser. Subclasses may wish to override this with less strict requirements. Returns
the type as which it can be expanded, or -1 if expansion is not possible.canDealWith
in class ExpansionPattern
input
- inputtypeCode
- typeCodeprotected List<Element> expand(List<Element> tokens, String s, int type)
ExpansionPattern
expand
in class ExpansionPattern
tokens
- is a list of token Elements to be replaced with their expanded form. The expanded forms are inserted into the
DOM tree at the same positions as the tokens in List tokens
. If there are more new tokens than old
tokens, the rest are inserted as siblings at the position of the last old token.s
- is the String to be expanded,type
- is the index in knownTypes
this string has matched with before.protected boolean matchFloat(String s)
protected boolean matchInteger(String s)
protected boolean matchOrdinal(String s)
protected boolean matchRoman(String s)
protected boolean matchDigits(String s)
protected List<Element> expandInteger(Document doc, long value, boolean createMtu, String orig)
protected String expandInteger(long value)
protected List<Element> expandFloat(Document doc, String s, boolean createMtu)
doc
- docs
- screateMtu
- createMtuprotected List<Element> expandOrdinal(Document doc, String s, boolean createMtu)
doc
- docs
- screateMtu
- createMtuprotected List<Element> expandOrdinal(Document doc, long value, boolean createMtu, String orig)
Copyright © 2000–2016 DFKI GmbH. All rights reserved.