Start position always 0
macwilam opened this issue · 1 comments
macwilam commented
Hi,
I am trying to use python-hyperscan and start is always 0. Below my code:
regList = ['home']
allResultsMap = {i:reg for i,reg in enumerate(regList)}
db = hyperscan.Database()
def on_match(pattern_id, start, end, flags, context):
print(start,end)
return None
text = "my sweet home"
expressions, ids, flags = zip(*[(full_expr(reg).encode(),i,0) for i,reg in enumerate(regList)])
db.compile(
expressions=expressions, ids=ids, elements=len(expressions), flags=flags
)
db.scan(text, match_event_handler=on_match)
The output is :
0 13
Ubuntu 20.04, python 3.8, libhyperscan5/focal,now 5.2.1-1build1 amd64 [installed]
Am I doing something wrong?
macwilam commented
I didnt read the docs carefully enough. If anyone has a similar problem it is a bout the flag:
hyperscan.HS_FLAG_SOM_LEFTMOST