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

Add NONE status to mentor answer #66

Open
wants to merge 1 commit into
base: main
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mentor_classifier/mentor_classifier/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def get_off_topic_threshold() -> float:
GQL_QUERY_MENTOR = """
query Mentor($id: ID!) {
mentor(id: $id) {
mentorType
subjects {
name
}
Expand Down
13 changes: 12 additions & 1 deletion mentor_classifier/mentor_classifier/mentor.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,19 @@ def load(self):
self.topics.append(topic["name"])
for answer in data.get("answers", []):
question = answer["question"]
if answer["status"] != "COMPLETE":
if answer["status"] == "INCOMPLETE":
continue
if answer["status"] != "COMPLETE":
if not answer["transcript"]:
continue
if data.get("mentorType", "") == "VIDEO":
if (
not answer["webMedia"]
or not answer["mobileMedia"]
or not answer["webMedia"].get("url", "")
or not answer["mobileMedia"].get("url", "")
):
continue
if question["type"] == "UTTERANCE":
if question["name"] not in self.utterances_by_type:
self.utterances_by_type[question["name"]] = []
Expand Down
57 changes: 57 additions & 0 deletions mentor_classifier/tests/fixtures/graphql/clint.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"data": {
"mentor": {
"mentorType": "VIDEO",
"subjects": [
{
"name": "Advice"
Expand Down Expand Up @@ -147,6 +148,62 @@
"paraphrases": []
},
"webMedia":"/clint/offtopic.mp4"
},
{
"_id": "A7",
"status": "NONE",
"transcript": "A7",
"question": {
"_id": "Q7",
"question": "Q7",
"type": null,
"name": null,
"paraphrases": []
},
"webMedia":{ "type": "video", "tag": "web", "url": "q1_web.mp4" },
"mobileMedia":{ "type": "video", "tag": "mobile", "url": "q1_mobile.mp4" }
},
{
"_id": "A8",
"status": "NONE",
"transcript": "",
"question": {
"_id": "Q8",
"question": "Q8",
"type": null,
"name": null,
"paraphrases": []
},
"webMedia":{ "type": "video", "tag": "web", "url": "q1_web.mp4" },
"mobileMedia":{ "type": "video", "tag": "mobile", "url": "q1_mobile.mp4" }
},
{
"_id": "A9",
"status": "NONE",
"transcript": "A9",
"question": {
"_id": "Q9",
"question": "Q9",
"type": null,
"name": null,
"paraphrases": []
},
"webMedia":null,
"mobileMedia":null
},
{
"_id": "A10",
"status": "NONE",
"transcript": "A10",
"question": {
"_id": "Q10",
"question": "Q10",
"type": null,
"name": null,
"paraphrases": []
},
"webMedia":{ "type": "video", "tag": "web" },
"mobileMedia":{ "type": "video", "tag": "mobile" }
}
]
}
Expand Down
163 changes: 163 additions & 0 deletions mentor_classifier/tests/fixtures/graphql/clint_chat.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
{
"data": {
"mentor": {
"mentorType": "CHAT",
"subjects": [
{
"name": "Advice"
},
{
"name": "Background"
},
{
"name": "Utterances"
}
],
"topics": [
{
"name": "About Me"
},
{
"name": "Weird"
}
],
"questions": [
{
"question": {
"_id": "Q1"
},
"topics": [
{
"name": "About Me"
}
]
},
{
"question": {
"_id": "Q2"
},
"topics": []
},
{
"question": {
"_id": "Q3"
},
"topics": [
{
"name": "Weird"
}
]
},
{
"question": {
"_id": "Q4"
},
"topics": []
},
{
"question": {
"_id": "Q5"
},
"topics": []
},
{
"question": {
"_id": "Q6"
},
"topics": []
}
],
"answers": [
{
"_id": "A1",
"status": "COMPLETE",
"transcript": "Clint Anderson",
"question": {
"_id": "Q1",
"question": "What is your name?",
"type": null,
"name": null,
"paraphrases": ["Who are you?"]
},
"webMedia":null,
"mobileMedia":null
},
{
"_id": "A2",
"status": "COMPLETE",
"transcript": "37 years old",
"question": {
"_id": "Q2",
"question": "How old are you?",
"type": null,
"name": null,
"paraphrases": ["What's your age?"]
}
},
{
"_id": "A3",
"status": "INCOMPLETE",
"transcript": null,
"question": {
"_id": "Q3",
"question": "Will you be my friend?",
"type": null,
"name": null,
"paraphrases": []
}
},
{
"_id": "A5",
"status": "COMPLETE",
"transcript": "Hi I'm Clint",
"question": {
"_id": "Q5",
"question": "Introduce yourself.",
"type": "UTTERANCE",
"name": "_INTRO_",
"paraphrases": []
}
},
{
"_id": "A6",
"status": "COMPLETE",
"transcript": "Ask me something else",
"question": {
"_id": "Q6",
"question": "Off topic",
"type": "UTTERANCE",
"name": "_OFF_TOPIC_",
"paraphrases": []
},
"webMedia":null
},
{
"_id": "A7",
"status": "NONE",
"transcript": "A7",
"question": {
"_id": "Q7",
"question": "Q7",
"type": null,
"name": null,
"paraphrases": []
},
"webMedia":null
},
{
"_id": "A8",
"status": "NONE",
"transcript": "",
"question": {
"_id": "Q8",
"question": "Q8",
"type": null,
"name": null,
"paraphrases": []
},
"webMedia":null
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"data": {
"mentor": {
"mentorType": "VIDEO",
"subjects": [
{
"name": "Advice"
Expand Down
Loading