public class FastCRules extends Object
( Beginning of capturing a group ) End of capturing a group
A punctuation\ plus following characters + An addition symbol (to distinguish the "+" after a wildcard) ( A left parentheses symbol ) A right parentheses symbol d A digit C A capital letter c A lowercase letter s A whitespace a A Non-whitespace character u A unusual character: not a letter, not a number, not a punctuation, not a whitespace n A return
The wildcard plus "+": 1 or more wildcard| Modifier and Type | Field and Description |
|---|---|
protected boolean |
debug |
protected DeterminantValueSet.Determinants |
END |
protected int |
maxRepeatLength |
protected String |
method |
protected Matcher |
mt |
protected Pattern |
pdigit |
protected int |
ruleId |
protected HashMap |
rules |
protected HashMap<Integer,String> |
ruleStore |
protected HashMap<Integer,Double> |
scores |
protected boolean |
scSupport |
protected boolean |
supportReplications |
| Modifier | Constructor and Description |
|---|---|
protected |
FastCRules() |
|
FastCRules(String ruleFileName) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addDeterminants(HashMap rule,
HashMap<DeterminantValueSet.Determinants,ArrayList<Span>> matches,
int matchBegin,
int matchEnd,
int currentPosition,
DeterminantValueSet.DirectionPrefer directionPrefer)
if reaches the end of one or more rules, add all corresponding
determinants into the results
|
protected boolean |
addRule(char[] rule,
DeterminantValueSet.Determinants determinant,
double score)
Override addRule method
|
protected boolean |
compareScoreOnly(Span a,
Span b) |
protected boolean |
compareScorePrior(Span a,
Span b) |
protected boolean |
compareSpan(Span a,
Span b) |
protected boolean |
compareWidthOnly(Span a,
Span b) |
protected boolean |
compareWidthPrior(Span a,
Span b) |
String |
getRuleString(int ruleId) |
double |
getScore(int ruleId) |
protected void |
initiate(String ruleFile)
Read from ruleFile to construct the rules.
|
protected void |
processRepetition(char[] textChars,
HashMap rule,
int matchBegin,
int matchEnd,
int currentPosition,
HashMap<DeterminantValueSet.Determinants,ArrayList<Span>> matches,
DeterminantValueSet.DirectionPrefer directionPrefer,
char previousChar,
boolean wildcard,
char previousKey) |
protected void |
processRules(char[] textChars,
HashMap rule,
int matchBegin,
int matchEnd,
int currentPosition,
HashMap<DeterminantValueSet.Determinants,ArrayList<Span>> matches,
DeterminantValueSet.DirectionPrefer directionPrefer,
char previousChar,
boolean wildcard,
char previousKey) |
void |
processRules(String text,
HashMap<DeterminantValueSet.Determinants,ArrayList<Span>> matches,
DeterminantValueSet.DirectionPrefer directionPrefer)
Because the input parameters are different, this method is overridden.
|
protected void |
processWildCards(char[] textChars,
HashMap rule,
int matchBegin,
int matchEnd,
int currentPosition,
HashMap<DeterminantValueSet.Determinants,ArrayList<Span>> matches,
DeterminantValueSet.DirectionPrefer directionPrefer,
char previousChar)
\d A digit
\C A capital letter
\c A lower case letter
\s A whitespace
\n A return
\( Beginning of capturing a group
\) End of capturing a group
\p A punctuation
\+ An addition symbol (to distinguish the "+" after a wildcard)
The wildcard plus "+": 1 or more wildcard
|
void |
setCompareMethod(String method) |
void |
setDebug(boolean debug) |
void |
setReplicationSupport(boolean support)
Using "+" to support replications might slow down the performance of FastCRules,
try to avoid using it as much as possible.
|
void |
setScore(int ruleId,
double score) |
void |
setSpecialCharacterSupport(Boolean scSupport) |
protected int ruleId
protected final DeterminantValueSet.Determinants END
protected final int maxRepeatLength
protected boolean supportReplications
protected boolean scSupport
protected boolean debug
protected HashMap rules
protected Pattern pdigit
protected Matcher mt
protected String method
protected FastCRules()
public FastCRules(String ruleFileName)
protected void initiate(String ruleFile) throws IOException
Read from ruleFile to construct the rules. The Determinants (enum type) will be generated dynamically by read the last element of rule; The format of rule file (Using \t to separate):
chars score determinant
ruleFile - The path string of the rule fileIOExceptionprotected boolean addRule(char[] rule,
DeterminantValueSet.Determinants determinant,
double score)
rule - A char array of ruledeterminant - Specify which type of rule is thisscore - Specify the priority score of this rulepublic void processRules(String text, HashMap<DeterminantValueSet.Determinants,ArrayList<Span>> matches, DeterminantValueSet.DirectionPrefer directionPrefer)
text - The input text stringmatches - Save the matched string in an ArrayList of SpansdirectionPrefer - Specify the preference of directionsprotected void processRules(char[] textChars,
HashMap rule,
int matchBegin,
int matchEnd,
int currentPosition,
HashMap<DeterminantValueSet.Determinants,ArrayList<Span>> matches,
DeterminantValueSet.DirectionPrefer directionPrefer,
char previousChar,
boolean wildcard,
char previousKey)
textChars - Input string in the format of character arrayrule - The constructed rules Map for processingmatchBegin - Store the beginning position of matchingmatchEnd - Store the ending position of matchingcurrentPosition - Store the current position of matchingmatches - Save the matched string in an ArrayList of SpansdirectionPrefer - Specify the preference of directionspreviousChar - Store the previous character for wildcard matching usewildcard - Whether wildcard is enabledpreviousKey - Store the previous previous matched character for replication detection useprotected void processRepetition(char[] textChars,
HashMap rule,
int matchBegin,
int matchEnd,
int currentPosition,
HashMap<DeterminantValueSet.Determinants,ArrayList<Span>> matches,
DeterminantValueSet.DirectionPrefer directionPrefer,
char previousChar,
boolean wildcard,
char previousKey)
textChars - Input string in the format of character arrayrule - The constructed rules Map for processingmatchBegin - Store the beginning position of matchingmatchEnd - Store the ending position of matchingcurrentPosition - Store the current position of matchingmatches - Save the matched string in an ArrayList of SpansdirectionPrefer - Specify the preference of directionspreviousChar - Store the previous character for wildcard matching usewildcard - Whether wildcard is enabledpreviousKey - Store the previous previous matched character for replication detection useprotected void processWildCards(char[] textChars,
HashMap rule,
int matchBegin,
int matchEnd,
int currentPosition,
HashMap<DeterminantValueSet.Determinants,ArrayList<Span>> matches,
DeterminantValueSet.DirectionPrefer directionPrefer,
char previousChar)
textChars - Input string in the format of character arrayrule - The constructed rules Map for processingmatchBegin - Store the beginning position of matchingmatchEnd - Store the ending position of matchingcurrentPosition - Store the current position of matchingmatches - Save the matched string in an ArrayList of SpansdirectionPrefer - Specify the preference of directionsprotected void addDeterminants(HashMap rule, HashMap<DeterminantValueSet.Determinants,ArrayList<Span>> matches, int matchBegin, int matchEnd, int currentPosition, DeterminantValueSet.DirectionPrefer directionPrefer)
if reaches the end of one or more rules, add all corresponding determinants into the results
The priority of multiple applicable rules can be modified. This version uses the following three rules: 1. if determinant spans overlap, choose the determinant with the widest span 2. else if prefer right determinant, choose the determinant with the largest end. 3. else if prefer left determinant, choose the determinant with the smallest begin.
rule - The constructed rules Map for processingmatches - Save the matched string in an ArrayList of SpansmatchBegin - Store the beginning position of matchingmatchEnd - Store the ending position of matchingcurrentPosition - Store the current position of matchingdirectionPrefer - Specify the preference of directionspublic double getScore(int ruleId)
public void setScore(int ruleId,
double score)
public void setReplicationSupport(boolean support)
support - Whether support replication grammarpublic void setCompareMethod(String method)
public void setSpecialCharacterSupport(Boolean scSupport)
public void setDebug(boolean debug)
public String getRuleString(int ruleId)
Copyright © 2017 The Department of Biomedical Informatics, University of Utah. All rights reserved.