mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Allow setting a specific number of words
This commit is contained in:
parent
d2fbe444d0
commit
87540e6d9e
6 changed files with 47 additions and 15 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,7 +1,7 @@
|
||||||
# Royalnet ignores
|
# Royalnet ignores
|
||||||
config*.toml
|
config*.toml
|
||||||
downloads/
|
downloads/
|
||||||
|
markov/
|
||||||
|
|
||||||
# Python ignores
|
# Python ignores
|
||||||
**/__pycache__/
|
**/__pycache__/
|
||||||
|
|
|
@ -11,5 +11,6 @@ A [Royalnet](https://github.com/Steffo99/royalnet) pack to have fun with [Markov
|
||||||
[Packs."markovpack"]
|
[Packs."markovpack"]
|
||||||
Markov.models_directory = "markovpack" # The name of the directory containing the .json files
|
Markov.models_directory = "markovpack" # The name of the directory containing the .json files
|
||||||
Markov.default_model = "example" # The name of the .json file that should be parsed if no arguments are passed to the command
|
Markov.default_model = "example" # The name of the .json file that should be parsed if no arguments are passed to the command
|
||||||
|
Markov.min_words = 5 # The minimum number of words a sentence should have to be sent
|
||||||
```
|
```
|
||||||
4. Start Royalnet and have fun!
|
4. Start Royalnet with `python -m royalnet` and have fun!
|
|
@ -30,13 +30,18 @@ class MarkovCommand(Command):
|
||||||
if self.interface.name != "telegram":
|
if self.interface.name != "telegram":
|
||||||
raise UnsupportedError("[c]markov[/c] funziona solo su Telegram.")
|
raise UnsupportedError("[c]markov[/c] funziona solo su Telegram.")
|
||||||
model_name = args.optional(0, self.config["Markov"]["default_model"])
|
model_name = args.optional(0, self.config["Markov"]["default_model"])
|
||||||
try:
|
while True:
|
||||||
sentence = self._texts[model_name].make_sentence()
|
try:
|
||||||
except KeyError:
|
sentence = self._texts[model_name].make_sentence()
|
||||||
models = "\n- ".join([model_name for model_name in self._texts])
|
except KeyError:
|
||||||
raise InvalidInputError("Il modello richiesto non esiste."
|
models = []
|
||||||
f"Modelli disponibili: {models}")
|
for mn in self._texts:
|
||||||
if sentence is None or sentence == "":
|
models.append(f"- [c]{mn}[/c]\n")
|
||||||
await data.reply(f"💭 Il bot ([c]{model_name}[/c])... non dice niente. Riprova!")
|
raise InvalidInputError("Il modello richiesto non esiste."
|
||||||
else:
|
f"Modelli disponibili:\n{models}")
|
||||||
await data.reply(f'💬 Il bot ([c]{model_name}[/c]) dice:\n{sentence}')
|
if sentence is None:
|
||||||
|
continue
|
||||||
|
if len(sentence.split()) < self.config["Markov"]["min_words"]:
|
||||||
|
continue
|
||||||
|
break
|
||||||
|
await data.reply(f'💬 Il bot ([c]{model_name}[/c]) dice:\n{sentence}')
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
semantic = "0.2.0"
|
semantic = "0.3.0"
|
||||||
|
|
28
poetry.lock
generated
28
poetry.lock
generated
|
@ -253,6 +253,17 @@ sqlalchemy = ["sqlalchemy"]
|
||||||
test = ["pytest-cov (>=2.6)", "pytest (>4.0)"]
|
test = ["pytest-cov (>=2.6)", "pytest (>4.0)"]
|
||||||
zmq = ["pyzmq"]
|
zmq = ["pyzmq"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
category = "main"
|
||||||
|
description = "A simple, extensible Markov chain generator. Uses include generating random semi-plausible sentences based on an existing text."
|
||||||
|
name = "markovify"
|
||||||
|
optional = false
|
||||||
|
python-versions = "*"
|
||||||
|
version = "0.8.0"
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
unidecode = "*"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
category = "main"
|
category = "main"
|
||||||
description = "A Python Matrix client library, designed according to sans I/O principles."
|
description = "A Python Matrix client library, designed according to sans I/O principles."
|
||||||
|
@ -590,6 +601,14 @@ version = "2.0.0"
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
pytz = "*"
|
pytz = "*"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
category = "main"
|
||||||
|
description = "ASCII transliterations of Unicode text"
|
||||||
|
name = "unidecode"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
|
||||||
|
version = "1.1.1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
category = "main"
|
category = "main"
|
||||||
description = "Unpadded Base64"
|
description = "Unpadded Base64"
|
||||||
|
@ -664,7 +683,7 @@ python-versions = "*"
|
||||||
version = "2020.1.15"
|
version = "2020.1.15"
|
||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
content-hash = "e50984a2b35e6d1188ae58089db153a70de042d42e008ca6862331307f504f55"
|
content-hash = "a4f472f93cfad2f414322d8d78d082a658bc57a2d7f74cfcd96e0f1c653185c5"
|
||||||
python-versions = "^3.8"
|
python-versions = "^3.8"
|
||||||
|
|
||||||
[metadata.files]
|
[metadata.files]
|
||||||
|
@ -831,6 +850,9 @@ logbook = [
|
||||||
{file = "Logbook-1.5.3-cp37-cp37m-win_amd64.whl", hash = "sha256:0cf2cdbfb65a03b5987d19109dacad13417809dcf697f66e1a7084fb21744ea9"},
|
{file = "Logbook-1.5.3-cp37-cp37m-win_amd64.whl", hash = "sha256:0cf2cdbfb65a03b5987d19109dacad13417809dcf697f66e1a7084fb21744ea9"},
|
||||||
{file = "Logbook-1.5.3.tar.gz", hash = "sha256:66f454ada0f56eae43066f604a222b09893f98c1adc18df169710761b8f32fe8"},
|
{file = "Logbook-1.5.3.tar.gz", hash = "sha256:66f454ada0f56eae43066f604a222b09893f98c1adc18df169710761b8f32fe8"},
|
||||||
]
|
]
|
||||||
|
markovify = [
|
||||||
|
{file = "markovify-0.8.0.tar.gz", hash = "sha256:c533a2e1aba8148bb98031b7159e8bf1a276c61db53d2e882ecb74fa5603a4f4"},
|
||||||
|
]
|
||||||
matrix-nio = [
|
matrix-nio = [
|
||||||
{file = "matrix-nio-0.6.tar.gz", hash = "sha256:25a4ac9d5e1435035f5c5b6e9a6b453ac66ade25cb455ba6bbe9cc3ae1e0ef50"},
|
{file = "matrix-nio-0.6.tar.gz", hash = "sha256:25a4ac9d5e1435035f5c5b6e9a6b453ac66ade25cb455ba6bbe9cc3ae1e0ef50"},
|
||||||
]
|
]
|
||||||
|
@ -1033,6 +1055,10 @@ tzlocal = [
|
||||||
{file = "tzlocal-2.0.0-py2.py3-none-any.whl", hash = "sha256:11c9f16e0a633b4b60e1eede97d8a46340d042e67b670b290ca526576e039048"},
|
{file = "tzlocal-2.0.0-py2.py3-none-any.whl", hash = "sha256:11c9f16e0a633b4b60e1eede97d8a46340d042e67b670b290ca526576e039048"},
|
||||||
{file = "tzlocal-2.0.0.tar.gz", hash = "sha256:949b9dd5ba4be17190a80c0268167d7e6c92c62b30026cf9764caf3e308e5590"},
|
{file = "tzlocal-2.0.0.tar.gz", hash = "sha256:949b9dd5ba4be17190a80c0268167d7e6c92c62b30026cf9764caf3e308e5590"},
|
||||||
]
|
]
|
||||||
|
unidecode = [
|
||||||
|
{file = "Unidecode-1.1.1-py2.py3-none-any.whl", hash = "sha256:1d7a042116536098d05d599ef2b8616759f02985c85b4fef50c78a5aaf10822a"},
|
||||||
|
{file = "Unidecode-1.1.1.tar.gz", hash = "sha256:2b6aab710c2a1647e928e36d69c21e76b453cd455f4e2621000e54b2a9b8cce8"},
|
||||||
|
]
|
||||||
unpaddedbase64 = [
|
unpaddedbase64 = [
|
||||||
{file = "unpaddedbase64-1.1.0-py2-none-any.whl", hash = "sha256:8917367e4e915b7dce1a72a99db8798c9f3d0d9a74cdd9aafac6d7c65ca495c5"},
|
{file = "unpaddedbase64-1.1.0-py2-none-any.whl", hash = "sha256:8917367e4e915b7dce1a72a99db8798c9f3d0d9a74cdd9aafac6d7c65ca495c5"},
|
||||||
{file = "unpaddedbase64-1.1.0-py2.py3-none-any.whl", hash = "sha256:81cb4eaaa28cc6a282dd3f2c3855eaa1fbaafa736b5ee64df69889e20540a339"},
|
{file = "unpaddedbase64-1.1.0-py2.py3-none-any.whl", hash = "sha256:81cb4eaaa28cc6a282dd3f2c3855eaa1fbaafa736b5ee64df69889e20540a339"},
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "markovpack"
|
name = "markovpack"
|
||||||
description = "A Royalnet pack to have fun with Markovify."
|
description = "A Royalnet pack to have fun with Markovify."
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"]
|
authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"]
|
||||||
license = "AGPL-3.0+"
|
license = "AGPL-3.0+"
|
||||||
homepage = "https://github.com/Steffo99/markovpack"
|
homepage = "https://github.com/Steffo99/markovpack"
|
||||||
|
|
Loading…
Reference in a new issue