Skip to content

Commit

Permalink
Merge pull request conversationai#38 from conversationai/iislucas3
Browse files Browse the repository at this point in the history
Quality summary support & improved data upload scripts
  • Loading branch information
iislucas authored Oct 19, 2017
2 parents f90d8b2 + 4f18541 commit a6b53b5
Show file tree
Hide file tree
Showing 26 changed files with 1,680 additions and 2,285 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,40 @@ declare module '@google-cloud/spanner' {
export interface Query {
sql: string;
}
export interface SpannerDate {}
export interface SpannerFloat {}
export interface SpannerInt {}
export interface SpannerTimestamp {}
export interface SpannerDate {
// A fake field to make this type unique: fake nominal typing using npm namespace.
__type__: '@google-cloud/spanner:SpannerDate';
}
export interface SpannerFloat {
// A fake field to make this type unique: fake nominal typing using npm namespace.
__type__: '@google-cloud/spanner:SpannerFloat';
}
export interface SpannerInt {
// A fake field to make this type unique: fake nominal typing using npm namespace.
__type__: '@google-cloud/spanner:SpannerInt';
}
export interface SpannerTimestamp {
// A fake field to make this type unique: fake nominal typing using npm namespace.
__type__: '@google-cloud/spanner:SpannerTimestamp';
}
export type InputField = string | null | SpannerDate | SpannerFloat
| SpannerInt | SpannerTimestamp;
export interface InputRow {
[columnKey:string] : string | null | SpannerDate | SpannerFloat
| SpannerInt | SpannerTimestamp
[columnKey:string] : InputField;
}
export interface Table {
insert(rows:InputRow[]): Promise<void>;
deleteRows(rowKeys:string[] | string[][]) : Promise<void>;
update(rows:InputRow[]) : Promise<void>;
}

// Rows and Columns.
export type ResultRow = {
name:string,
// The value representation chosen here by the spanner nodejs client
// library is pretty surprising: INT64s are converted into
// Objects with a value field that is the string representation of the number.
// Strings on the other hand are just strings.
value: string | { value: string } | null }[]
// The value representation chosen here by the spanner nodejs client
// library is pretty surprising: INT64s are converted into
// Objects with a value field that is the string representation of the number.
// Strings on the other hand are just strings.
export type ResultField = string | { value: string } | null | Date;
// Rows and Columns (Fields) in that row.
export type ResultRow = { name:string; value: ResultField; }[]
export type QueryResult = ResultRow[];
export interface Database {
table(tableName:string): Table;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ curl -H "x-admin-auth-key: ${ADMIN_AUTH_KEY}" \
"question_group_id":"foo1",
"status":"setup",
"answers_per_question":3,
"answer_schema": { "comments": { "stringInput" : {} },
"toxicity": { "validEnumValues": ["ok", "unsure", "toxic"] } }
"answer_schema": "{"comments":{"stringInput":{}},"toxic":{"validEnumValues":["ok","unsure","toxic"]},"threat":{"validEnumValues":["ok","unsure","toxic"]},"insult":{"validEnumValues":["ok","unsure","toxic"]},"identityHate":{"validEnumValues":["ok","unsure","toxic"]},"obscene":{"validEnumValues":["ok","unsure","toxic"]}}"
}' ${SERVER}/active_jobs/job1_for_foo1
```

Expand All @@ -55,49 +54,49 @@ curl -H "x-admin-auth-key: ${ADMIN_AUTH_KEY}" \
{
"question_id": "q1",
"question_group_id":"foo1",
"question":"{\"string\":\"Is this a toxic comment?\"}",
"accepted_answers": "{ \"toxicity\": { \"enumScores\": { \"ok\": 0, \"unsure\": -1, \"toxic\": -1 } } }",
"question": { "string": "Is q1 a toxic really comment?"},
"accepted_answers": { "toxic": { "enumScores": { "notatall": 0, "somewhat": -1, "very": -1 } } },
"type": "training"
},
{
"question_id": "q2",
"question_group_id":"foo1",
"question":"{\"string\":\"Is this a shitty toxic comment?\"}",
"accepted_answers": "{ \"toxicity\": { \"enumScores\": { \"ok\": -1, \"unsure\": 0, \"toxic\": 0 } } }",
"question": { "string": "Is q2 a toxic really comment?"},
"accepted_answers": { "toxic": { "enumScores": { "notatall": -1, "somewhat": 0, "very": 0 } } },
"type": "test"
},
{
"question_id": "q3",
"question_group_id":"foo1",
"question":"{\"string\":\"Is this a toxic really comment?\"}",
"question": { "string": "Is q3 a toxic really comment?"},
"accepted_answers": null,
"type": "toanswer"
},
{
"question_id": "q4",
"question_group_id":"foo1",
"question":"{\"string\":\"Is this a toxic really comment?\"}",
"question": { "string": "Is q4 a toxic really comment?"},
"accepted_answers": null,
"type": "toanswer"
},
{
"question_id": "q4",
"question_group_id":"foo2",
"question":"{\"string\":\"foo2! q4?\"}",
"question": { "string": "foo2! q4?"},
"accepted_answers": null,
"type": "toanswer"
},
{
"question_id": "q5",
"question_group_id":"foo2",
"question":"{\"string\":\"foo2! q5?\"}",
"question": { "string": "foo2! q5?"},
"accepted_answers": null,
"type": "toanswer"
},
{
"question_id": "q6",
"question_group_id":"foo2",
"question":"{\"string\":\"foo2! q6?\"}",
"question": { "string": "foo2! q6?"},
"accepted_answers": null,
"type": "toanswer"
}
Expand Down Expand Up @@ -186,18 +185,18 @@ Submit some answers from crowd-workers:
```
# Example answers with answer_id specified.
curl -H "Content-Type: application/json" -X POST -d \
'{ "answer_id": "1", "answer": "{\"toxicity\": { \"enumAnswer\": \"ok\"} }" }' \
'{ "answer_id": "1", "answer":{"toxic":"notatall"} }' \
${SERVER}/client_jobs/job1_for_foo1/questions/q1/answers/user_fuzbar1
curl -H "Content-Type: application/json" -X POST -d \
'{ "answer_id": "2", "answer": "{\"toxicity\": { \"enumAnswer\": \"unsure\"} }" }' \
'{ "answer_id": "2", "answer":{"toxic":"somewhat"} }' \
${SERVER}/client_jobs/job1_for_foo1/questions/q1/answers/user_fuzbar1
curl -H "Content-Type: application/json" -X POST -d \
'{ "answer": "{\"toxicity\": { \"enumAnswer\": \"toxic\"} }" }' \
'{ "answer":{"toxic":"very"} }' \
${SERVER}/client_jobs/job1_for_foo1/questions/q1/answers/user_fuzbar2
curl -H "Content-Type: application/json" -X POST -d \
'{ "answer": "{\"toxicity\": { \"enumAnswer\": \"toxic\"} }" }' \
'{ "answer": { "toxic": { "enumAnswer": "very"} } }' \
${SERVER}/client_jobs/job1_for_foo1/questions/q2/answers/user_fuzbar1
curl -H "Content-Type: application/json" -X POST -d \
'{ "answer": "{\"toxicity\": { \"enumAnswer\": \"unsure\"} }" }' \
Expand Down
Loading

0 comments on commit a6b53b5

Please sign in to comment.