Skip to content

Commit

Permalink
Merge pull request #10 from ken-morel/ken-morel-patch-2
Browse files Browse the repository at this point in the history
Improved demo, and Added support for function-less callbacks
  • Loading branch information
ken-morel authored Jul 19, 2024
2 parents 3693e2e + 10de274 commit 752c36a
Show file tree
Hide file tree
Showing 9 changed files with 308 additions and 1,110 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,14 @@ It will check the patterns as given and return the match with tha maximum score

# Enter the Demo Zone

Well, let's now explore the demo and see how it does:

```python
from djamago.demo import cli

cli()
```

```
```
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
autoclass_content = "both"

sys.setrecursionlimit(500)
project = "pyoload"
project = "djamago"
copyright = "2024, ken-morel"
author = "ken-morel"

release = "2.0.0"
version = "2.0.0"
release = "0.1.0"
version = "0.1.0"

# -- General configuration

Expand Down
79 changes: 79 additions & 0 deletions docs/expressions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
===============================================================================
Registering Expressions
===============================================================================

You can register expressions using `Expression.register` to create a new
expression, or `Expression.extend` to add more patterns to an existing
expression or `Expression.override` to override an existing expression.
`Expression.register`It takes two arguments:

-------------------------------------------------------------------------------
Expression definition
-------------------------------------------------------------------------------

The definition of the expression, it could just be the expression name
as `asking_no-thing@robot`. you could also subclass an existing expression
using the syntax `name(parent1, parent2, ...)`.

-------------------------------------------------------------------------------
Expression patterns
-------------------------------------------------------------------------------

a list of tuples in the for `(score, regex_pattern)`.

The score is a float or integer value between `-1` for no match, passing by `0`
for default match, to `100` for full match

The pattern is simply a string pattern to full match.
The captures of the regex will be used for matching with the arguments when
the expression is inferred.

===============================================================================
Using expressions
===============================================================================

A djamago expression consists of four parts

-------------------------------------------------------------------------------
The pattern
-------------------------------------------------------------------------------

The first and only required part of the expression. It may have two value types

1. **A registerred expression name**: A simple name reference to a list of
mappings of score to regular epression.
2. **A quoted regular expression**: you could simply quote a regular expression
and use it in the same way.

-------------------------------------------------------------------------------
The arguments
-------------------------------------------------------------------------------

As a simple function call, the arguments will be fullmatched on the expression
matching groups.
gives something like `how-are(you)`

-------------------------------------------------------------------------------
The match name
-------------------------------------------------------------------------------

Add a hash and a string after the pattern name regex or call arguments,
and the match will be available in the `node.vars` under the specified name.

now like:
- `greetings#greetingMessage`
- `".+"#anything`
- `hello("user")#message`

-------------------------------------------------------------------------------
The match score
-------------------------------------------------------------------------------

Fix a specific score to rescale the score match, use syntax `everyThingElse:{score}`
as in:

- `hello:60.5`
- `'hello':60.5`
- `greetings(".+"#personName:60, ".+"#personName2:40):65`

Well, you are all set to use `djamago.Expression`.
24 changes: 15 additions & 9 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,29 @@ Wealcome to djamago v |version| documentation!
:target: https://portfolio-ken-morel-projects.vercel.app/
:alt: Hit count

Hy pythonista, here is `djamago`, what is?
===============================================================================
Getting introduced
===============================================================================

Djamago is a chatbot module which will help you build python chat robots.
It implements regular expression matching and score based evaluation to improve
result accuracy while keeping interesting performance.

**It does not use AI**, making it fast but dacading result uniquness, making
it better for building simple bots for advertisement, or simple dynamic
answering.


A python chatbot library

Djamago is a chatbot library which will help you creating simple
chatbots, it inspires of chatbot project, and tries to improve accuracy
using score based answers.

.. toctree::
:maxdepth: 1

examples
usage
api
installation
expressions
whatsnew
examples
api
report
genindex
modindex
oload-or-multi
61 changes: 20 additions & 41 deletions docs/whatsnew.rst
Original file line number Diff line number Diff line change
@@ -1,41 +1,20 @@
==================================================
What's new
==================================================

Lot's have been done since I started the project
to when I write this doc now, about

.. image:: https://wakatime.com/badge/user/dbe5b692-a03c-4ea8-b663-a3e6438148b6/project/ab01ce70-02f0-4c96-9912-bafa41a0aa54.svg


These are the highlights

--------------------------------------------------
pyoload v2.0.0
--------------------------------------------------

1. Greatly worked on the docs to make them more undetsandable and increase coverage.
2. Renamed overload to multiple dispatch or multimethod as required, since
As from :ref:`Overload or multimethod`.
3. Added new options to :ref:`pyoload.Checks` such as registerring under multiple names.
4. Increased the pytest coverage to ensure the full functionality of `pyoload`
on the several supported python versions.
5. Greatly improved performance using `inspect.Signature`. Providing support
for partial annotating of function.(Yes, from v2.0.0 some annotations may be ommited).
6. Added helper methods for interacting with annotated functions,
They include

- :ref:`pyoload.annotable`
- :ref:`pyoload.unannotable`
- :ref:`pyoload.is_annotable`
- :ref:`pyoload.is_annotated`

Those methods will help you prevent some functions from being annotated.

7. Improved support for python 3.9 and 3.10
8. renamed functions as the previous `pyoload.typeMatch` to :ref:`pyoload.type_match` to follow
the snake case system of nomenclature.
9. :ref:`pyoload.type_match` returns a tuple of the matchin status and errors
which may have lead to type mismatch, thosse errors are added to traceback
to ease debugging.
10. Now most classes implement `__slots__` to improve memory size.
===============================================================================
What's new?
===============================================================================

-------------------------------------------------------------------------------
v0.0.2
-------------------------------------------------------------------------------

- **Added supports for named exprssions**: with the new expression syntax, now
an expression can be named.
- **Improved expression checking errors**: Added name propositions, and error
messages.
- **Added builtin expressions**: Now Djamago implements builtin expressions
prefixed with a `-`.
- **Added .next to Node**: You can now easily specify precisely which method
will follow.
- **simplified node**: now node implements all the session data including
variables, parameters, score and candidates.
- **Added ScoreChange**: raise this in a callback to assign to it a new
score and recheck.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pyoload==2.0.1
pyoload==2.0.2
Loading

0 comments on commit 752c36a

Please # to comment.