@@ -419,7 +419,7 @@ def __init__(self, text=''):
419
419
elif text :
420
420
self .text = text
421
421
self .ntext = self ._convert_numbers (self .text )
422
- self ._text_ = ' ' + self .text + ' ' # some complex regular expressions were easier to write for padded text
422
+ self ._text_ = ' ' + self .text + ' ' # some complex regular expressions were easier to write for padded text
423
423
self ._ntext_ = ' ' + self .ntext + ' ' # some complex regular expressions were easier to write for padded text
424
424
425
425
##### DATA MODEL #####
@@ -505,10 +505,10 @@ def digits(self,n=0,normalize=True,convert=True):
505
505
def numbers (self ,decimals = True ,convert = True ):
506
506
if self .text :
507
507
if decimals :
508
- matches = _re .findall (r'(?<!\d)(?<!\-)(( ?:\-\s?)?(?:(?:\d\s?)+(?:[\.\,]\d+[^\.\,])?|(?:[\.\,]\d+[^\.\,]))\- ?)' , re .IGNORECASE , self ._ntext_ if convert else self ._text_ )
508
+ matches = _re .findall (r'(?<!\d)(?<!\-)(?<!\:)(( ?:\-\s?)?(?:(?:\d\s?)+(?:[\.\,]\d+[^\.\,])?|(?:[\.\,]\d+[^\.\,\: ]))[\-\:] ?)' , re .IGNORECASE , self ._ntext_ if convert else self ._text_ )
509
509
okay = []
510
510
for item in matches :
511
- if item [- 1 ]!= '-' :
511
+ if item [- 1 ] not in ( '-' , ':' ) :
512
512
item = item .replace (',' ,'.' )
513
513
if not item [- 1 ].isnumeric ():
514
514
item = item [:- 1 ]
@@ -525,8 +525,8 @@ def numbers(self,decimals=True,convert=True):
525
525
pass
526
526
return okay
527
527
else :
528
- matches = _re .findall (r'(?<!\d\-)(?<![\.\,\d])(\-?(?:\d\s?)+(?![\.\,]\d))[^\d\-]+' , re .IGNORECASE , self ._ntext_ if convert else self ._text_ )
529
- okay = [item for item in matches if item and item [- 1 ]!= '-' ]
528
+ matches = _re .findall (r'(?<!\d\-)(?<![\.\,\d])(\-?(?:\d\s?)+(?![\.\,]\d))[^\d\-\: ]+' , re .IGNORECASE , self ._ntext_ if convert else self ._text_ )
529
+ okay = [item for item in matches if item and item [- 1 ] not in ( '-' , ':' ) ]
530
530
return [int ('' .join (number .strip ().split ())) for number in okay ]
531
531
return []
532
532
@@ -925,8 +925,6 @@ def _currencies_fallback(self):
925
925
elif item in number :
926
926
okay .append (item )
927
927
return okay
928
-
929
-
930
928
931
929
# extract commands and arguments from text: "/help lara" will return ('help',['lara'])
932
930
def commands (self ):
0 commit comments