ovos-solver-rivescript-plugin 0.0.0__tar.gz → 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (20) hide show
  1. ovos-solver-rivescript-plugin-0.0.1/PKG-INFO +40 -0
  2. {ovos-solver-rivescript-plugin-0.0.0 → ovos-solver-rivescript-plugin-0.0.1}/ovos_solver_rivescript_plugin/__init__.py +29 -15
  3. ovos-solver-rivescript-plugin-0.0.1/ovos_solver_rivescript_plugin/version.py +6 -0
  4. ovos-solver-rivescript-plugin-0.0.1/ovos_solver_rivescript_plugin.egg-info/PKG-INFO +40 -0
  5. ovos-solver-rivescript-plugin-0.0.1/ovos_solver_rivescript_plugin.egg-info/entry_points.txt +2 -0
  6. ovos-solver-rivescript-plugin-0.0.1/ovos_solver_rivescript_plugin.egg-info/requires.txt +2 -0
  7. {ovos-solver-rivescript-plugin-0.0.0 → ovos-solver-rivescript-plugin-0.0.1}/setup.py +24 -11
  8. ovos-solver-rivescript-plugin-0.0.0/PKG-INFO +0 -40
  9. ovos-solver-rivescript-plugin-0.0.0/ovos_solver_rivescript_plugin/version.py +0 -7
  10. ovos-solver-rivescript-plugin-0.0.0/ovos_solver_rivescript_plugin.egg-info/PKG-INFO +0 -40
  11. ovos-solver-rivescript-plugin-0.0.0/ovos_solver_rivescript_plugin.egg-info/entry_points.txt +0 -3
  12. ovos-solver-rivescript-plugin-0.0.0/ovos_solver_rivescript_plugin.egg-info/requires.txt +0 -2
  13. {ovos-solver-rivescript-plugin-0.0.0 → ovos-solver-rivescript-plugin-0.0.1}/LICENSE +0 -0
  14. {ovos-solver-rivescript-plugin-0.0.0 → ovos-solver-rivescript-plugin-0.0.1}/MANIFEST.in +0 -0
  15. {ovos-solver-rivescript-plugin-0.0.0 → ovos-solver-rivescript-plugin-0.0.1}/README.md +0 -0
  16. {ovos-solver-rivescript-plugin-0.0.0 → ovos-solver-rivescript-plugin-0.0.1}/ovos_solver_rivescript_plugin.egg-info/SOURCES.txt +0 -0
  17. {ovos-solver-rivescript-plugin-0.0.0 → ovos-solver-rivescript-plugin-0.0.1}/ovos_solver_rivescript_plugin.egg-info/dependency_links.txt +0 -0
  18. {ovos-solver-rivescript-plugin-0.0.0 → ovos-solver-rivescript-plugin-0.0.1}/ovos_solver_rivescript_plugin.egg-info/top_level.txt +0 -0
  19. {ovos-solver-rivescript-plugin-0.0.0 → ovos-solver-rivescript-plugin-0.0.1}/ovos_solver_rivescript_plugin.egg-info/zip-safe +0 -0
  20. {ovos-solver-rivescript-plugin-0.0.0 → ovos-solver-rivescript-plugin-0.0.1}/setup.cfg +0 -0
