maha.parsers.templates

Submodules

Package Contents

Classes

Dimension

Template for the parsed item

DimensionType

Type of the extracted value

NumeralType

Generic enumeration.

OrdinalType

Generic enumeration.

Day

Generic enumeration.

Month

Generic enumeration.

Unit

Base class for all units

TimeUnit

Base class for all units

MoneyUnit

Base class for all units

DistanceUnit

Base class for all units

DurationUnit

Base class for all units

TextExpression

Expression that returns the matched text as value

Value

Expression that returns a predefined value if the pattern matches.

MatchedValue

Expression that returns a predefined value of a matched expression from the input

FunctionValue

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

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.Enum

Type 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
MENTIONS
EMOJIS
class NumeralType[source]

Bases: enum.Enum

Generic enumeration.

Derive from this class to define new enumerations.

DECIMALS
INTEGERS
ONES
TENS
HUNDREDS
THOUSANDS
MILLIONS
BILLIONS
TRILLIONS
class OrdinalType[source]

Bases: enum.Enum

Generic enumeration.

Derive from this class to define new enumerations.

ONES
TENS
HUNDREDS
THOUSANDS
MILLIONS
BILLIONS
TRILLIONS
class Day[source]

Bases: enum.Enum

Generic enumeration.

Derive from this class to define new enumerations.

MONDAY = 0
TUESDAY
WEDNESDAY
THURSDAY
FRIDAY
SATURDAY
SUNDAY
class Month[source]

Bases: enum.Enum

Generic enumeration.

Derive from this class to define new enumerations.

JANUARY
FEBRUARY
MARCH
APRIL
MAY
JUNE
JULY
AUGUST
SEPTEMBER
OCTOBER
NOVEMBER
DECEMBER
class Unit[source]

Bases: enum.Enum

Base class for all units

class TimeUnit[source]

Bases: Unit

Base class for all units

SECONDS
MINUTES
HOURS
DAYS
MONTHS
YEARS
class MoneyUnit[source]

Bases: Unit

Base class for all units

EURO
DOLLAR
POUND
class DistanceUnit[source]

Bases: Unit

Base class for all units

METER
MILE
class DurationUnit[source]

Bases: Unit

Base class for all units

SECONDS
MINUTES
HOURS
DAYS
WEEKS
MONTHS
YEARS
class TextExpression(pattern, pickle=False)[source]

Bases: maha.rexy.Expression

Expression that returns the matched text as value

Parameters
  • pattern (str) –

  • pickle (bool) –

class Value(value, pattern, pickle=False)[source]

Bases: maha.rexy.Expression

Expression that returns a predefined value if the pattern matches.

Parameters
  • value (Any) –

  • pattern (str) –

  • pickle (bool) –

value :Any
class MatchedValue(expressions, pattern)[source]

Bases: Value

Expression 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

ExpressionResult

class FunctionValue(function, pattern, pickle=True)[source]

Bases: Value

Expression 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

ExpressionResult