Skip to main content

Forseti Language

The system for determining the compliance of the text with the specified rules

How to install:

PyPi installation guide

pip install forseti-lang

How to use:

from forseti_lang.execute import execute_condition

condition = "TRUE AND FALSE"
text = ""
execute_condition(condition, text)  # False

All regular expressions should be in lowercase.

Supported logic operators

English

Below is a table of available logical operators and their description.

Operator Description Priority
() The conditions in quotes will be met first 0
AND Logical AND 1
AND NOT Logical AND NOT 2
OR Logical OR 3
Atoms (TRUE and FALSE) Minimum logical unit 4

Russian

Forseti was developed for the analysis of texts in Russian. So, you can use:

RU ENG
И AND
ИЛИ OR

Note

You can combine ru and eng operators.

Supported functions

We really lacked a simple syntax (but regular expressions did not allow us to achieve this), so we created our own functions!

Function In Forseti Description Priority
f text length ll, lg Text length in characters check function 5
f words distance wN, cN, N Checks whether the words are in the specified interval 6
f words nearby nearby Checks the words that are next to another word 7
f regex search Checks the occurrence of a regular expression in the text 8

Explanations

  • |ll - length less (in characters)
  • |lg - length great (in characters)
  • |wN - word in distance N words
  • |cN - word in distance N characters
  • |N - alias of |wN
  • |nearby - the word is nearby to the words word1 |nearby word2 | word3 | word4

Notes

  • All function starts with special character: |. That's why we don't support it in regular expressions
  • It is also forbidden to use the - character, it is used in the distance function
  • The function of finding words at a distance will allow you to exclude constructions with a word at a distance, for example:
condition - "hello |w1 -world"
text      - "Hello beautiful world!"
result    - False
  • You cannot combine two functions in one expression
  • Text length and word distance functions don't work with negative values

Priority table

Operator Description Priority
() The conditions in quotes will be met first 0
AND Logical AND 1
AND NOT Logical AND NOT 2
OR Logical OR 3
Atoms (TRUE and FALSE) Minimum logical unit 4
f text length Text length in characters check function 5
f words distance Checks whether the words are in the specified interval 6
f words nearby Checks the words that are next to another word 7
f regex search Checks the occurrence of a regular expression in the text 8

Examples

Checking the length of the text

from forseti_lang.execute import execute_condition

condition = '|ll5'
execute_condition(condition, "Hello world!")  # False
execute_condition(condition, "Hi")  # True

condition = '|lg5'
execute_condition(condition, "Hello world!")  # True
execute_condition(condition, "Hi")  # False

Checking the words distance

from forseti_lang.execute import execute_condition

condition = 'hello |w1 world'
execute_condition(condition, "Hello world!")  # True
execute_condition(condition, "Hello sunny world!")  # True
execute_condition(condition, "Hello dirty and dark world!")  # False

condition = 'hi\W? |c1 how are you'
execute_condition(condition, "Hi, how are you?")  # True
execute_condition(condition, "Hi, hmm.. how ary you?")  # False

condition = 'hello |1 world'
execute_condition(condition, "Hello world!")  # True

Checking nearby words

from forseti_lang.execute import execute_condition

condition = 'hello |nearby world | people | notalib'
execute_condition(condition, "Hello world!")  # True
execute_condition(condition, "Hello notalib!")  # True

Logic processing

from forseti_lang.execute import execute_condition

execute_condition("TRUE AND FALSE", "") # False
execute_condition("TRUE OR FALSE", "") # True
execute_condition("FALSE OR TRUE AND (TRUE OR FALSE)", "") # True
execute_condition("FALSE OR TRUE AND (FALSE AND TRUE)", "") # False
execute_condition("(TRUE OR FALSE) AND NOT (TRUE AND FALSE)", "") # TRUE

Difficult rules example

  • короб AND NOT короб |2 конфет
  • минимальн\w,{,2} |1 стоимо
  • балл AND NOT (сн[ия]\w* балл ИЛИ 10\s?балл ИЛИ десять\sбаллов) AND |lg15

Metadata

Release files for forseti-lang 1.0.3

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

Source distribution (sdist)

Source distribution for forseti-lang 1.0.3
File Size Uploaded Provenance Actions
forseti_lang-1.0.3.tar.gz 9.6 kB Without provenance Details for forseti_lang-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for forseti-lang 1.0.3
File Interpreter ABI Platform Actions
forseti_lang-1.0.3-py3-none-any.whl Python 3 none any Details for forseti_lang-1.0.3-py3-none-any.whl

Total release size: 24.9 kB

Release files / forseti_lang-1.0.3.tar.gz

Download URL forseti_lang-1.0.3.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
aefc5ba0ed98ae3479b378b59aaef6c10e095bd727a8f5d1960825fa1498a87a
BLAKE2b-256 checksum
How to use checksums
5fc0d07c15b7a0c9ddf8434aba8206048fe208520e2271cb87217fb351cc6ea2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.1 CPython/3.8.10 Linux/5.4.0-170-generic

Release files / forseti_lang-1.0.3-py3-none-any.whl

Download URL forseti_lang-1.0.3-py3-none-any.whl
Size 15.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f5efef37b1a690103bd40dcd4b95c98357f05e19ae0c149f2bed1429aa8e86ab
BLAKE2b-256 checksum
How to use checksums
d27e3f8fa788f31dee5e447506e6c702da976c333f75d1897e0c80d57f73f7b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.1 CPython/3.8.10 Linux/5.4.0-170-generic

Security for forseti-lang 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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