Metadata-Version: 2.4
Name: ovos-skill-calculator
Version: 0.0.2
Summary: A basic calculator skill for OVOS - add, subtract, multiply, divide, percentages, square roots, fully offline
Home-page: https://github.com/andlo/ovos-skill-calculator
Author: Andreas Lorensen
Author-email: andlo@outlook.dk
License: GPL-3.0-or-later
Project-URL: Source, https://github.com/andlo/ovos-skill-calculator
Project-URL: Bug Tracker, https://github.com/andlo/ovos-skill-calculator/issues
Keywords: ovos skill voice assistant calculator math arithmetic
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: End Users/Desktop
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: ovos-number-parser
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: project-url
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# <img src='icon.png' card_color='#4085DB' width='50' height='50' style='vertical-align:bottom'/> Calculator

A basic calculator for OVOS - "what is 15 times 23", "what is the
square root of 144", "what is 20 percent of 150". Fully offline, pure
arithmetic, no external dependencies beyond number parsing.

[![Tests](https://github.com/andlo/ovos-skill-calculator/actions/workflows/test.yml/badge.svg)](https://github.com/andlo/ovos-skill-calculator/actions/workflows/test.yml)
[![PyPI version](https://img.shields.io/pypi/v/ovos-skill-calculator.svg)](https://pypi.org/project/ovos-skill-calculator/)

## Usage
```
"what is 5 plus 3"
"what is 15 times 23"
"what is 100 divided by 4"
"what is 20 percent of 150"
"what is 9 squared"
"what is the square root of 144"
"hvad er 5 plus 3"                (Danish)
"hvad er kvadratroden af 144"     (Danish)
```

## Why one intent file per operation

A single intent like `"what is {a} {operator} {b}"`, with the
operator word captured as a wildcard, does **not** work reliably in
padatious: with three consecutive wildcards and no literal anchor
word between `{a}`, `{operator}`, and `{b}`, the matcher can't tell
where one wildcard ends and the next begins. Each operation gets its
own intent file instead, with the operator as literal text - the same
anchor-word pattern every other intent in this project family uses
(e.g. `ovos-skill-convert`'s `"convert {value} {from_unit} to
{to_unit}"`).

## A rough edge fixed here (tracked as an issue elsewhere)

[ovos-skill-convert](https://github.com/andlo/ovos-skill-convert)
has an open issue for a cosmetic rough edge: whole-number results
spoken with a trailing ".0" (e.g. "10.0" instead of "10"), because
Python's default float formatting was used as-is. This skill avoids
the problem from the start with a small `_format_number()` helper - a
whole-number float speaks as a plain integer, a genuine fraction
rounds to 4 decimal places. Worth porting the same helper over when
that issue is picked up.

## Common Query safety net

`"what is 5 times 6"` is structurally identical to the "what is X"
questions confirmed to sometimes get intercepted by a platform-level
semantic router (`ovos-m2v-pipeline-high`) before this skill's own
Padatious intents get a chance - see
[ovos-skill-geometry](https://github.com/andlo/ovos-skill-geometry)'s
DEVELOPMENT.md for the full live-tested finding. `handle_common_query()`
reuses the exact literal anchor words each intent file already has
(plus/minus/times/...) as regex patterns, so it's not a second
implementation of the arithmetic parsing, just a fallback entry point
into it.

## Install
```bash
pip install ovos-skill-calculator
```

## Development

See [DEVELOPMENT.md](DEVELOPMENT.md).

## Category
**Utility**

## Tags
#calculator #math #arithmetic
