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/ru friendship skill #120

Merged
merged 33 commits into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d561d93
feat: add language parameters
dilyararimovna Mar 2, 2022
a532393
fix: black codestyle
dilyararimovna Mar 2, 2022
2370c59
fix: codestyle
dilyararimovna Mar 2, 2022
7048a93
fix: dff friendship ru
dilyararimovna Mar 2, 2022
e3fd43a
fix: dff friendship ru
dilyararimovna Mar 2, 2022
3441408
fix: dff friendship ru
dilyararimovna Mar 2, 2022
e0b3502
fix: dff friendship ru уокротила реплики
dilyararimovna Mar 3, 2022
0de4ca7
fix: dff friendship tests
dilyararimovna Mar 3, 2022
ac4acf1
fix: dff friendship tests
dilyararimovna Mar 3, 2022
a7afb56
Merge remote-tracking branch 'origin/feat/russian_baseline' into feat…
dilyararimovna Mar 3, 2022
2586df3
fix: languAGE FOR WIKI
dilyararimovna Mar 3, 2022
856a9d8
fix: language default value
dilyararimovna Mar 3, 2022
f41f4a0
fix: language default value
dilyararimovna Mar 3, 2022
b3cf2cc
Merge remote-tracking branch 'origin/feat/russian_baseline' into feat…
dilyararimovna Mar 12, 2022
4f49f69
fix: language env var
dilyararimovna Mar 12, 2022
c7f86c0
fix: use templates by language
dilyararimovna Mar 12, 2022
5c76687
fix: ru templates
dilyararimovna Mar 12, 2022
723a2e5
fix: no lang env var in common
dilyararimovna Mar 12, 2022
9296982
fix: lang to ackn
dilyararimovna Mar 12, 2022
4970973
fizx: codestyle
dilyararimovna Mar 12, 2022
1208236
feat: default lang value
dilyararimovna Mar 12, 2022
f1487ea
fix: dummy for russian
dilyararimovna Mar 12, 2022
2d45711
fix: no en acks
dilyararimovna Mar 12, 2022
cb64f47
fix: how are you ru
dilyararimovna Mar 12, 2022
374bd6c
fix: logs for response functions
dilyararimovna Mar 12, 2022
5ae3941
fix: logs for condition functions
dilyararimovna Mar 12, 2022
7840e40
fix: ru version if what to talk about
dilyararimovna Mar 12, 2022
85b5f6a
feat: ru tests
dilyararimovna Mar 12, 2022
f36c98f
fix: codestyle
dilyararimovna Mar 12, 2022
185ceb7
fix: ru condition to resp selector
dilyararimovna Mar 12, 2022
15cb123
fix: ru condition to resp selector
dilyararimovna Mar 13, 2022
fafc6f2
fix: logging level and configuration
dilyararimovna Mar 14, 2022
aa9762b
fix: ascii in tests
dilyararimovna Mar 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion annotators/BadlistedWordsDetector/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN pip install -r /src/requirements.txt
RUN spacy download en_core_web_sm
RUN spacy download ru_core_news_sm

ARG LANGUAGE
ARG LANGUAGE=EN
ENV LANGUAGE ${LANGUAGE}

COPY . /src/
Expand Down
4 changes: 2 additions & 2 deletions annotators/BadlistedWordsDetector/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


sentry_sdk.init(getenv("SENTRY_DSN"))
LANGUAGE = getenv("LANGUAGE", "ENGLISH")
LANGUAGE = getenv("LANGUAGE", "EN")

logging.basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO)
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -144,7 +144,7 @@ def collect_ngrams(utterance: Doc, max_ngram: int):
return all_ngrams


if LANGUAGE == "RUSSIAN":
if LANGUAGE == "RU":
nlp_pipeline = spacy.load("ru_core_news_sm", exclude=["senter", "ner"])
badlists_dir = Path("./badlists")
badlists_files = [f for f in badlists_dir.iterdir() if f.is_file() and "_ru" in f.name]
Expand Down
4 changes: 2 additions & 2 deletions annotators/BadlistedWordsDetector/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
def main():
url = "http://0.0.0.0:8018/badlisted_words"

