Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/US579/507
Browse files Browse the repository at this point in the history
  • Loading branch information
US579 committed Nov 7, 2019
2 parents 8b24cc3 + 6424846 commit 31f21d3
Show file tree
Hide file tree
Showing 2,729 changed files with 67 additions and 328,464 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@

+ * type function
- <set type=<formal>> Ok, I will remember the type name <get type>.

+ *isdigit()
- if <star> is string type, Returns True if all characters in the string are digits
^ if <star> is a byte type, Return true if all bytes in the sequence are ASCII decimal digits and the sequence is not empty, false otherwise. ASCII decimal digits are those byte values in the sequence b'0123456789'.
* <get type> == String => Returns True if all characters in the string are digits

+ *isalpha()
- Returns True if all characters in the string are in the alphabet
* <get type> == String => Returns True if all characters in the string are in the alphabet

+ *upper()
- if <star> is string type, Converts a string into upper case
^ , Return a copy of the string with all the cased characters converted to uppercase.
* <get type> == String => Converts a string into upper case, Return a copy of the string with all the cased characters converted to uppercase.

+ *translate()
- Returns a translated string

* <get type> == String => Returns a translated string

+ *lower()
- if <star> is bytes type, return a copy of the sequence with all the uppercase ASCII characters converted to their corresponding lowercase counterpart.
^ if <star> is string type, return a copy of the string with all the cased characters converted to lowercase.
* <get type> == String => if <star> is string type, return a copy of the string with all the cased characters converted to lowercase.

+ *split()
- Splits the string at the specified separator, and returns a list
* <get type> == String => Splits the string at the specified separator, and returns a list

+ *endswith()
- Returns true if the string ends with the specified value
* <get type> == String => Returns true if the string ends with the specified value

+ *lstrip()
- Returns a left trim version of the string
* <get type> == String => Returns a left trim version of the string

+ *encode()
- Returns an encoded version of the string
* <get type> == String => Returns an encoded version of the string

+ *startswith()
- Returns true if the string starts with the specified value
* <get type> == String => Returns true if the string starts with the specified value
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,5 @@
* <get name> != undefined => Yes, your name is <get name>!
- I don't know your name.

+ for child in children
- ➪ iterator method count every elements in children

+ *
- Google search: "http://google.com/search?q=<star>"
- Google search: "http://google.com/search?q=<star>"
52 changes: 50 additions & 2 deletions backend/OpenSourceProject/backend/ChatService/api/chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
from .. import schemas,config
import jwt
import os
import json


from wit import Wit
access_token = "ABJWGG53QBEVM6UY6AUMBPNP42EQCXOZ"
client = Wit(access_token)


rs = RiveScript()
rs.load_directory(os.getcwd())
rs.sort_replies()
Expand All @@ -17,5 +25,45 @@ def get(self):
try:
data = jwt.decode(g.headers['Token'],config.Secret_Key)
except Exception:
return make_response(jsonify(message = 'invalid token'), 400)
return make_response(jsonify(messge = rs.reply(data['email'], g.args['message'])))
return make_response(jsonify(message = 'invalid token'), 401)
#print(g.args['message'])
resp = client.message(g.args['message'])
resp = self.wit_response(resp)
#print("*"*100)
#print(rs.reply(data['email'], g.args['message']))
#print(resp)
if resp == None:
return make_response(jsonify(messge=rs.reply(data['email'], g.args['message'])))
else:
return make_response(jsonify(messge=resp))
# if rs.reply(data['email'], g.args['message']) == "Sorry I don't understand.":
# return make_response(jsonify(messge = resp ))
# return make_response(jsonify(messge = rs.reply(data['email'], g.args['message'])))

def wit_response(self,text):
#print(json.dumps(text, indent=4))
#print(text["_text"])
message = "Analysing the code " + text["_text"] + " : "
entities = list(text["entities"].keys())
if "intent" not in entities:
return None
intent = text["entities"]["intent"][0]["value"]
if intent == "function_search":
return None

if intent == "Loop_function":
m_function ="This is a Loop Function, since the key world " +\
text["entities"]["loop_tag"][0]["value"]
if intent == "Conditional_statement":
m_function = "This is a Conditions Statement, since the key world " + \
text["entities"]["condition_statement_tag"][0]["value"]

if "condition" in entities:
condition_entities = list(text["entities"]["condition"][0]["entities"].keys())
c = text["entities"]["condition"][0]["entities"]
m_condition = ". The rest is condition: " +text["entities"]["condition"][0]["value"] + "; it can split into several parts: "
for i in condition_entities:
if i!= "intent":
m_condition += i + " is " + c[i][0]["value"] +"; "

return message + m_function + m_condition
2 changes: 1 addition & 1 deletion backend/OpenSourceProject/backend/ChatService/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def copy(self):

base_path = '/ChatService'

definitions = {'definitions': {'User': {'type': 'object', 'properties': {'email': {'type': 'string'}, 'password': {'type': 'string'}, 'role': {'type': 'string', 'enum': ['mentor', 'learner']}}, 'xml': {'name': 'User'}}}, 'parameters': {}}
definitions = {'definitions': {'User': {'type': 'object', 'properties': {'email': {'type': 'string'}, 'password': {'type': 'string'}}, 'xml': {'name': 'User'}}}, 'parameters': {}}

validators = {
('chatbot', 'GET'): {'headers': {'required': ['Token'], 'properties': {'Token': {'type': 'string'}}}, 'args': {'required': ['message'], 'properties': {'message': {'type': 'string'}}}},
Expand Down
1 change: 0 additions & 1 deletion backend/OpenSourceProject/backend/env/.Python

This file was deleted.

1 change: 0 additions & 1 deletion backend/OpenSourceProject/backend/env/include/python3.6m

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion backend/OpenSourceProject/backend/env/lib/python3.6/abc.py

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion backend/OpenSourceProject/backend/env/lib/python3.6/imp.py

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion backend/OpenSourceProject/backend/env/lib/python3.6/io.py

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Empty file.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion backend/OpenSourceProject/backend/env/lib/python3.6/os.py

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion backend/OpenSourceProject/backend/env/lib/python3.6/re.py

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 31f21d3

Please sign in to comment.