Skip to main content

SearchString is a custom implementation for searching strings for overvaagning.app.

Project description

Search String

GitHub Workflow Status (branch) PyPI - Version PyPI - Python Version

Installation

You can install search-string from PyPI:

$ pip install search-string-overvaagning

The package is supported on Python 3.7+.

About

This package implements the search string object that is used across overvaagning.app for different types of surveillance.

It is used for searching a text. For something to be deemed a match, the text must match the first_str and if the second_str is not empty, the text must also match the second_str. If the not_str is not empty, the text must not match the not_str. A logical AND is used between the three conditions. The three strings can each be a collection of strings separated by semicolons wherein a match is deemed by logical OR. You can use '~' to make a word boundary. Finally, you can use !global at the end of a string to signal that that part should check globally.

Quick examples:

>>> ss = SearchString('example;hello', 'text', 'elephant', data=None)
>>> ss.match('This is an example text')
True
>>> ss.match('This text says hello')
True
>>> ss.match('This is just an example')
False

Usage

Creating Search Strings

Start by importing the SearchString class:

>>> from search_string import SearchString

Construct a new search string by supplying the first_str, second_str, not_str and any data that can be useful to refer back to later, such as an ID:

>>> ss = SearchString('first', '', '', data=2)

Optionally, you can also supply a third_str that works in the same was as first_str and not_str but has to be supplied as a keyword argument:

>>> ss = SearchString('first', '', '', data=2, third_str='third')

Matching text

If you just need to find out whether a given search string matches a text, you can use the method .match on a SearchString instance.

Often, what you want to do, is to match a collection of search strings across a list of text, e.g. sentences. You can do that the following way:

>>> from search_string import SearchString
>>> search_strings = [
...    SearchString('kan', '', 'ritzau', data=1),
...    SearchString('kan', '', 'ritzau!global', data=2)
... ]
>>> sentences = [
...    'Du kan skrive din tekst her.',
...    'Den kan bestå af flere sætninger.',
...    'Dig og Ritzau kan bestemme hvordan det skal være.',
...    'Nogle kan være lange, andre kan være korte.'
... ]
>>> res = SearchString.find_all(sentences, search_strings)
>>> res
[SearchString(kan, -, ritzau, data=1)]

For each of the matched search strings (in the above example, only one), you can extract the data and the matched text as follows:

>>> res[0].data
1
>>> res[0].matched_text
'Du kan skrive din tekst her. Den kan bestå af flere sætninger. (...) Nogle kan være lange, andre kan være korte.'
>>> res[0].matched_text_highligthed
'Du <b>kan</b> skrive din tekst her. Den <b>kan</b> bestå af flere sætninger. (...) Nogle <b>kan</b> være lange, andre <b>kan</b> være korte.'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

search_string_overvaagning-0.2.1-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

search_string_overvaagning-0.2.1-cp311-cp311-win_amd64.whl (53.2 kB view details)

Uploaded CPython 3.11Windows x86-64

search_string_overvaagning-0.2.1-cp311-cp311-win32.whl (48.2 kB view details)

Uploaded CPython 3.11Windows x86

search_string_overvaagning-0.2.1-cp311-cp311-musllinux_1_1_x86_64.whl (122.9 kB view details)

Uploaded CPython 3.11musllinux: musl 1.1+ x86-64

