insperatum / pregex

Probabilistic regular expressions
18 stars 4 forks source link

Python 2 compatibility #1 #1

Open mtensor opened 6 years ago

mtensor commented 6 years ago

pre.Alt([pre.create("T"), pre.create("\d")]).match("4")

causes the error:

  File "<stdin>", line 1, in <module>
  File "pregex/pregex.py", line 106, in match
    for remainderMatch in continuation.consume(remainder, state):
  File "pregex/pregex.py", line 238, in consume
    extraScore = math.log(p)

Also, v = pre.create("T|\d").sample()

causes the error:

  File "<stdin>", line 1, in <module>
  File "pregex/pregex.py", line 228, in sample
    value = np.random.choice(values, p=self.ps)
  File "mtrand.pyx", line 1146, in mtrand.RandomState.choice
ValueError: probabilities do not sum to 1