Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
"contraction <text> will":
R(Text("%(text)s'll ")),
"cap contraction <text> will":
R(Function(lambda text:Text(text.capitalize() + "'ll ").execute())),
"contraction <text> have":
R(Text("%(text)s've ")),
"cap contraction <text> have":
R(Function(lambda text:Text(text.capitalize() + "'ve ").execute())),
"contraction <text> are":
R(Text("%(text)s're ")),
"cap contraction <text> are":
R(Function(lambda text:Text(text.capitalize() + "'re ").execute())),
"contraction <text> is":
R(Text("%(text)s's ")),
"cap contraction <text> is":
R(Function(lambda text:Text(text.capitalize() + "'s ").execute())),
"contraction <text> not":
R(Text("%(text)s't ")),
"cap contraction <text> not":
R(Function(lambda text:Text(text.capitalize() + "'t ").execute())),
"contraction <text> (do|would)":
R(Text("%(text)s'd ")),
"cap contraction <text> (do|would)":
R(Function(lambda text:Text(text.capitalize() + "'d ").execute())),
@mpourmpoulis

This comment has been minimized.

Copy link

@mpourmpoulis mpourmpoulis commented Jun 28, 2020

Thanks for sharing, Just a small suggestion,in order to avoid having many specs, you could try to have a Choice element, say "continuation" or what ever you want to name it that would be like

Choice("continuation", {
    "(do|would)":"'d",
    "not":"'nt",
...
}

And you could do like

"contraction <text> <continuation>":R(Text("%(text)s%(continuation)"))
@tieTYT

This comment has been minimized.

Copy link
Owner Author

@tieTYT tieTYT commented Jun 28, 2020

That's cool, I didn't know I could do that.

"contraction <text> <continuation>":R(Text("%(text)s%(continuation)"))

Should this have an s before the end quote?

@mpourmpoulis

This comment has been minimized.

Copy link

@mpourmpoulis mpourmpoulis commented Jun 29, 2020

Yes it does! sr for typo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.