@@ -0,0 +1,40 @@
1
+ Metadata-Version: 2.1
2
+ Name: ovos-solver-rivescript-plugin
3
+ Version: 0.0.1
4
+ Summary: A question solver plugin for ovos/neon/mycroft
5
+ Home-page: https://github.com/OpenVoiceOS/ovos-solver-rivescript-plugin
6
+ Author: jarbasai
7
+ Author-email: jarbasai@mailfence.com
8
+ License: MIT
9
+ Keywords: mycroft plugin utterance fallback query
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+
13
+ # <img src='https://raw.githack.com/FortAwesome/Font-Awesome/master/svgs/solid/robot.svg' card_color='#40DBB0' width='50' height='50' style='vertical-align:bottom'/> Rivescript Chatbot
14
+
15
+ Give Mycroft some sass with Rivescript!
16
+
17
+ Leverages the [Alice chatbot](https://www.chatbots.org/chatbot/a.l.i.c.e/) to create some fun interactions. Phrases not explicitly handled by other skills will be run by the chatbot, so nearly every interaction will have _some_ response. But be warned, Mycroft might become a bit obnoxious...
18
+
19
+ ## Examples
20
+ * "Do you like ice cream"
21
+ * "Do you like dogs"
22
+ * "I have a jump rope"
23
+
24
+
25
+ ## Usage
26
+
27
+ Spoken answers api with a Rivescript backend
28
+
29
+ ```python
30
+ from ovos_solver_rivescript_plugin import RivescriptSolver
31
+
32
+ d = RivescriptSolver()
33
+ sentence = d.spoken_answer("hello")
34
+ print(sentence)
35
+ # Hi there!
36
+
37
+ sentence = d.spoken_answer("Do you like ice cream", {"lang": "pt-pt"})
38
+ print(sentence)
39
+ # O que queres mesmo saber?
40
+ ```
@@ -1,16 +1,17 @@
1
1
  import os
2
- import random
3
2
  from datetime import date
4
- from neon_solvers import AbstractSolver
5
- from os import listdir, remove as remove_file
6
- from os.path import dirname, isfile, join, dirname, isdir
3
+ from os.path import dirname, isdir
4
+ from typing import Optional
5
+
6
+ from ovos_plugin_manager.templates.solvers import QuestionSolver
7
7
  from ovos_utils.log import LOG
8
+ from ovos_utils.xdg_utils import xdg_data_home
8
9
  from rivescript import RiveScript
9
10
 
10
11
 
11
12
  class RivescriptBot:
12
13
  XDG_PATH = f"{xdg_data_home()}/rivescript"
13
- makedirs(XDG_PATH, exist_ok=True)
14
+ os.makedirs(XDG_PATH, exist_ok=True)
14
15
 
15
16
  def __init__(self, lang="en-us", settings=None):
16
17
  self.settings = settings or {}
@@ -80,7 +81,7 @@ class RivescriptBot:
80
81
  self.rs.set_variable("website", self.settings["website"])
81
82
  self.rs.set_variable("master", self.settings["master"])
82
83
  self.rs.set_variable("interests", self.settings["interests"])
83
- self.rs.set_variable("name", self.settings.get("name", "mycroft"))
84
+ self.rs.set_variable("name", self.settings.get("name", "mycroft"))
84
85
 
85
86
  self.rs.set_variable("age", str(date.today().year - 2016))
86
87
  # TODO - location from mycroft.conf
@@ -96,21 +97,34 @@ class RivescriptBot:
96
97
  LOG.error(e)
97
98
 
98
99
 
99
- class RivescriptSolver(AbstractSolver):
100
- def __init__(self):
101
- super().__init__(name="Rivescript", priority=96, enable_cache=False, enable_tx=True)
102
- self.brain = RivescriptBot("en-us", self.config)
100
+ class RivescriptSolver(QuestionSolver):
101
+ def __init__(self, config=None):
102
+ config = config or {"lang": "en-us"}
103
+ lang = config.get("lang") or "en-us"
104
+ if lang != "en-us" and lang not in os.listdir(RivescriptBot.XDG_PATH):
105
+ config["lang"] = lang = "en-us"
106
+ super().__init__(config, internal_lang=lang, enable_tx=True, priority=96)
107
+ self.brain = RivescriptBot(lang, self.config)
103
108
  self.brain.load_brain()
104
109
 
105
- # officially exported Solver methods
106
- def get_data(self, query, context=None):
107
- return {"answer": self.get_spoken_answer(query, context)}
110
+ def get_spoken_answer(self, query: str,
111
+ lang: Optional[str] = None,
112
+ units: Optional[str] = None) -> Optional[str]:
113
+ """
114
+ Obtain the spoken answer for a given query.
115
+
116
+ Args:
117
+ query (str): The query text.
118
+ lang (Optional[str]): Optional language code. Defaults to None.
119
+ units (Optional[str]): Optional units for the query. Defaults to None.
108
120
 
109
- def get_spoken_answer(self, query, context=None):
121
+ Returns:
122
+ str: The spoken answer as a text response.
123
+ """
110
124
  return self.brain.ask_brain(query)
111
125
 
112
126
 
113
127
  if __name__ == "__main__":
114
128
  bot = RivescriptSolver()
115
129
  print(bot.get_spoken_answer("hello!"))
116
- print(bot.spoken_answer("Qual é a tua comida favorita?", {"lang": "pt-pt"}))
130
+ print(bot.spoken_answer("Qual é a tua comida favorita?", lang="pt-pt"))
@@ -0,0 +1,6 @@
1
+ # START_VERSION_BLOCK
2
+ VERSION_MAJOR = 0
3
+ VERSION_MINOR = 0
4
+ VERSION_BUILD = 1
5
+ VERSION_ALPHA = 0
6
+ # END_VERSION_BLOCK
@@ -0,0 +1,40 @@
1
+ Metadata-Version: 2.1
2
+ Name: ovos-solver-rivescript-plugin
3
+ Version: 0.0.1
4
+ Summary: A question solver plugin for ovos/neon/mycroft
5
+ Home-page: https://github.com/OpenVoiceOS/ovos-solver-rivescript-plugin
6
+ Author: jarbasai
7
+ Author-email: jarbasai@mailfence.com
8
+ License: MIT
9
+ Keywords: mycroft plugin utterance fallback query
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+
13
+ # <img src='https://raw.githack.com/FortAwesome/Font-Awesome/master/svgs/solid/robot.svg' card_color='#40DBB0' width='50' height='50' style='vertical-align:bottom'/> Rivescript Chatbot
14
+
15
+ Give Mycroft some sass with Rivescript!
16
+
17
+ Leverages the [Alice chatbot](https://www.chatbots.org/chatbot/a.l.i.c.e/) to create some fun interactions. Phrases not explicitly handled by other skills will be run by the chatbot, so nearly every interaction will have _some_ response. But be warned, Mycroft might become a bit obnoxious...
18
+
19
+ ## Examples
20
+ * "Do you like ice cream"
21
+ * "Do you like dogs"
22
+ * "I have a jump rope"
23
+
24
+
25
+ ## Usage
26
+
27
+ Spoken answers api with a Rivescript backend
28
+
29
+ ```python
30
+ from ovos_solver_rivescript_plugin import RivescriptSolver
31
+
32
+ d = RivescriptSolver()
33
+ sentence = d.spoken_answer("hello")
34
+ print(sentence)
35
+ # Hi there!
36
+
37
+ sentence = d.spoken_answer("Do you like ice cream", {"lang": "pt-pt"})
38
+ print(sentence)
39
+ # O que queres mesmo saber?
40
+ ```
@@ -0,0 +1,2 @@
1
+ [neon.plugin.solver]
2
+ ovos-solver-rivescript-plugin = ovos_solver_rivescript_plugin:RivescriptSolver
@@ -0,0 +1,2 @@
1
+ rivescript
2
+ ovos-plugin-manager<2.0.0,>=0.0.26
@@ -16,23 +16,36 @@ def required(requirements_file):
16
16
  if pkg.strip() and not pkg.startswith("#")]
17
17
 
18
18
 
19
- with open("README.md", "r") as f:
19
+ with open(f"{BASEDIR}/README.md", "r") as f:
20
20
  long_description = f.read()
21
21
 
22
-
23
- with open("./version.py", "r", encoding="utf-8") as v:
24
- for line in v.readlines():
25
- if line.startswith("__version__"):
26
- if '"' in line:
27
- version = line.split('"')[1]
28
- else:
29
- version = line.split("'")[1]
30
-
22
+ def get_version():
23
+ """ Find the version of the package"""
24
+ version_file = os.path.join(BASEDIR, 'ovos_solver_rivescript_plugin', 'version.py')
25
+ major, minor, build, alpha = (None, None, None, None)
26
+ with open(version_file) as f:
27
+ for line in f:
28
+ if 'VERSION_MAJOR' in line:
29
+ major = line.split('=')[1].strip()
30
+ elif 'VERSION_MINOR' in line:
31
+ minor = line.split('=')[1].strip()
32
+ elif 'VERSION_BUILD' in line:
33
+ build = line.split('=')[1].strip()
34
+ elif 'VERSION_ALPHA' in line:
35
+ alpha = line.split('=')[1].strip()
36
+
37
+ if ((major and minor and build and alpha) or
38
+ '# END_VERSION_BLOCK' in line):
39
+ break
40
+ version = f"{major}.{minor}.{build}"
41
+ if alpha and int(alpha) > 0:
42
+ version += f"a{alpha}"
43
+ return version
31
44
 
32
45
  PLUGIN_ENTRY_POINT = 'ovos-solver-rivescript-plugin=ovos_solver_rivescript_plugin:RivescriptSolver'
33
46
  setup(
34
47
  name='ovos-solver-rivescript-plugin',
35
- version=version,
48
+ version=get_version(),
36
49
  description='A question solver plugin for ovos/neon/mycroft',
37
50
  url='https://github.com/OpenVoiceOS/ovos-solver-rivescript-plugin',
38
51
  author='jarbasai',
@@ -1,40 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: ovos-solver-rivescript-plugin
3
- Version: 0.0.0
4
- Summary: A question solver plugin for ovos/neon/mycroft
5
- Home-page: https://github.com/OpenVoiceOS/ovos-solver-rivescript-plugin
6
- Author: jarbasai
7
- Author-email: jarbasai@mailfence.com
8
- License: MIT
9
- Description: # <img src='https://raw.githack.com/FortAwesome/Font-Awesome/master/svgs/solid/robot.svg' card_color='#40DBB0' width='50' height='50' style='vertical-align:bottom'/> Rivescript Chatbot
10
-
11
- Give Mycroft some sass with Rivescript!
12
-
13
- Leverages the [Alice chatbot](https://www.chatbots.org/chatbot/a.l.i.c.e/) to create some fun interactions. Phrases not explicitly handled by other skills will be run by the chatbot, so nearly every interaction will have _some_ response. But be warned, Mycroft might become a bit obnoxious...
14
-
15
- ## Examples
16
- * "Do you like ice cream"
17
- * "Do you like dogs"
18
- * "I have a jump rope"
19
-
20
-
21
- ## Usage
22
-
23
- Spoken answers api with a Rivescript backend
24
-
25
- ```python
26
- from ovos_solver_rivescript_plugin import RivescriptSolver
27
-
28
- d = RivescriptSolver()
29
- sentence = d.spoken_answer("hello")
30
- print(sentence)
31
- # Hi there!
32
-
33
- sentence = d.spoken_answer("Do you like ice cream", {"lang": "pt-pt"})
34
- print(sentence)
35
- # O que queres mesmo saber?
36
- ```
37
-
38
- Keywords: mycroft plugin utterance fallback query
39
- Platform: UNKNOWN
40
- Description-Content-Type: text/markdown
@@ -1,7 +0,0 @@
1
- # The following lines are replaced during the release process.
2
- # START_VERSION_BLOCK
3
- VERSION_MAJOR = 0
4
- VERSION_MINOR = 0
5
- VERSION_BUILD = 0
6
- VERSION_ALPHA = 1
7
- # END_VERSION_BLOCK
@@ -1,40 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: ovos-solver-rivescript-plugin
3
- Version: 0.0.0
4
- Summary: A question solver plugin for ovos/neon/mycroft
5
- Home-page: https://github.com/OpenVoiceOS/ovos-solver-rivescript-plugin
6
- Author: jarbasai
7
- Author-email: jarbasai@mailfence.com
8
- License: MIT
9
- Description: # <img src='https://raw.githack.com/FortAwesome/Font-Awesome/master/svgs/solid/robot.svg' card_color='#40DBB0' width='50' height='50' style='vertical-align:bottom'/> Rivescript Chatbot
10
-
11
- Give Mycroft some sass with Rivescript!
12
-
13
- Leverages the [Alice chatbot](https://www.chatbots.org/chatbot/a.l.i.c.e/) to create some fun interactions. Phrases not explicitly handled by other skills will be run by the chatbot, so nearly every interaction will have _some_ response. But be warned, Mycroft might become a bit obnoxious...
14
-
15
- ## Examples
16
- * "Do you like ice cream"
17
- * "Do you like dogs"
18
- * "I have a jump rope"
19
-
20
-
21
- ## Usage
22
-
23
- Spoken answers api with a Rivescript backend
24
-
25
- ```python
26
- from ovos_solver_rivescript_plugin import RivescriptSolver
27
-
28
- d = RivescriptSolver()
29
- sentence = d.spoken_answer("hello")
30
- print(sentence)
31
- # Hi there!
32
-
33
- sentence = d.spoken_answer("Do you like ice cream", {"lang": "pt-pt"})
34
- print(sentence)
35
- # O que queres mesmo saber?
36
- ```
37
-
38
- Keywords: mycroft plugin utterance fallback query
39
- Platform: UNKNOWN
40
- Description-Content-Type: text/markdown
@@ -1,3 +0,0 @@
1
- [neon.plugin.solver]
2
- ovos-solver-rivescript-plugin=ovos_solver_rivescript_plugin:RivescriptSolver
3
-