Comments (6)
going to improve type annotations and tests to cover this, as well as docs, but basically the issue is the returned Database doesn't include a scratch. try this:
hdb.scratch = hyperscan.Scratch(db)
hdb.scan(b"aaa")
also you'll have to keep track of the mode of the database that the serialized representation was created with. i.e. if it was created with stream mode, you'll have to use the stream context manager. currently db.mode isn't set on the returned db object, which I'll try to fix.
from python-hyperscan.
I am using hyperscan version 0.4.0
from python-hyperscan.
Steps:
f = open("local/keyword_features_hyperscan_databases/TestKeyword1", 'rb')
hdb = hyperscan.loadb(f.read())
hdb.scan("aaa")
gives:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: a bytes-like object is required
TestKeyword1 is a simple test database with a few words that is being compiled a moment before during tests.
from python-hyperscan.
try hdb.scan(b"aaa")
from python-hyperscan.
hdb.scan(b"aaa")
didn't help. But switching back to hyperscan version 0.3.3 solved the issue.
from python-hyperscan.
@darvid Is there any reason that the scratch can't (or shouldn't) be initialized automatically if it's missing? At minimum, it would obviously help to have a more informative error :)
(Also, it looks like there's a small typo in your code example above where the parameter to the Scratch
constructor should be hdb
instead of db
.)
from python-hyperscan.
Related Issues (20)
- symbol not found in flat namespace '_ch_alloc_scratch' HOT 10
- Add args for early termination of scanning if only need to find one match regex or just judging matched
- Import time slowness due to pkg_resources HOT 1
- How to match an exact string with hyperscan like with re.findall
- Handling scan termination from match callback could be cleaner HOT 2
- switch to vectorscan HOT 2
- Request for maintainer(s) HOT 5
- multiprocessing problem.
- Memory leak in Database object when compiling, dumping and loading. HOT 15
- Named capture groups with Chimera
- install by Dockerfile
- v0.2.0 does not work with Python 3.10 HOT 5
- ModuleNotFoundError: No module named 'hyperscan._hyperscan'
- when it will be ready for windows ? HOT 1
- Please do a release HOT 1
- Problem with musl and fat runtime? HOT 5
- pypi don't have py3.9 whl release and tar.gz with source code HOT 2
- Python 3.10 using error
- Can't import from hyperscan in python 3.12 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-hyperscan.