Skip to content

proverb: Add canonical data.#994

Merged
coriolinus merged 7 commits intomasterfrom
add-proverb-canonical-data
Nov 5, 2017
Merged

proverb: Add canonical data.#994
coriolinus merged 7 commits intomasterfrom
add-proverb-canonical-data

Conversation

@coriolinus
Copy link
Copy Markdown
Member

@coriolinus coriolinus commented Nov 3, 2017

This is based on the Rust tests as implemented in exercism/rust#380.
The lack of canonical data had resulted in odd custom tests being
designed, which was reported in exercism/rust#379.

Closes #578.

This is based on the Rust tests as implemented in exercism/rust#380.
The lack of canonical data had resulted in odd custom tests being
designed, which was reported in exercism/rust#379.
@Insti
Copy link
Copy Markdown
Contributor

Insti commented Nov 3, 2017

A couple of things that came up during #983 might be appropriate here:

  • Name the method recite
  • The expected output should be an array of strings without newlines.
  • Make sure the exercise and version properties are at the top.

See the canonical-data.json for food-chain as an example.

Comment thread exercises/proverb/canonical-data.json Outdated
"property": "construct"
},
{
"description": "three pieces modernized",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seem to be four pieces in the array.

@Insti
Copy link
Copy Markdown
Contributor

Insti commented Nov 3, 2017

Comment thread exercises/proverb/canonical-data.json Outdated
{
"description": "full proverb",
"expected": "For want of a nail the shoe was lost.\nFor want of a shoe the horse was lost.\nFor want of a horse the rider was lost.\nFor want of a rider the message was lost.\nFor want of a message the battle was lost.\nFor want of a battle the kingdom was lost.\nAnd all for the want of a nail.",
"input": [
Copy link
Copy Markdown
Contributor

@Insti Insti Nov 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method of input is not really specified in the description and is an implementation detail.

We either need to:

  • Update the description to specify that you will be provided with a list of items.
  • Change the tests so we're just testing for the specified verses. (see also food-chain.)

I think in order to differentiate this exercise from food-chain it might be good to use the "list of items" version.

cc: @ErikSchierboom

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Insti I agree that having a different input here makes for a more interesting exercise. The existing exercises are quite similar, so having some variety is nice.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the description should also be updated to clarify the problem.

@Insti Insti changed the title Add canonical data to the proverb exercise. proverb: Add canonical data. Nov 3, 2017
- name the method 'recite'
- expect output as an array of strings without newlines
- move exercise, version properties to the top
- rename 'three pieces modernized' to 'four pieces modernized', for accuracy
- add comment regarding output format
- add link to problem description
- Eliminate bogus word 'horseshoe' from last line of example proverb
- Add text noting that the inputs may vary
@coriolinus
Copy link
Copy Markdown
Member Author

@Insti Good ideas all; I've incorporated all of them.

Comment thread exercises/proverb/canonical-data.json Outdated
"cases": [
{
"description": "zero pieces",
"expected": [
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was considering to ask that this should have zero elements, but given that this is converted to a string by joining all elements with newlines, then [""] and [] are both representations of the empty string, so do whatever you want.

Comment thread exercises/proverb/canonical-data.json Outdated
"property": "recite"
}
],
"description": "Construct a proverb of the form 'for want of an X, the Y was lost'"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if someone will miss this at the crucial time because it's on the bottom. But I don't think it's necessary at all. I would remove it and remove one level of cases nesting.

Copy link
Copy Markdown
Member

@rpottsoh rpottsoh Nov 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description doesn't say that the lines of the proverb could vary, only the "input".

- Remove empty string from output
- Un-nest cases
- Move inner cases description to problemset comment
- Amplify inner cases description
- Re-order case fields for more sensible reading
"For want of a pin the gun was lost.",
"For want of a gun the soldier was lost.",
"For want of a soldier the battle was lost.",
"And all for the want of a pin."
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it to be presumed that the proverb is not set in stone? The description only refers to a single proverb and makes not mention that the "input" provided might refer to a different proverb. I don't think "four pieces modernized" should be included unless the description is also updated.

Copy link
Copy Markdown
Member

@rpottsoh rpottsoh Nov 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coriolinus my apologies! I didn't read closely enough. You are passing the expected proverb.

ugh, I just need to slow down. My original concern still stands. With the "input" provided how are we to know that it is for a different proverb when only one proverb is described in the description.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rpottsoh I did update the description for that: "your solution should be able to handle lists of arbitrary length and content".

In short, the idea is to ensure that students won't just hard-code the entire poem as a list, and then return its last N items, where N is the length of the input list. The goal of the exercise is to ensure that they can manipulate strings.

This also helps distinguish this exercise from others; discussion here was in favor of keeping the input list.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @coriolinus for clearing this up for me. I have not worked this exercise yet so some of the what was getting past me. Thanks for taking the time to produce the canonical data for this exercise.

Comment thread exercises/proverb/canonical-data.json Outdated
"lines together with line breaks. ",
"All cases expect the student to construct a proverb of the form ",
"'For want of an X, the Y was lost.', terminating with the stock phrase ",
"'And all for the want of a Z.'"
Copy link
Copy Markdown
Contributor

@wolf99 wolf99 Nov 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like Z is a special case for one of the inputs - could be worth specifically calling that out in the description.md

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No? I don't understand your comment; all inputs of non-zero length terminate with that stock phrase.

Copy link
Copy Markdown
Contributor

@wolf99 wolf99 Nov 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description.md doesn't specifically draw any explicit connection between the last line and the first input. This especially is confusing if you are aware of the proverb IRL, where the inputs are always the same and the last line is always "And all for the want of a nail".

Going solely by the description, it seems like Z should always be "nail" but that is not the case. Yes, the data implicitly makes this a requirement in a single case - but surely the data should be informed by the requirement (i.e. the description) rather than it introducing a requirement by itself?

What I mean to say is that by the description it is obvious that the inputs affect X and Y, but it is not obvious that they affect Z; Z is really X[0] so to speak.

I should have added this note against the description.md rather than this line I realise 😅

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now what you mean, though I'm not sure that I agree: the obvious terminating phrase, to me, would always be f"And all for the want of a {input[0]}.". Still, I don't mind adding a bit of text to the description to make that more clear.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description.md specifies the problem so I think you can just remove these 3 lines (8-10) from the config.json.

Copy link
Copy Markdown
Member

@rpottsoh rpottsoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @coriolinus!

@coriolinus coriolinus merged commit b15c45a into master Nov 5, 2017
@coriolinus coriolinus deleted the add-proverb-canonical-data branch November 5, 2017 17:12
@Insti
Copy link
Copy Markdown
Contributor

Insti commented Nov 5, 2017

Thanks @coriolinus ❤️

petertseng added a commit to exercism/rust that referenced this pull request Nov 18, 2018
Actually, the canonical data was born from the Rust implementation.
exercism/problem-specifications#994

1.1.0 moves inputs to the `input` object.
exercism/problem-specifications#1157

The Rust track has all the canonical tests, although in a different
order. Reviewers should indicate whether an ordering change in the Rust
tests is desired.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants