Inside of a skill handler, I find myself wanting to use a little tuple-index trick as a ternary operator as a ternary operator trick, to be a “plurality” detector/handler. E.g.,
self.speak(str(inquiry.total) + " issue" + (‘’, ‘s’)[inquiry.total > 1] + " remain unresolved.")
thissue = self.jira.issue(inquiry[0].key, fields=‘summary,comment’)
self.speak("Highest priority unresolved issue is regarding: " + thissue.fields.summary)
This way, if there is only 1 result, no ‘s’ follows, but if more than one, the ‘s’ is inserted (I extracted example this out of an if-then block that handles zero-results case, but you could imagine an extension to this tuple expression that would handle zero as well).
But as far as I can tell, this will prevent me from using dialog files. Is there some built-in mechanism in the dialog file tokens that would give me a similar capability? Or another special function that would somehow provide “auto-pluralization”? Or is there a different approach that somegives me the best of both worlds?