Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import unicode_literals
- from sberbot.core.service import SkillService
- from yargy import Parser, rule
- from yargy.predicates import dictionary
- import requests
- class Headortail(SkillService):
- #def __init__(self, host, port, app_name):
- #super(SkillService, self).__init__(host, port, app_name)
- #self.headortail = Parser(self.head_rule())
- def __call__(self, utterances_batch, states_batch=None, history_batch=None, **kwargs):
- output = ['head', 'tail']
- responce = np.random.choice(output)
- return responce
- def classify(self, utterances_batch, states_batch=None, history_batch=None):
- print("head or tail intent")
- user_text = utterances_batch[0]
- matches = list(self.headortail.findall(user_text))
- if len(matches) >= 1:
- return {'name': 'Headortail'}
- return {}
- @classmethod
- def fit(cls, *args, **kwargs):
- """Don't need fit"""
- return None
- @staticmethod
- def head_rule():
- return rule(
- dictionary({
- 'орел',
- 'решка',
- 'монетку',
- 'подбрось',
- 'head',
- 'tail',
- 'toss',
- 'coin'
- })
- ).named('Headortail')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement