Add tactic
This commit is contained in:
parent
d4505f30e4
commit
7120c99b6a
@ -2,7 +2,7 @@
|
||||
|
||||
grammar issues;
|
||||
|
||||
public <issue> = (pokaz mi | wyswietl | powiedz mi o| przedstaw mi) [nowe | nowych] <issues> [<time>] w <repo>;
|
||||
public <issue> = (pokaz [mi] [moje] | wyswietl [mi] [moje] | powiedz mi o| przedstaw [mi] [moje]) [nowe | nowych] <issues> [<time>] w <repo>;
|
||||
|
||||
<repozytoria> = gra - kolko i krzyzyk | zajęcia ai | projekt - sklep | super_stronka_internetowa | nazwarepozytorium | pizza | zajecia;
|
||||
|
||||
|
@ -15,6 +15,3 @@ public <notifications> = (pokaz [mi] | wyświetl [mi] | przedstaw [mi]) [<liczba
|
||||
<powiadomienia> = notif | pow | powiadomienia | notification | notifications;
|
||||
|
||||
<miesiac> = (styczen | stycznia | styczniu) | (luty | lutego | lutym) | (marzec | marca | marcu) | (kwiecien | kwietniu | kwietnia) | (maj | maja | maju) | (czerwiec | czerwca | czerwcu) | (lipiec | lipca | lipcu) | (sierpien | sierpnia | sierpniu) | (wrzesien | wrzesieniu | wrzesnia) | (pazdziernik | październiku | pazdziernika) | (listopad | listopada | listopadzie) | (grudzien | grudnia | grudniu);
|
||||
|
||||
|
||||
|
||||
|
@ -41,17 +41,20 @@ def nlu(utterance):
|
||||
|
||||
|
||||
#result = nlu('jakie są dostępne funkcje')
|
||||
#result = nlu('w czym możesz mi pomóc')
|
||||
#result = nlu('w czym mozesz mi pomoc')
|
||||
|
||||
#result = nlu('jakie są nowe pull requesty')
|
||||
#result = nlu('jakie sa nowe pull requesty')
|
||||
#result = nlu('ile jest nowych pull requestow')
|
||||
|
||||
#result = nlu('pokaż mi nowe pow z lipca')
|
||||
|
||||
#result = nlu('przedstaw mi nowe issues z trzech miesiecy w Zajęcia AI')
|
||||
#result = nlu('przedstaw mi moje issues w Zajęcia AI')
|
||||
|
||||
#result = nlu('siemanko')
|
||||
#result = nlu('zegnaj')
|
||||
#result = nlu('Zajęcia AI')
|
||||
#result = nlu('pokaz mi moje powiadomienia')
|
||||
|
||||
|
||||
#result = nlu('pokaż mi testy od lutego w Zajęcia AI')
|
||||
#result = nlu('powiedz co nowego na moim repozytorium Zajęcia AI')
|
||||
|
80
system_mockup/apimock.py
Normal file
80
system_mockup/apimock.py
Normal file
@ -0,0 +1,80 @@
|
||||
#Possible actions:
|
||||
# - create repository
|
||||
# - delete repository
|
||||
# - list repositories
|
||||
# - list respository issues
|
||||
# - list repository pull requests
|
||||
# - list notifications
|
||||
# - list repository tests
|
||||
|
||||
repositoriesMock = ["repo1", "repo2", "repo3"]
|
||||
issuesMock = [
|
||||
{
|
||||
"name": "Issue 1",
|
||||
"description": "Description of issue 1",
|
||||
"status": "open"
|
||||
},
|
||||
{
|
||||
"name": "Issue 2",
|
||||
"description": "Description of issue 2",
|
||||
"status": "closed"
|
||||
}
|
||||
]
|
||||
pullRequestMock = [
|
||||
{
|
||||
"name": "pull request 1",
|
||||
"description": "description 1",
|
||||
"state": "open"
|
||||
},
|
||||
{
|
||||
"name": "pull request 2",
|
||||
"description": "description 2",
|
||||
"state": "open"
|
||||
}
|
||||
]
|
||||
notificationsMock = [
|
||||
{
|
||||
"name": "notification 1",
|
||||
"description": "description 1"
|
||||
},
|
||||
{
|
||||
"name": "notification 2",
|
||||
"description": "description 2"
|
||||
}
|
||||
]
|
||||
testMock = [
|
||||
{
|
||||
"name": "test1",
|
||||
"description": "test1 description",
|
||||
"status": "passed"
|
||||
},
|
||||
{
|
||||
"name": "test2",
|
||||
"description": "test2 description",
|
||||
"status": "failed"
|
||||
},
|
||||
]
|
||||
|
||||
def createRepository(repositoryName):
|
||||
pass
|
||||
|
||||
def deleteRepository(repositoryName):
|
||||
pass
|
||||
|
||||
def listRepositories():
|
||||
return repositoriesMock
|
||||
|
||||
def listPublicRepositories():
|
||||
return repositoriesMock
|
||||
|
||||
def listRepositoryIssues(repositoryName):
|
||||
return issuesMock
|
||||
|
||||
def listRepositoryPullRequests(repositoryName):
|
||||
return pullRequestMock
|
||||
|
||||
def listNotifications():
|
||||
return notificationsMock
|
||||
|
||||
def listRepositoryTests(repositoryName):
|
||||
return testMock
|
@ -6,8 +6,8 @@ dialogue_state = {
|
||||
'topics': [],
|
||||
# facts is a dict of contextual data such as selected repo and a timeframe
|
||||
'facts': {
|
||||
'repo' : '',
|
||||
'time': ''
|
||||
'repo' : None,
|
||||
'time': None
|
||||
},
|
||||
'counter': 0
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ def main():
|
||||
# print(state)
|
||||
|
||||
questions = taktyka_dialogu(state, frame) # todo dodac stan
|
||||
# print(questions)
|
||||
#
|
||||
# generator_jezyka_nautalnego(frame, questions, state)
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
from apimock import *
|
||||
|
||||
gramar_slots = {
|
||||
# 'act': ((slot0, 'required'),
|
||||
# (slot1, 'optional')
|
||||
@ -9,16 +11,29 @@ gramar_slots = {
|
||||
('repo', 'required')
|
||||
),
|
||||
'notifications': (('liczba', 'optional'),
|
||||
# ('repo', 'required')
|
||||
('repo', 'required')
|
||||
),
|
||||
'tests': (('test', 'optional'),
|
||||
# ('repo', 'required')
|
||||
('repo', 'required')
|
||||
),
|
||||
'time': (('time_when', 'required'),
|
||||
('timeunit', 'required')
|
||||
('timeunit', 'required'),
|
||||
('liczba','optional')
|
||||
),
|
||||
'issues': (
|
||||
'issues': (('time_when','optional'),
|
||||
('liczba','optional'),
|
||||
('timeunit','optional'),
|
||||
('repozytoria', 'required')
|
||||
),
|
||||
'number': (('liczba', 'required')
|
||||
),
|
||||
'help': (('functions', 'optional'),
|
||||
('help', 'optional')
|
||||
),
|
||||
'repo': (('repozytoria', 'required')
|
||||
),
|
||||
'hello': (),
|
||||
'bye': (),
|
||||
}
|
||||
|
||||
|
||||
@ -34,40 +49,70 @@ def taktyka_dialogu(state, frame):
|
||||
def short_thread(state):
|
||||
if state['current_context'] == 'pomoc':
|
||||
print(state['current_context'])
|
||||
pass
|
||||
#TODO
|
||||
return state['current_context']
|
||||
#TODO?
|
||||
else:
|
||||
print(state['current_context'])
|
||||
return state['current_context']
|
||||
|
||||
def validate_repo(repo):
|
||||
if repo not in listRepositories():
|
||||
print('repo not in listRepositories')
|
||||
if repo not in listPublicRepositories():
|
||||
print('repo not in listPublicRepositories')
|
||||
#validate_date
|
||||
#if zakres dat
|
||||
#if test/notification/issues/pullRequest non empty
|
||||
|
||||
def long_thread(state):
|
||||
act = state['current_context']
|
||||
slots = []
|
||||
print(act)
|
||||
# slots = []
|
||||
for topic in state['topics']:
|
||||
if act == topic['act']:
|
||||
slots = topic['slots']
|
||||
required = gramar_slots[act]
|
||||
for item in required:
|
||||
if item[1] == 'required':
|
||||
req_args, opt_args = agregate(required, slots)
|
||||
facts = state['facts']# osobno validuj repo z req i z facts
|
||||
req_args = add_facts(req_args, facts)
|
||||
opt_args = add_facts(opt_args, facts)
|
||||
required_empty = check_req(req_args)
|
||||
if required_empty:
|
||||
return "QESTION", required_empty[0] #slot do uzupełnienia
|
||||
return "ANSWER", req_args, opt_args #wyświetl użytkownikowi
|
||||
|
||||
def check_req(req_args):
|
||||
req = []
|
||||
for item in req_args:
|
||||
if item[1] == None:
|
||||
req.append(item)
|
||||
return req
|
||||
|
||||
def add_facts(args, facts):
|
||||
for key, value in facts.items():
|
||||
for idx, item in enumerate(args):
|
||||
if key == item[0] and value != None and item[1] == None:
|
||||
args[idx] = value
|
||||
if key == 'repo':
|
||||
validate_repo(value)
|
||||
|
||||
|
||||
return args
|
||||
|
||||
def agregate(grammar, slots):
|
||||
req_args, opt_args = [], []
|
||||
for item in grammar:
|
||||
value = None
|
||||
for slot in slots:
|
||||
if slot[0] == item[0] and slot[1] == '':
|
||||
if slot[0] == 'repo':
|
||||
state['facts']['repo'] == ''
|
||||
print('dopytaj')
|
||||
print(item[0])
|
||||
elif slot[0] == 'time':
|
||||
state['facts']['time'] == ''
|
||||
print('dopytaj')
|
||||
print(item[0])
|
||||
else:
|
||||
print('dopytaj')
|
||||
print(item[0])
|
||||
#pokaz
|
||||
#powiedz, że może dopytać o... 'optional'
|
||||
if slot[0] == item[0]:
|
||||
value = None if slot[1] == '' else slot[1]
|
||||
if item[1] == 'required':
|
||||
req_args.append([item[0], value])
|
||||
elif item[1] == 'optional':
|
||||
opt_args.append([item[0], value])
|
||||
return req_args, opt_args
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#todo dodać mock github api
|
||||
#powiedz, że może dopytać o 'optional'
|
||||
#gramar_slots musi mieć 100% gramatyk albo będzie pomijał sloty
|
||||
|
Loading…
Reference in New Issue
Block a user