-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from ken-morel/ken-morel-patch-2
Improved demo, and Added support for function-less callbacks
- Loading branch information
Showing
9 changed files
with
308 additions
and
1,110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pyoload==2.0.1 | ||
pyoload==2.0.2 |
Oops, something went wrong.