Adding a handlebar to return pitch accent categories of a word #563
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There's a function hidden in the source code called pitchCategories, which returns the pitch accent categories of a word in string format. This pull request adds a new handlebar, called "pitch-accent-categories" which uses this function to return a comma delimited list of pitch accent categories for a word.
For instance, with my set of pitch accent dictionaries, running "pitch-accent-categories" on the word 「推量」returns "heiban,nakadaka", while running it on 「読め」returns "kifuku".
In order to make this work, I needed to fix a logic error in the function isNonNounVerbOrAdjective. As it was, the function would return an incorrect result if the word was both a suru verb and a noun (which is quite a lot of words!) For these words, it should return False, but it was actually returning True. To see the problem, note that in the final return statement, it contains the following expression:
!(isSuruVerb && isNoun)
. With the old logic, there is never a situation where this will evaluate False, it will always return True.