|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectadams.core.ConsoleObject
adams.core.option.AbstractOptionHandler
adams.parser.AbstractExpressionEvaluator<T>
adams.parser.AbstractSymbolEvaluator<Boolean>
adams.parser.TwitterFilter
public class TwitterFilter
Evaluates Twitter filter expressions.
The expressions use the following grammar:
expr_list ::= expr_list expr | expr;
expr ::= ( expr )
| boolexpr
;
boolexpr ::= BOOLEAN
| ( boolexpr )
| not boolexpr
| boolexpr and boolexpr
| boolexpr or boolexpr
| boolexpr xor boolexpr
| langcode <match> pattern
| country <match> pattern
| countrycode <match> pattern
| place <match> pattern
| source <match> pattern
| text <match> pattern
| user <match> pattern
| ifelse ( boolexpr:test , boolexpr:test_true , boolexpr:test_false )
;
The '<match>' operator can be one of the following:
1. '=' - exact match (the twitter field must be the exact 'pattern' string)
2. ':' - substring match (the 'pattern' can occur anywhere in the twitter field)
3. '~' - regular expression match (the 'pattern' is a regular expression that the twitter field must match)
Please note, all strings are converted to lower case before the filter is applied.
-D <int> (property: debugLevel) The greater the number the more additional info the scheme may output to the console (0 = off). default: 0 minimum: 0
-env <java.lang.String> (property: environment) The class to use for determining the environment. default: adams.env.Environment
-expression <java.lang.String> (property: expression) The filter expression to evaluate. default: text~\".*\"
-symbol <adams.core.base.BaseString> [-symbol ...] (property: symbols) The symbols to initialize the parser with, key-value pairs: name=value. default:
| Field Summary |
|---|
| Fields inherited from class adams.parser.AbstractSymbolEvaluator |
|---|
m_Symbols |
| Fields inherited from class adams.parser.AbstractExpressionEvaluator |
|---|
m_Environment, m_Expression |
| Fields inherited from class adams.core.option.AbstractOptionHandler |
|---|
m_DebugLevel, m_OptionManager |
| Constructor Summary | |
|---|---|
TwitterFilter()
|
|
| Method Summary | |
|---|---|
protected Boolean |
doEvaluate(HashMap symbols)
Performs the actual evaluation. |
static boolean |
evaluate(String expr,
HashMap symbols)
Parses and evaluates the given expression. |
String |
expressionTipText()
Returns the tip text for this property. |
protected String |
getDefaultExpression()
Returns the default expression to use. |
String |
getGrammar()
Returns a string representation of the grammar. |
String |
globalInfo()
Returns a string describing the object. |
protected Object |
initializeSymbol(String name,
String value)
Initializes the symbol. |
static void |
main(String[] args)
Runs the evaluator from command-line. |
| Methods inherited from class adams.parser.AbstractSymbolEvaluator |
|---|
defineOptions, evaluate, getSymbols, initialize, initializeSymbols, setSymbols, symbolsTipText |
| Methods inherited from class adams.parser.AbstractExpressionEvaluator |
|---|
environmentTipText, forCommandLine, forName, getEnvironment, getExpression, runEvaluator, setEnvironment, setExpression |
| Methods inherited from class adams.core.option.AbstractOptionHandler |
|---|
cleanUpOptions, debug, debug, debugLevelTipText, destroy, finishInit, getDebugLevel, getOptionManager, isDebugOn, newOptionManager, reset, setDebugLevel, toCommandLine, toString |
| Methods inherited from class adams.core.ConsoleObject |
|---|
getDebugging, getSystemErr, getSystemOut, sizeOf |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TwitterFilter()
| Method Detail |
|---|
public String globalInfo()
globalInfo in class AbstractOptionHandlerpublic String getGrammar()
protected String getDefaultExpression()
getDefaultExpression in class AbstractExpressionEvaluator<Boolean>public String expressionTipText()
expressionTipText in class AbstractExpressionEvaluator<Boolean>
protected Object initializeSymbol(String name,
String value)
initializeSymbol in class AbstractSymbolEvaluator<Boolean>name - the name of the symbolvalue - the string representation of the symbol
protected Boolean doEvaluate(HashMap symbols)
throws Exception
doEvaluate in class AbstractSymbolEvaluator<Boolean>symbols - the symbols to use
Exception - if evaluation fails
public static boolean evaluate(String expr,
HashMap symbols)
throws Exception
expr - the expression to evaluatesymbols - the symbol/value mapping
Exception - if something goes wrongpublic static void main(String[] args)
args - the command-line options, use "-help" to list them
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||