Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(package/knowledge): Adds new knowledge package. #115

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions bridges/python/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ requests = "==2.21.0"
pytube = "==9.5.0"
tinydb = "==3.9.0"
beautifulsoup4 = "==4.7.1"
wolframalpha = "==3.0.1"
wikipedia = "==1.4.0"

[dev-packages]
56 changes: 52 additions & 4 deletions bridges/python/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions packages/knowledge/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Knowledge Package

The Knowledge package aims at answering general questions.

#### Usage

1. Set up and account at [Wolfram Alpha API](http://developer.wolframalpha.com) and create an `app_id`.
2. Duplicate the file `packages/knowledge/config/config.sample.json` and rename it `config.json`.
3. Set your language and other settings.
4. This package needs a few libraries to work properly. To install it, from inside leon directory, `cd bridges/python`
5. `pipenv install requests wikipedia wolframalpha`
6. Done!


### Wikipedia

```
(en-US)
- "Search on Wikipedia GitHub"
```

#### Requirements
- requests
- wikipedia

#### Options

- `lang`: Choose your language. Default: `en`
- `sentences`: Number of sentences to report. No greater than 10.


#### Links

- [MediaWiki API](https://www.mediawiki.org/wiki/API:Main_page)
- [Wikipedia GitHub](https://github.com/goldsmith/Wikipedia)
- [Wikipedia Docs](https://wikipedia.readthedocs.io/en/latest/)


### Wolfram Alpha

```
(en-US)
- "On Wolfram Alpha search for the integral of cos(x)"
- "On Wolfram Alpha search for Barack Obama's age"

```

#### Requirements
- wolframalpha

#### Options
- `app_id`: Your app id.
- `lang`: Choose your language. Default: `en`

#### Links

- [Wolfram Alpha API](http://developer.wolframalpha.com)
- [Wolfram Alpha GitHub](https://github.com/jaraco/wolframalpha)
- [Wolfram Alpha Docs](http://products.wolframalpha.com/docs/WolframAlpha-API-Reference.pdf)
Empty file.
12 changes: 12 additions & 0 deletions packages/knowledge/config/config.sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"wikipedia": {
"lang": "en",
"sentences": 5,
"options": {}
},
"wolframalpha": {
"app_id": "YOUR_APP_ID",
"lang": "en",
"options": {}
}
}
Empty file.
Empty file.
41 changes: 41 additions & 0 deletions packages/knowledge/data/answers/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"wikipedia": {
"acquiring": [
"Right away!",
"One second please.",
"Just a second...",
"Browsing Wikipedia right now..."
],
"summary": [
"%summary%"
],
"disambiguation_error": [
"Disambiguation error."
],
"page_error": [
"Your request does not match any page."
],
"no_entities_error": [
"Your request was not well formatted. Please, retry."
],
"connection_error": [
"I'm having issuse reaching the server."
]
},
"wolframalpha": {
"acquiring": [
"Right away!",
"One second please.",
"Just a second..."
],
"result": [
"%result%"
],
"no_query": [
"Please, specify a query."
],
"connection_error": [
"I'm having issuse reaching the server."
]
}
}
Empty file.
95 changes: 95 additions & 0 deletions packages/knowledge/data/expressions/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"wikipedia": {
"summary": {
"expressions": [
"Search on Wikipedia",
"Search on Wikipedia for",
"Search for ",
"Search",
"Look for",
"On wikipedia look for"
],
"entities": [
{
"type": "trim",
"name": "page",
"conditions": [
{
"type": "after_last",
"from": "wikipedia"
},
{
"type": "between",
"from": "wikipedia",
"to": "?"
},
{
"type": "after_last",
"from": "for"
},
{
"type": "between",
"from": "for",
"to": "?"
},
{
"type": "between",
"from": "search",
"to": "on"
},
{
"type": "after_last",
"from": "search"
}
]
}
]
},
"random": {
"expressions": [
"Search a random page on Wikipedia",
"Search a random Wikipedia page",
"Give me a random page on Wikipedia"
]
}
},
"wolframalpha": {
"query": {
"expressions": [
"On Wolfram Alpha",
"On Wolfram Alpha search for",
"On Wolfram Alpha search for the",
"Search for this on Wolfram Alpha"
],
"entities": [
{
"type": "trim",
"name": "query",
"conditions": [
{
"type": "before_first",
"from": "on"
},
{
"type": "after_last",
"from": "Alpha"
},
{
"type": "after_last",
"from": "for"
},
{
"type": "after_last",
"from": "the"
},
{
"type": "between",
"from": "for",
"to": "on"
}
]
}
]
}
}
}
1 change: 1 addition & 0 deletions packages/knowledge/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0