forseti-lang


Nameforseti-lang JSON
Version 1.0.3 PyPI version JSON
download
home_pagehttps://github.com/Kirill-Lekhov/forseti_lang
SummaryThe system for determining the compliance of the text with the specified rules
upload_time2024-01-30 14:29:57
maintainer
docs_urlNone
authorKirill_Lekhov
requires_python>=3.5,<4.0
licenseMIT
keywords language_processing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Forseti Language

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

## How to install:

PyPi installation guide
```shell
pip install forseti-lang
```

## How to use:

```python
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

```python
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

```python
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

```python
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

```python
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`

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Kirill-Lekhov/forseti_lang",
    "name": "forseti-lang",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.5,<4.0",
    "maintainer_email": "",
    "keywords": "language_processing",
    "author": "Kirill_Lekhov",
    "author_email": "Kirill.Lekhov@mail.ru",
    "download_url": "https://files.pythonhosted.org/packages/5f/c0/d07c15b7a0c9ddf8434aba8206048fe208520e2271cb87217fb351cc6ea2/forseti_lang-1.0.3.tar.gz",
    "platform": null,
    "description": "# Forseti Language\n\nThe system for determining the compliance of the text with the specified rules\n\n## How to install:\n\nPyPi installation guide\n```shell\npip install forseti-lang\n```\n\n## How to use:\n\n```python\nfrom forseti_lang.execute import execute_condition\n\ncondition = \"TRUE AND FALSE\"\ntext = \"\"\nexecute_condition(condition, text)  # False\n```\n\nAll regular expressions should be in lowercase.\n\n## Supported logic operators\n\n### English\n\nBelow is a table of available logical operators and their description.\n\n| Operator               | Description                                 | Priority |\n|------------------------|---------------------------------------------|----------|\n| ()                     | The conditions in quotes will be met first  | 0        |\n| AND                    | Logical **AND**                             | 1        |\n| AND NOT                | Logical **AND NOT**                         | 2        |\n| OR                     | Logical **OR**                              | 3        |\n| Atoms (TRUE and FALSE) | Minimum logical unit                        | 4        |\n\n### Russian\n\nForseti was developed for the analysis of texts in Russian.\nSo, you can use:\n\n| RU  | ENG |\n|-----|-----|\n| \u0418   | AND |\n| \u0418\u041b\u0418 | OR  |\n\n#### Note\n\nYou can combine ru and eng operators.\n\n## Supported functions\n\nWe really lacked a simple syntax (but regular expressions did not allow us to achieve this), so we created our own\nfunctions!\n\n| Function         | In Forseti | Description                                               | Priority |\n|------------------|------------|-----------------------------------------------------------|----------|\n| f text length    | ll, lg     | Text length in characters check function                  | 5        |\n| f words distance | wN, cN, N  | Checks whether the words are in the specified interval    | 6        |\n| f words nearby   | nearby     | Checks the words that are next to another word            | 7        |\n| f regex search   |            | Checks the occurrence of a regular expression in the text | 8        |\n\n### Explanations\n\n* `|ll` - length less (in characters)\n* `|lg` - length great (in characters)\n* `|wN` - word in distance `N words`\n* `|cN` - word in distance `N characters`\n* `|N` - alias of `|wN`\n* `|nearby` - the word is nearby to the words `word1 |nearby word2 | word3 | word4`\n\n#### Notes\n\n* All function starts with special character: `|`. That's why we don't support it in regular expressions\n* It is also forbidden to use the `-` character, it is used in the distance function\n* The function of finding words at a distance will allow you to exclude constructions with a word at a distance,\nfor example:\n```\ncondition - \"hello |w1 -world\"\ntext      - \"Hello beautiful world!\"\nresult    - False\n```\n* You cannot combine two functions in one expression\n* Text length and word distance functions don't work with negative values\n\n## Priority table\n\n| Operator                   | Description                                               | Priority |\n|----------------------------|-----------------------------------------------------------|----------|\n| `()`                       | The conditions in quotes will be met first                | 0        |\n| `AND`                      | Logical `AND`                                             | 1        |\n| `AND NOT`                  | Logical `AND NOT`                                         | 2        |\n| `OR`                       | Logical `OR`                                              | 3        |\n| Atoms (`TRUE` and `FALSE`) | Minimum logical unit                                      | 4        |\n| f text length              | Text length in characters check function                  | 5        |\n| f words distance           | Checks whether the words are in the specified interval    | 6        |\n| f words nearby             | Checks the words that are next to another word            | 7        |\n| f regex search             | Checks the occurrence of a regular expression in the text | 8        |\n\n\n## Examples\n\n### Checking the length of the text\n\n```python\nfrom forseti_lang.execute import execute_condition\n\ncondition = '|ll5'\nexecute_condition(condition, \"Hello world!\")  # False\nexecute_condition(condition, \"Hi\")  # True\n\ncondition = '|lg5'\nexecute_condition(condition, \"Hello world!\")  # True\nexecute_condition(condition, \"Hi\")  # False\n```\n\n### Checking the words distance\n\n```python\nfrom forseti_lang.execute import execute_condition\n\ncondition = 'hello |w1 world'\nexecute_condition(condition, \"Hello world!\")  # True\nexecute_condition(condition, \"Hello sunny world!\")  # True\nexecute_condition(condition, \"Hello dirty and dark world!\")  # False\n\ncondition = 'hi\\W? |c1 how are you'\nexecute_condition(condition, \"Hi, how are you?\")  # True\nexecute_condition(condition, \"Hi, hmm.. how ary you?\")  # False\n\ncondition = 'hello |1 world'\nexecute_condition(condition, \"Hello world!\")  # True\n```\n\n### Checking nearby words\n\n```python\nfrom forseti_lang.execute import execute_condition\n\ncondition = 'hello |nearby world | people | notalib'\nexecute_condition(condition, \"Hello world!\")  # True\nexecute_condition(condition, \"Hello notalib!\")  # True\n```\n\n### Logic processing\n\n```python\nfrom forseti_lang.execute import execute_condition\n\nexecute_condition(\"TRUE AND FALSE\", \"\") # False\nexecute_condition(\"TRUE OR FALSE\", \"\") # True\nexecute_condition(\"FALSE OR TRUE AND (TRUE OR FALSE)\", \"\") # True\nexecute_condition(\"FALSE OR TRUE AND (FALSE AND TRUE)\", \"\") # False\nexecute_condition(\"(TRUE OR FALSE) AND NOT (TRUE AND FALSE)\", \"\") # TRUE\n```\n\n### Difficult rules example\n* `\u043a\u043e\u0440\u043e\u0431 AND NOT \u043a\u043e\u0440\u043e\u0431 |2 \u043a\u043e\u043d\u0444\u0435\u0442`\n* `\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\\w,{,2} |1 \u0441\u0442\u043e\u0438\u043c\u043e`\n* `\u0431\u0430\u043b\u043b AND NOT (\u0441\u043d[\u0438\u044f]\\w* \u0431\u0430\u043b\u043b \u0418\u041b\u0418 10\\s?\u0431\u0430\u043b\u043b \u0418\u041b\u0418 \u0434\u0435\u0441\u044f\u0442\u044c\\s\u0431\u0430\u043b\u043b\u043e\u0432) AND |lg15`\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "The system for determining the compliance of the text with the specified rules",
    "version": "1.0.3",
    "project_urls": {
        "Homepage": "https://github.com/Kirill-Lekhov/forseti_lang",
        "Repository": "https://github.com/Kirill-Lekhov/forseti_lang"
    },
    "split_keywords": [
        "language_processing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d27e3f8fa788f31dee5e447506e6c702da976c333f75d1897e0c80d57f73f7b1",
                "md5": "a238af3aa7e896f1d4942360df4f8905",
                "sha256": "f5efef37b1a690103bd40dcd4b95c98357f05e19ae0c149f2bed1429aa8e86ab"
            },
            "downloads": -1,
            "filename": "forseti_lang-1.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a238af3aa7e896f1d4942360df4f8905",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.5,<4.0",
            "size": 15257,
            "upload_time": "2024-01-30T14:29:55",
            "upload_time_iso_8601": "2024-01-30T14:29:55.199914Z",
            "url": "https://files.pythonhosted.org/packages/d2/7e/3f8fa788f31dee5e447506e6c702da976c333f75d1897e0c80d57f73f7b1/forseti_lang-1.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5fc0d07c15b7a0c9ddf8434aba8206048fe208520e2271cb87217fb351cc6ea2",
                "md5": "7b1b5e0b69f8f1115b85d3e7663a354b",
                "sha256": "aefc5ba0ed98ae3479b378b59aaef6c10e095bd727a8f5d1960825fa1498a87a"
            },
            "downloads": -1,
            "filename": "forseti_lang-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "7b1b5e0b69f8f1115b85d3e7663a354b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5,<4.0",
            "size": 9616,
            "upload_time": "2024-01-30T14:29:57",
            "upload_time_iso_8601": "2024-01-30T14:29:57.024715Z",
            "url": "https://files.pythonhosted.org/packages/5f/c0/d07c15b7a0c9ddf8434aba8206048fe208520e2271cb87217fb351cc6ea2/forseti_lang-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-30 14:29:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Kirill-Lekhov",
    "github_project": "forseti_lang",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "forseti-lang"
}
        
Elapsed time: 0.16600s