Bump to 0.2.0

- Add Unweighted mode to command line
- Download nltk data if needed.
This commit is contained in:
Cassowary 2023-11-04 20:39:54 -07:00
parent 6556164879
commit d6e329ff39
7 changed files with 188 additions and 9 deletions

BIN
carkov-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 392 KiB

175
carkov-logo.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 64 KiB

View File

@ -4,4 +4,4 @@
# This is free software, see the included LICENSE for terms and conditions. # This is free software, see the included LICENSE for terms and conditions.
# #
version = '0.1.2' version = '0.2.0'

View File

@ -61,17 +61,18 @@ def parse_arguments() -> argparse.Namespace:
chain_sub = subparsers.add_parser('chain', help="Output from a chainer") chain_sub = subparsers.add_parser('chain', help="Output from a chainer")
chain_sub.add_argument('input', help="The chain file to load", type=pathlib.Path) chain_sub.add_argument('input', help="The chain file to load", type=pathlib.Path)
chain_sub.add_argument('-u', '--unweighted', help="Don't weight token selection by statistical frequency.", action='store_true')
chain_sub.add_argument('-c', '--count', help="Number of chain outputs to output", type=int, default=10) chain_sub.add_argument('-c', '--count', help="Number of chain outputs to output", type=int, default=10)
chain_sub.add_argument('-m', '--maxlen', help="Maximum length in tokens of output (0 is unlimited)", type=int, default=0) chain_sub.add_argument('-m', '--maxlen', help="Maximum length in tokens of output (0 is unlimited)", type=int, default=0)
return parser.parse_args() return parser.parse_args()
def print_chainer_output(chainer: Chain, random_state: Random): def print_chainer_output(chainer: Chain, random_state: Random, weighted: bool = False):
if chainer.analyzer_class in JOINERS: if chainer.analyzer_class in JOINERS:
print(JOINERS[cast(str, chainer.analyzer_class)](chainer.walk(random_state, True))) print(JOINERS[cast(str, chainer.analyzer_class)](chainer.walk(random_state, weighted)))
else: else:
print(chainer.walk(random_state, True)) print(chainer.walk(random_state, weighted))
def command_analyze(args: argparse.Namespace) -> int: def command_analyze(args: argparse.Namespace) -> int:
@ -145,7 +146,7 @@ def command_chain(args: argparse.Namespace) -> int:
args.count = 1 args.count = 1
for _ in range(0, args.count): for _ in range(0, args.count):
print_chainer_output(chainer, r) print_chainer_output(chainer, r, not args.unweighted)
return 0 return 0

View File

@ -9,6 +9,12 @@ import nltk
from .abstract import AbstractAnalyzer from .abstract import AbstractAnalyzer
try:
nltk.sent_tokenize("foo bar")
except LookupError:
nltk.download('punkt')
class English(AbstractAnalyzer): class English(AbstractAnalyzer):
def __init__(self, order, filters=None): def __init__(self, order, filters=None):
if filters is None: if filters is None:

View File

@ -1,3 +0,0 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

View File

@ -1,6 +1,6 @@
[metadata] [metadata]
name = carkov name = carkov
version = 0.1.2 version = 0.2.0
description = A markov chainer library description = A markov chainer library
author = Aldercone Studio author = Aldercone Studio
author_email = alderconestudio@gmail.com author_email = alderconestudio@gmail.com