LANGUAGE = getenv("LANGUAGE", "ENGLISH")
if LANGUAGE == "RUSSIAN":
LANGUAGE = getenv("LANGUAGE", "EN")
if LANGUAGE == "RU":
request_data = {
"sentences": ["пизда настала", "застрахуйте уже его", "пошел нахер!"],
}
Expand Down
2 changes: 1 addition & 1 deletion annotators/wiki_parser/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARG CONFIG
ARG COMMIT
ARG PORT
ARG SRC_DIR
ARG LANGUAGE
ARG LANGUAGE=EN

ENV CONFIG=$CONFIG
ENV PORT=$PORT
Expand Down
2 changes: 1 addition & 1 deletion assistant_dists/dream/docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ services:
args:
SERVICE_PORT: 8008
SERVICE_NAME: dff_program_y_skill
LANGUAGE: ENGLISH
LANGUAGE: EN
context: .
dockerfile: ./skills/dff_program_y_skill/Dockerfile
command: gunicorn --workers=1 server:app -b 0.0.0.0:8008 --reload
Expand Down
8 changes: 6 additions & 2 deletions assistant_dists/dream_russian/docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
args:
SERVICE_PORT: 8008
SERVICE_NAME: dff_program_y_skill
LANGUAGE: RUSSIAN
LANGUAGE: RU
context: .
dockerfile: ./skills/dff_program_y_skill/Dockerfile
command: gunicorn --workers=1 server:app -b 0.0.0.0:8008 --reload
Expand All @@ -32,6 +32,8 @@ services:
build:
context: .
dockerfile: ./response_selectors/convers_evaluation_based_selector/Dockerfile
args:
LANGUAGE: RU
command: flask run -h 0.0.0.0 -p 8009
environment:
- FLASK_APP=server
Expand Down Expand Up @@ -82,7 +84,7 @@ services:
env_file: [.env]
build:
args:
LANGUAGE: RUSSIAN
LANGUAGE: RU
context: annotators/BadlistedWordsDetector/
command: flask run -h 0.0.0.0 -p 8018
environment:
Expand Down Expand Up @@ -219,6 +221,7 @@ services:
args:
SERVICE_PORT: 8086
SERVICE_NAME: dff_friendship_skill # has to be the same with skill dir name
LANGUAGE: RU
context: .
dockerfile: ./skills/dff_friendship_skill/Dockerfile
command: gunicorn --workers=1 server:app -b 0.0.0.0:8086
Expand All @@ -239,6 +242,7 @@ services:
SERVICE_PORT: 8111
SERVICE_NAME: dff_wiki_skill
COMMIT: 5b99ac3392e8e178e2bb4f9b218d4ddb2ec2e242
LANGUAGE: RU
context: ./
dockerfile: ./skills/dff_wiki_skill/Dockerfile
command: gunicorn --workers=1 server:app -b 0.0.0.0:8111
Expand Down
13 changes: 10 additions & 3 deletions common/acknowledgements.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
GENERAL_ACKNOWLEDGEMENTS = {
"positive": ["Sounds cool! ", "Great! ", "Wonderful! ", "Cool!", "Nice!"],
"neutral": ["Okay. ", "Oh. ", "Huh. ", "Well. ", "Gotcha. ", "Aha. "],
"negative": ["Hmm... ", "I see.", "That's okay.", "Okay."],
"EN": {
"positive": ["Sounds cool! ", "Great! ", "Wonderful! ", "Cool!", "Nice!"],
"neutral": ["Okay. ", "Oh. ", "Huh. ", "Well. ", "Gotcha. ", "Aha. "],
"negative": ["Hmm... ", "I see.", "That's okay.", "Okay."],
},
"RU": {
"positive": ["Звучит круто! ", "Классно! ", "Великолепно! ", "Отлично!", "Замечательно!"],
"neutral": ["Окей. ", "Хм. ", "Ага. ", "Что ж. ", "Понятно. "],
"negative": ["Хмм... ", "Понимаю.", "Окей.", "Понятно."],
},
}
4 changes: 2 additions & 2 deletions common/dff/integration/condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def is_passive_user(ctx: Context, actor: Actor, history_len=2) -> bool:
return False