search_string_overvaagning-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (127.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

search_string_overvaagning-0.2.1-cp311-cp311-macosx_10_9_x86_64.whl (74.6 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

search_string_overvaagning-0.2.1-cp310-cp310-win_amd64.whl (53.5 kB view details)

Uploaded CPython 3.10Windows x86-64

search_string_overvaagning-0.2.1-cp310-cp310-win32.whl (48.5 kB view details)

Uploaded CPython 3.10Windows x86

search_string_overvaagning-0.2.1-cp310-cp310-musllinux_1_1_x86_64.whl (123.2 kB view details)

Uploaded CPython 3.10musllinux: musl 1.1+ x86-64

search_string_overvaagning-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (127.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

search_string_overvaagning-0.2.1-cp310-cp310-macosx_10_9_x86_64.whl (75.4 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

search_string_overvaagning-0.2.1-cp39-cp39-win_amd64.whl (53.5 kB view details)

Uploaded CPython 3.9Windows x86-64

search_string_overvaagning-0.2.1-cp39-cp39-win32.whl (48.5 kB view details)

Uploaded CPython 3.9Windows x86

search_string_overvaagning-0.2.1-cp39-cp39-musllinux_1_1_x86_64.whl (122.9 kB view details)

Uploaded CPython 3.9musllinux: musl 1.1+ x86-64

search_string_overvaagning-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (127.6 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

search_string_overvaagning-0.2.1-cp39-cp39-macosx_10_9_x86_64.whl (75.4 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

search_string_overvaagning-0.2.1-cp38-cp38-win_amd64.whl (52.8 kB view details)

Uploaded CPython 3.8Windows x86-64

search_string_overvaagning-0.2.1-cp38-cp38-win32.whl (48.0 kB view details)

Uploaded CPython 3.8Windows x86

search_string_overvaagning-0.2.1-cp38-cp38-musllinux_1_1_x86_64.whl (121.0 kB view details)

Uploaded CPython 3.8musllinux: musl 1.1+ x86-64

search_string_overvaagning-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (124.5 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

search_string_overvaagning-0.2.1-cp38-cp38-macosx_10_9_x86_64.whl (74.3 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

search_string_overvaagning-0.2.1-cp37-cp37m-win_amd64.whl (52.3 kB view details)

Uploaded CPython 3.7mWindows x86-64

search_string_overvaagning-0.2.1-cp37-cp37m-win32.whl (47.5 kB view details)

Uploaded CPython 3.7mWindows x86

search_string_overvaagning-0.2.1-cp37-cp37m-musllinux_1_1_x86_64.whl (105.7 kB view details)

Uploaded CPython 3.7mmusllinux: musl 1.1+ x86-64

search_string_overvaagning-0.2.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (109.0 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

search_string_overvaagning-0.2.1-cp37-cp37m-macosx_10_9_x86_64.whl (72.7 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

File details

Details for the file search_string_overvaagning-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 92614932c97290f1adda5fce23eda849d030fc2a5868992998379b516db02ccd
MD5 69e6cc43e4575bc910f4f47183566f12
BLAKE2b-256 a4272a5c9e27e98a4f1d53f1ca87ad9dcb8afc48027880b1a9c376fba3c73fa2

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 229807f6a3e5615c9c5afc6919c4ffa0df9e4813c89ba2a3bc1dbf3647495d9c
MD5 e5bb9670c21026c51f8e348adfb72f98
BLAKE2b-256 42f98a5ea59faefbfab6097e923411acb08056e07227643626309bd71218df35

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp311-cp311-win32.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 dd5c1ca293aa3c7a33273361b2073c5862695d2b46f06a4b70f2fdf931927302
MD5 5822dc9cae90ff8b1afcf201b55cdcca
BLAKE2b-256 02ebd0054488d1496dcc7d58c5253ff054ce5754d14cf821fb8a91b752b12862

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp311-cp311-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 ce74b123e86b42c900fb92ba35072c4161fbd063cf7bb0159ac96e1b3315974b
MD5 4bb43040087d0146f9a77edb5df6ccb3
BLAKE2b-256 7c18b9f387ebd3e71a42797bb77641679dc9814a5ffd55836df06579e5fb1ff3

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c0ed34536217c2dfde36c5c739045a297140472f01b2b0fd4d9777bfc3f07882
MD5 990706ebb3010fe7a466cafb940ecb3e
BLAKE2b-256 b8f9ac3433def2b610469916bb24f9cf2af2d29e35ff52da3a70b03b324177a0

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4012188a06c83de67a9faa78623edfb1be84bbe44453c11905c00bc9ad72b45b
MD5 d76dfb54da8faa9f1cbeb5ae0b2d3b42
BLAKE2b-256 ecde8a4e41c4a143faf2457ce1b76e55fc0c117412adc058b86441371dbf1417

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8bc27ba556e482771d8534be68f65364960c696ab8d70ed57a62371103a86b22
MD5 7ad2ec7e1455cef6e1036b6f4608374d
BLAKE2b-256 e98f6a34e4cbc8cab702755a410339ff3bfbe60521f1c2efaec3042f5ffffa55

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp310-cp310-win32.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 3746295770d1e65c388df7a1eb1f7bd2515116494034a646e0432e8d54a7ecdf
MD5 d0760243c5f63f7d945e93a1a769d410
BLAKE2b-256 e4e573a01170d2c8d310bbae02627a2c4427d9881f1c2e2454f2e479b3b288d3

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp310-cp310-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 a048700eebd05cca3d032aaeba800e728ee586c89d3a2e6209d2fa69d4956f2f
MD5 cfbb826600f32ef6bd5cb5cb7129a64a
BLAKE2b-256 e04a757d1665206d9d8bcf68086e464af37ce8d535f20ce0895a32a2477c6098

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 03b5692195c0f82c623844eb5cd644ac8cae378872628788520986cee4f5b2bf
MD5 f2bf0b8d9df71be518f8f5262b6df3e9
BLAKE2b-256 01e7ed2d4022ece1840c330d597a773a269c146c2dc58fa445acc828f06eb341

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8826aeb2d123847390f742789db1740aacd96c3c53caeeb0ad94e05b00874196
MD5 1650b489285da4aed96d1bf1b723f574
BLAKE2b-256 61a41c89a934285f7890c0ea6f7ef0b4d045ea4feb8c8319bd60c5d4a0d245f2

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 152c9616ae0ee4a05db04b608ab36bc6bdf823251544f71cef7f6cb9a422659d
MD5 40db8a1cfbac31f8baa69924365aa946
BLAKE2b-256 db86f83e13f54cd7781cb04404d7044dec24b4c684875e11f5c77d2c2869cbdf

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp39-cp39-win32.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 8ad6ab68f1dd2ae55454657167adc9765ac157929b92287f7d283140e282daa6
MD5 d87876da1c1eeae7310507f306b054bb
BLAKE2b-256 ff5bfd6ec87e4ae93932707bac100fe4ae2344be7e6e4ecacc8d8960afe618c8

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp39-cp39-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 a43a36bda66fa1aff9990973bace56b6c454199a1691373033ddb9eb1d1239ef
MD5 2744e0e0f93ca94f71b7a1635e0f7267
BLAKE2b-256 caf02a38038beac2cd62d116338553c8f6e1b8393f1ff493109fdede45313e5a

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6a929f00cc624de8267abe3959c4863dacec6effdb3d9a010a81fc01c09a61e0
MD5 866d66c283a1100da3aab8021a48a98b
BLAKE2b-256 947de851fa557a5904af4797464f47b2ebdd0c0eed6168e2320d2f27bb9c9f14

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0dfa2e01068e5c30ff7813ed956d5320be7638b82ee3c097287132e06e3a1ef4
MD5 d84da317c6b9606081db79258afcea9b
BLAKE2b-256 3f6ee85b4006a775dd611ef1c736e408597c49a8a217125a6cf80189a620a109

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 2ac3ce5750d04295e7ef38669fb498ba217eeecc75e233846d4592bfdd43991d
MD5 13481ec66dccd2750e83198159d74102
BLAKE2b-256 028f1f948e348be9c08d7a44cd745044d4c23f39f3eeb70ac8b9309ad72486d5

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp38-cp38-win32.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 42dac77df309d82337a8237b95c71ab2f5d8e6f229f518e3332366d35641ce29
MD5 ceddb426bbc0c67328106d35a80f56c6
BLAKE2b-256 5d859ec5705a706d617f872ba0983d4d091ff5046f8cf681ac81cb1d6ae7b575

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp38-cp38-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 b7da0055d4db9e047cfecccd4a3148043d80e8f1337b1bb078631267c1660031
MD5 40a64d6a2ed6ae9c81784c8c502fa039
BLAKE2b-256 ef0b14aae99a05b6c17e295ea4c42b3bfca409d144a90e438f66b6560be61632

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0e43bc5d4d590aa3ab80d29b8f8acccdb41d4e0514044aef784b86081e26b1c2
MD5 55cb537cdfb0e8b31c89259659564689
BLAKE2b-256 3b6f11e7166ff1c085b7a4c585a3d04b53651edcf2b3ed25470799bbda27edd5

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e66000e3c48422651cac793b27aeed148c7080588ed9e0390a3844f3ac246214
MD5 72679f7cb3c520dbac4266e0d41046de
BLAKE2b-256 60e87fa4453c71f1a6b0425aecb5cef7fd5dd5bc7115888569006e6646c10cd2

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp37-cp37m-win_amd64.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 ee571ab3fa88396d36b9c1953dc2c1fc4b5d07cad49f5ca616926e0d30e03cf5
MD5 ea0a667ded5e5492f7094d66d93ddf1a
BLAKE2b-256 e9429a404e561b0d1ff30d1aea86002192328a84a1dc65405dbd2cb37babaf31

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp37-cp37m-win32.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 1d478535800b4dda9e838e5e445562d35eb0d67b5d53d8da3c81b389bd18767e
MD5 8b4643c21cdb42e16eea750c5974993c
BLAKE2b-256 ad66b2bf3a8058031f734a057432165938aeac943ef2f5163ca1e921295ca0a5

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp37-cp37m-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 67b6264e0a0bc224dd0d9725685aced6345975547cae87718f4069e4a2169567
MD5 3240da0a2a31bfff3aa70067ee737406
BLAKE2b-256 5710f0695ae3f90f5f0d38cafce3c538bfe1bb4366f2b625674539d11e9421ba

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 459e4ed845597d440abb71d96be93aa08b6d690a57cf8f5350968651667a153a
MD5 ecafe86064a182987a964b922a6dc07f
BLAKE2b-256 26fd9bb340541c9416e5ccfd671777ed3dca50c14eddea9388186cf84ab8e7b7

See more details on using hashes here.

File details

Details for the file search_string_overvaagning-0.2.1-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for search_string_overvaagning-0.2.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 148cdaa73e4f4d08799112ef6dcfdd7a77206fd7f506ce0fe0c964cf186de75e
MD5 29462c1c0ef90a5acf03a9a8ca036112
BLAKE2b-256 01c641a857a1928b3a5d6d84af52ffc3db6f8aeb376179d2200e1ca71a4b04a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page