Skip to main content

os2ds-rules: Next-generation, high-performance rule system for OS2datascanner

os2ds-rules is the next-generation rules system for use in OS2datascanner by Magenta ApS, which aimes to deliver high-performance with regards to processing speed and detection accuracy.

The project consists of several components:

  • A shared-library backend written in modern C++20.
  • A Python C/C++ extension that exposes functionality from the backend to python.
  • A python library that provides a safe, easy-to-use interface to the aforementioned extension.

WARNING: This is currently in a very early stage of development and frequently undergoes substantial changes, so it is not ready for prime time, yet.

Getting Started

You can install either or both of the C++ library or the python extension.

C++ backend library: libos2dsrules

For the C++ library you need a few different things:

  • A compiler that supports C++20. We recommend using either g++ (GCC) or clang (LLVM).
  • cmake>=3.20: Primary (meta) build system.
  • ninja: Cross-platform backend for cmake.
  • gtest (Google Test): For building and running the test suite.

For development, you additionally want:

  • cppcheck or clang-analyzer: For static code analysis.
  • clang-format: For formatting C++ code. We adhere to the LLVM style guide.
  • clang-tidy: For C++ code linting.
  • gdb or lldb: A suitable debugger.

To make a debug build on linux, run the following:

# Make a build directory 
cmake . --preset linux-debug
cmake --build --preset linux-build-debug

This will build the shared library libos2dsrules.so and the test suite testsuite.

To install the library, run the following from the build directory:

sudo cmake --install build_cmake/debug

By default, this will install headers into /usr/include and shared objects to /usr/lib.

To run the test suite:

ctest --preset linux-test-debug

Currently, this has only been tested on linux. It remains to be tested on windows and macos.

Using CMake preset workflows

There are four preconfigured workflows that has been automated with cmake:

  • linux-debug-workflow: Configures, Builds and Tests the debug version of the library for linux.
  • linux-release-workflow: Configures, Builds and Packages the release version of the library for linux.
  • windows-debug-workflow: Configures, Builds and Tests the debug version of the library for windows.
  • windows-release-workflow: Configures, Builds and Packages the release version of the library for windows.

For example, to run a debugging workflow on linux, use:

cmake --workflow --preset linux-debug-workflow

The Python extension: os2ds-rules

You need the following:

  • A compiler that supports C++20. We recommend using either g++ (GCC) or clang (LLVM).
  • The CPython development headers and libraries.
  • setuptools: For building the extension.
  • pytest: For python tests.
  • pytest-benchmark: For python benchmarks.

NOTE: Depending on what OS you use and how CPython was installed on your system, the development headers and libraries may or may not be installed.

The development headers and libraries can be installed using a package manager on the following systems:

  • ubuntu/debian: sudo apt install python3-dev
  • fedora: sudo dnf install python3-devel

To build the extension:

# From the project root.
python3 -m setup build

To install the extension locally:

# From the project root.
# You may want to use the `-e` option during development.
python3 -m pip install .

Uninstalling is as easy as running:

pip uninstall os2ds-rules

Running the benchmark

After having installed the extension as described above, run the benchmarks with:

python3 -m pytest --benchmark-only test/benchmarks/

Currently, you need to build and install the extension before running the benchmark until this gets fixed.

Python Interpreter support

The Python3 extension uses the CPython C-API, which is supported by CPython as standard.

We aim to support the PyPy interpreter as well.

Usage Examples

In Python

Let us scan a python str for occurances for CPR-Numbers:

from os2ds_rules import CPRDetector


detector = CPRDetector()

matches = detector.find_matches('This is a fake, but valid CPR-Number: 1111111118')

for m in matches:
	print(m)

In C++

Consider this simple file, test.cpp:

#include <os2dsrules.hpp>
#include <name_rule.hpp>

#include <iostream>
#include <string>

using namespace OS2DSRules::NameRule;

int main(void) {
    NameRule rule;
    std::string s = "This is my friend, John.";
    auto results = rule.find_matches(s);

    std::cout << "Found matches: \n";
    for (auto m : results) {
        std::cout << m.match() << '\n';
    }

    return 0;
}

To compile, using clang, simply run:

clang++ -los2dsrules -std=c++20 test.cpp -o test 

This will produce an executable test in the current working directory.

Running it:

$ ./test
Found matches:
John

Release files for os2ds-rules 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for os2ds-rules 0.1.0
File Size Uploaded
os2ds-rules-0.1.0.tar.gz 25.4 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for os2ds-rules 0.1.0
File
os2ds_rules-0.1.0-pp39-pypy39_pp73-win_amd64.whl PyPy 3.9 PyPy 3.9 7.3 Windows x86-64 Details
os2ds_rules-0.1.0-pp39-pypy39_pp73-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl PyPy 3.9 PyPy 3.9 7.3 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
os2ds_rules-0.1.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
os2ds_rules-0.1.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
os2ds_rules-0.1.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
os2ds_rules-0.1.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
os2ds_rules-0.1.0-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
os2ds_rules-0.1.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details

