Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions documentation/geometry_classes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Geometry classes
============================================================================

Dragonfly's window and monitor APIs use a pair of small geometry classes to
represent points, bounds and movement calculations across supported
platforms.


Point class
----------------------------------------------------------------------------

.. autoclass:: dragonfly.windows.point.Point
:members:


Rectangle class
----------------------------------------------------------------------------

.. autoclass:: dragonfly.windows.rectangle.Rectangle
:members:
1 change: 1 addition & 0 deletions documentation/kaldi_engine.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ The engine can also be configured via the :ref:`command-line interface


.. autofunction:: dragonfly.engines.backend_kaldi.engine.KaldiEngine
:no-index:

**Arguments (all optional):**

Expand Down
79 changes: 78 additions & 1 deletion documentation/language.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,90 @@ The following languages are supported:
English has additional time, date and character related classes.


Numeric language elements
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Dragonfly exposes a small public numeric language API through the
:mod:`dragonfly.language` package. These classes use the current speech
recognition engine language to load the right spoken-number content.

Use the direct element classes when building grammars inline:

* :class:`Integer` for bounded spoken integers.
* :class:`Digits` for sequences of spoken digits.
* :class:`Number` for larger spoken numbers and number series.

Use the ``*Ref`` variants when you want Dragonfly to wrap those elements in
named private rules for use as command extras:

* :class:`IntegerRef`
* :class:`ShortIntegerRef`
* :class:`DigitsRef`
* :class:`NumberRef`

:class:`ShortIntegerRef` uses a more permissive short-number grammar when a
language implements it and otherwise falls back to normal integer
pronunciations for that language.


Language classes reference
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. automodule:: dragonfly.language.en.short_number
Integer class
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. autoclass:: dragonfly.language.Integer
:members:


IntegerRef class
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. autoclass:: dragonfly.language.IntegerRef
:members:


ShortIntegerRef class
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. autoclass:: dragonfly.language.ShortIntegerRef
:members:


Digits class
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. autoclass:: dragonfly.language.Digits
:members:


DigitsRef class
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. autoclass:: dragonfly.language.DigitsRef
:members:


Number class
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. autoclass:: dragonfly.language.Number
:members:


NumberRef class
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. autoclass:: dragonfly.language.NumberRef
:members:


Short number pronunciation notes
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. automodule:: dragonfly.language.en.short_number


.. rubric:: References

.. [#f1] https://nuance.custhelp.com/app/answers/detail/a_id/6280/kw/Dragon%20NaturallySpeaking%20languages%20supported/related/1
Expand Down
4 changes: 2 additions & 2 deletions documentation/related_resources.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ The following resources are used by the Dragonfly community and speech
recognition users/developers:

* `Gitter chat room <https://app.gitter.im/#/room/#dragonfly2:matrix.org>`__
(also `bridged to Matrix <https://matrix.to/#/#dragonfly2:matrix.org>`__)
--- Real-time chat and historical discussions about Dragonfly
(also `bridged to Matrix <https://matrix.to/#/#dragonfly2:matrix.org>`__)
--- Real-time chat and historical discussions about Dragonfly

* `Dragonfly Speech Google Group
<https://groups.google.com/forum/#!forum/dragonflyspeech>`_
Expand Down
1 change: 1 addition & 0 deletions documentation/windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Contents of Dragonfly's windows sub-package:
.. toctree::
:maxdepth: 2

geometry_classes
clipboard
monitor_classes
window_classes
7 changes: 7 additions & 0 deletions dragonfly/language/base/digits.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
# Base class for digit-series element classes.

class Digits(Repetition):
"""
Language-aware element for a spoken series of digits.

The recognized value can be returned either as a list of digit values or
combined into an integer via the ``as_int`` argument.
"""

_content = None
_digit_name = "_digit"
Expand Down Expand Up @@ -92,6 +98,7 @@ def value(self, node):
# Digits reference class.

class DigitsRef(RuleWrap):
"""Named rule wrapper around :class:`Digits` for use in rule extras."""

def __init__(self, name=None, min=1, max=12, as_int=True, default=None):
element = Digits(name=None, min=min, max=max, as_int=as_int)
Expand Down
14 changes: 14 additions & 0 deletions dragonfly/language/base/integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
# Base class for integer element classes.

class Integer(Alternative):
"""
Language-aware element for spoken integers within a numeric range.

The active speech recognition engine language determines which spoken
forms are available unless a specific content implementation is passed
explicitly.
"""

_content = None

Expand Down Expand Up @@ -90,12 +97,19 @@ def _build_children(self, min, max):
# Integer reference class.

class IntegerRef(RuleWrap):
"""Named rule wrapper around :class:`Integer` for use in rule extras."""

def __init__(self, name, min, max, default=None):
element = Integer(None, min, max)
RuleWrap.__init__(self, name, element, default=default)

class ShortIntegerRef(RuleWrap):
"""
Variant of :class:`IntegerRef` that accepts shorter spoken forms.

This uses language-specific short-number content when available and
otherwise falls back to the standard integer content for the language.
"""

def __init__(self, name, min, max, default=None):
element = Integer(None, min, max, content=language.ShortIntegerContent)
Expand Down
8 changes: 8 additions & 0 deletions dragonfly/language/base/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
# Number class.

class Number(Alternative):
"""
Language-aware element for spoken whole numbers and number series.

This combines the current language's integer content into a higher-level
element that can interpret a single number or a spoken series of smaller
numbers as one value.
"""

_int_max = 1000000
_ser_len = 8
Expand Down Expand Up @@ -81,6 +88,7 @@ def value(self, node):
# Number reference class.

class NumberRef(RuleWrap):
"""Named rule wrapper around :class:`Number` for use in rule extras."""

def __init__(self, name=None, zero=False, default=None):
element = Number(None, zero=zero)
Expand Down
6 changes: 6 additions & 0 deletions dragonfly/windows/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
#===========================================================================

class Point(object):
"""
Two-dimensional point with floating-point coordinates.

The class provides small geometry helpers used throughout Dragonfly's
window and monitor toolkits.
"""

#-----------------------------------------------------------------------
# Methods for initialization, copying, and introspection.
Expand Down
8 changes: 8 additions & 0 deletions dragonfly/windows/rectangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@
# Rectangle class.

class Rectangle(Point):
"""
Axis-aligned rectangle represented by an origin point and size.

Rectangle inherits the position handling from
:class:`~dragonfly.windows.point.Point` and adds width, height,
centre-point, and containment helpers used by the window and monitor
APIs.
"""

#-----------------------------------------------------------------------
# Methods for initialization, copying, and introspection.
Expand Down