def get_not_used_and_save_sentiment_acknowledgement(ctx: Context, actor: Actor, sentiment=None):
def get_not_used_and_save_sentiment_acknowledgement(ctx: Context, actor: Actor, sentiment=None, lang="EN"):
if sentiment is None:
sentiment = int_ctx.get_human_sentiment(ctx, actor)
if is_yes_vars(ctx, actor) or is_no_vars(ctx, actor):
Expand All @@ -246,7 +246,7 @@ def get_not_used_and_save_sentiment_acknowledgement(ctx: Context, actor: Actor,
last_acknowledgements = shared_memory.get("last_acknowledgements", [])

ack = common_utils.get_not_used_template(
used_templates=last_acknowledgements, all_templates=GENERAL_ACKNOWLEDGEMENTS[sentiment]
used_templates=last_acknowledgements, all_templates=GENERAL_ACKNOWLEDGEMENTS[lang][sentiment]
)

used_acks = last_acknowledgements + [ack]
Expand Down
4 changes: 2 additions & 2 deletions common/dialogflow_framework/utils/condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def is_passive_user(vars, history_len=2):
return False


def get_not_used_and_save_sentiment_acknowledgement(vars):
def get_not_used_and_save_sentiment_acknowledgement(vars, lang="EN"):
sentiment = state_utils.get_human_sentiment(vars)
if is_yes_vars(vars) or is_no_vars(vars):
sentiment = "neutral"
Expand All @@ -259,7 +259,7 @@ def get_not_used_and_save_sentiment_acknowledgement(vars):
last_acknowledgements = shared_memory.get("last_acknowledgements", [])

ack = common_utils.get_not_used_template(
used_templates=last_acknowledgements, all_templates=GENERAL_ACKNOWLEDGEMENTS[sentiment]
used_templates=last_acknowledgements, all_templates=GENERAL_ACKNOWLEDGEMENTS[lang][sentiment]
)

used_acks = last_acknowledgements + [ack]
Expand Down
8 changes: 5 additions & 3 deletions common/emotion.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import re

from common.greeting import HOW_ARE_YOU_RESPONSES
from common.utils import get_emotions
from common.universal_templates import if_chat_about_particular_topic


POSITIVE_EMOTIONS = set(
[
"interest",
Expand Down Expand Up @@ -117,7 +119,7 @@
NOT_LONELINESS_TEMPLATE = re.compile(rf"{NOT_PATTERN} {ALONE_PATTERN}", re.IGNORECASE)
SAD_TEMPLATE = re.compile(rf"({SAD_PATTERN}|{POOR_ASR_PATTERN})", re.IGNORECASE)
NOT_SAD_TEMPLATE = re.compile(rf"{NOT_PATTERN} {SAD_PATTERN}", re.IGNORECASE)
BORING_TEMPLATE = re.compile(rf"(boring|bored)", re.IGNORECASE)
BORING_TEMPLATE = re.compile(r"(boring|bored)", re.IGNORECASE)
NOT_BORING_TEMPLATE = re.compile(rf"{NOT_PATTERN} (boring|bored)", re.IGNORECASE)
JOKE_REQUEST_TEMPLATE = re.compile(rf"{JOKE_PATTERN}", re.IGNORECASE)
NOT_JOKE_REQUEST_TEMPLATE = re.compile(rf"{NOT_PATTERN} {JOKE_PATTERN}", re.IGNORECASE)
Expand Down Expand Up @@ -179,7 +181,7 @@ def emo_advice_requested(uttr):


def skill_trigger_phrases():
return [HOW_DO_YOU_FEEL] + HOW_ARE_YOU_RESPONSES
return [HOW_DO_YOU_FEEL] + sum([HOW_ARE_YOU_RESPONSES[lang] for lang in ["RU", "EN"]], [])


def emotion_from_feel_answer(prev_bot_uttr, user_uttr):
Expand Down Expand Up @@ -207,7 +209,7 @@ def if_turn_on_emotion(user_utt, bot_uttr):
how_are_you = any(
[
how_are_you_response.lower() in bot_uttr.get("text", "").lower()
for how_are_you_response in HOW_ARE_YOU_RESPONSES
for how_are_you_response in sum([HOW_ARE_YOU_RESPONSES[lang] for lang in ["RU", "EN"]], [])
]
)
joke_request_detected = is_joke_requested(user_utt)
Expand Down
Loading