Total release size: 13.5 MB

Release files / os2ds-rules-0.1.0.tar.gz

Download URL os2ds-rules-0.1.0.tar.gz
Size 25.4 kB
Tags Source
SHA-256 checksum
How to use checksums
32fcb9e16b04b8761878c4d9654ae68ab09776c5df720632e51af2b734dbbfd8
BLAKE2b-256 checksum
How to use checksums
42eb45594759d6007292369f283819556e1a4c7575bff62abd9ff63f79168a42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / os2ds_rules-0.1.0-pp39-pypy39_pp73-win_amd64.whl

Download URL os2ds_rules-0.1.0-pp39-pypy39_pp73-win_amd64.whl
Size 1.2 MB
Tags PyPy 3.9 PyPy 3.9 7.3 Windows x86-64
SHA-256 checksum
How to use checksums
7df797377bc0d832bced852d293948c0b2ea605441fa89eccb20b12128331e4c
BLAKE2b-256 checksum
How to use checksums
8aeb63c9a9469f72eadcd79c987849e49e2dbeec80154a2d0ea8e626ae57ea97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / os2ds_rules-0.1.0-pp39-pypy39_pp73-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL os2ds_rules-0.1.0-pp39-pypy39_pp73-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 1.7 MB
Tags Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 PyPy 3.9 PyPy 3.9 7.3
SHA-256 checksum
How to use checksums
75be425ef250aa08dca22a8f9b29697a6f685b0fe6f66a7a25952a357e4d9289
BLAKE2b-256 checksum
How to use checksums
c48d7caf1af57c5a9b4afa676d536293a6505e5c48718bab1516dbae4053e0a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / os2ds_rules-0.1.0-cp311-cp311-win_amd64.whl

Download URL os2ds_rules-0.1.0-cp311-cp311-win_amd64.whl
Size 1.2 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
d53a17f66fe1374789514360ab7bb4cec83aec8a31e9477cc2b651bdae79a2ef
BLAKE2b-256 checksum
How to use checksums
c7f7bdce987e000e60d5dbb27bb8a922ee9b45757647d0b9c2612bb1f8594012
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / os2ds_rules-0.1.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL os2ds_rules-0.1.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 2.3 MB
Tags CPython 3.11 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
dc56412a44193ccf491c2d13520bbf17c5b3614af0a54abd054d84197b3a816a
BLAKE2b-256 checksum
How to use checksums
8c1c9dc3a99af9a711b58e42fb2bfc8b6311d80bd44769620abd5ec3042e27b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / os2ds_rules-0.1.0-cp310-cp310-win_amd64.whl

Download URL os2ds_rules-0.1.0-cp310-cp310-win_amd64.whl
Size 1.2 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
162cc3770de675ed580f9d486ac2987237f655481cc35cfaf3ae823d04017088
BLAKE2b-256 checksum
How to use checksums
ed6959159a2dd5d90ea16f16865a0c8b2bb3bf6feb47467b11d3b5aaebd076e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / os2ds_rules-0.1.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL os2ds_rules-0.1.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 2.3 MB
Tags CPython 3.10 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
db761f480a72bccabe8a72640d8c863742d3f9a7ce03d153f413b7b83136393f
BLAKE2b-256 checksum
How to use checksums
84198c6059d2ec22acc6d6285dd9c3a6deffce83d195ee01c3699e98dd60f779
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / os2ds_rules-0.1.0-cp39-cp39-win_amd64.whl

Download URL os2ds_rules-0.1.0-cp39-cp39-win_amd64.whl
Size 1.2 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
15aef1457b2cc01d498b07b205ccafddeefd5c8a91b30508d867c37bdd20ebc4
BLAKE2b-256 checksum
How to use checksums
0f81bc1f2fac914db9bccc2db57d6fd26346db06a5c7e1f37c5be6b2af57477c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / os2ds_rules-0.1.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL os2ds_rules-0.1.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 2.3 MB
Tags CPython 3.9 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
dc9d53c1e7c58dc0d8839586b9e6753c2024d911b82e2222757b4c3ad7c3079e
BLAKE2b-256 checksum
How to use checksums
b5a3cd06e03e16753e60c495a7ef3ab91027d978691f7767b0dd5ecb55f578e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release history Release notifications | RSS feed

This release

0.1.0 This release

9 release files

0.0.9

9 release files

0.0.8

9 release files

0.0.7

9 release files

0.0.6

9 release files

0.0.5

9 release files

0.0.4

9 release files

0.0.3

9 release files

0.0.2

9 release files

0.0.1

9 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page