maha.parsers.templates¶
Submodules¶
Package Contents¶
Classes¶
Template for the parsed item |
|
Type of the extracted value |
|
Generic enumeration. |
|
Generic enumeration. |
|
Generic enumeration. |
|
Generic enumeration. |
|
Base class for all units |
|
Base class for all units |
|
Base class for all units |
|
Base class for all units |
|
Base class for all units |
|
Expression that returns the matched text as value |
|
Expression that returns a predefined value if the pattern matches. |
|
Expression that returns a predefined value of a matched expression from the input |
|
Expression that returns the output value of an input function when matched. |
- class Dimension(expression, body, value, start, end, dimension_type)[source]¶
Template for the parsed item
- Parameters
expression (maha.rexy.Expression) –
body (str) –
value (Any) –
start (int) –
end (int) –
dimension_type (maha.parsers.templates.enums.DimensionType) –
- expression :maha.rexy.Expression¶
The expression that was used to find the value
- body :str¶
Text from the input that was matched by the expression.
- value :Any¶
Extracted value
- start :int¶
Start index of the value in the text
- end :int¶
End index of the value in the text
- dimension_type :maha.parsers.templates.enums.DimensionType¶
Dimension type.
- class DimensionType[source]¶
Bases:
enum.EnumType of the extracted value
- GENERAL¶
- AMOUNT_OF_MONEY¶
- NAME¶
- DISTANCE¶
- DURATION¶
- ORDINAL¶
- NUMERAL¶
- TIME¶
- ARABIC¶
- ENGLISH¶
- ARABIC_LETTERS¶
- ENGLISH_LETTERS¶
- ENGLISH_SMALL_LETTERS¶
- ENGLISH_CAPITAL_LETTERS¶
- NUMBERS¶
- HARAKAT¶
- ALL_HARAKAT¶
- TATWEEL¶
- PUNCTUATIONS¶
- ARABIC_NUMBERS¶
- ENGLISH_NUMBERS¶
- ARABIC_PUNCTUATIONS¶
- ENGLISH_PUNCTUATIONS¶
- ARABIC_LIGATURES¶
- ARABIC_HASHTAGS¶
- ARABIC_MENTIONS¶
- EMAILS¶
- ENGLISH_HASHTAGS¶
- ENGLISH_MENTIONS¶
- HASHTAGS¶
- LINKS¶
- MENTIONS¶
- EMOJIS¶
- class NumeralType[source]¶
Bases:
enum.EnumGeneric enumeration.
Derive from this class to define new enumerations.
- DECIMALS¶
- INTEGERS¶
- ONES¶
- TENS¶
- HUNDREDS¶
- THOUSANDS¶
- MILLIONS¶
- BILLIONS¶
- TRILLIONS¶
- class OrdinalType[source]¶
Bases:
enum.EnumGeneric enumeration.
Derive from this class to define new enumerations.
- ONES¶
- TENS¶
- HUNDREDS¶
- THOUSANDS¶
- MILLIONS¶
- BILLIONS¶
- TRILLIONS¶
- class Day[source]¶
Bases:
enum.EnumGeneric enumeration.
Derive from this class to define new enumerations.
- MONDAY = 0¶
- TUESDAY¶
- WEDNESDAY¶
- THURSDAY¶
- FRIDAY¶
- SATURDAY¶
- SUNDAY¶
- class Month[source]¶
Bases:
enum.EnumGeneric enumeration.
Derive from this class to define new enumerations.
- JANUARY¶
- FEBRUARY¶
- MARCH¶
- APRIL¶
- MAY¶
- JUNE¶
- JULY¶
- AUGUST¶
- SEPTEMBER¶
- OCTOBER¶
- NOVEMBER¶
- DECEMBER¶
- class TimeUnit[source]¶
Bases:
UnitBase class for all units
- SECONDS¶
- MINUTES¶
- HOURS¶
- DAYS¶
- MONTHS¶
- YEARS¶
- class DurationUnit[source]¶
Bases:
UnitBase class for all units
- SECONDS¶
- MINUTES¶
- HOURS¶
- DAYS¶
- WEEKS¶
- MONTHS¶
- YEARS¶
- class TextExpression(pattern, pickle=False)[source]¶
Bases:
maha.rexy.ExpressionExpression that returns the matched text as value
- Parameters
pattern (str) –
pickle (bool) –
- class Value(value, pattern, pickle=False)[source]¶
Bases:
maha.rexy.ExpressionExpression that returns a predefined value if the pattern matches.
- Parameters
value (Any) –
pattern (str) –
pickle (bool) –
- value :Any¶
- class MatchedValue(expressions, pattern)[source]¶
Bases:
ValueExpression that returns a predefined value of a matched expression from the input expressions
- Parameters
expressions (ExpressionGroup) – The expressions to match
pattern (str) – The pattern to match
- Returns
The result of the expression
- Return type
- class FunctionValue(function, pattern, pickle=True)[source]¶
Bases:
ValueExpression that returns the output value of an input function when matched.
- Parameters
function (Callable) – The function to be called when the pattern matches.
pattern (str) – The pattern to be matched.
pickle (bool) –
- Returns
The result of the expression.
- Return type