Skip to content

Added functionallity to handle marking of capital letters in the same way as hyphenation.#1

Closed
kalaspuffar wants to merge 9 commits intomainfrom
mark_capital_letters
Closed

Added functionallity to handle marking of capital letters in the same way as hyphenation.#1
kalaspuffar wants to merge 9 commits intomainfrom
mark_capital_letters

Conversation

@kalaspuffar
Copy link
Copy Markdown
Collaborator

@kalaspuffar kalaspuffar commented Feb 26, 2021

Hi @bertfrees and @PaulRambags

After reviewing the code for how the hyphenation code is implemented, I realized that it was done with an attribute, and I see no reason why capital letter marks could not be handled the same way.

This pull request adds the functionality of a new attribute for text processing. mark-capital-letters could be used to inform the formatter if the text should have capital letter marks.

From OBFL Specification mtmse/obfl#28

Please review and comment.

Best regards
Daniel

Copy link
Copy Markdown
Contributor

@PaulRambags PaulRambags left a comment

Choose a reason for hiding this comment

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

I couldn't find a description of this functionality in the OBFL specification. Did I overlook it?
If not, please add a description of this marking of capital letters in the OBFL specification.

private final String translationMode;
private final boolean hyphenate;

private final boolean markCapitalLetters;
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.

You're using spaces instead of a TAB.
I won't mention this further

* Returns true if the mark capital letters property is true, false otherwise
* @return returns true if the mark capital letters property is true
*/
public boolean shouldMarkCapitalLetters() {
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.

I'd expect a name like "isMarkingCapitalLetters", as in the FormatterConfiguration.
Please don't use "should" because that is too vague.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hi @PaulRambags

When it comes to the naming of this function, I use the most reasonable verb. If you want another example of this use, you have it with the hyphenate function:

boolean h = specification.getTextToTranslate().get(0).shouldHyphenate();

In the specific case, the boolean doesn't tell you if the current object is a mark capital letter. "is" as a keyword is really great for telling about a state of an object. But in this case, it tells us if we should run a specific piece of code.

The style guide of Oracle only tells you to use a relevant verb for your function names:
https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html

This can be a part that we could debate what verbs are allowed in this codebase, and then I will change it. But in that change, I will go through and change all other usages of the same keywords, so we get a cohesive use.

Best regards
Daniel

final int prime = 31;
int result = 1;
result = prime * result + (hyphenate ? 1231 : 1237);
result = prime * result + (markCapitalLetters ? 1241 : 1247);
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.

1241 -> 1231; 1247 -> 1237
That is how it is done elsewhere
Besides, 1241 and 1247 are not prime numbers

@kalaspuffar
Copy link
Copy Markdown
Collaborator Author

Hi @PaulRambags

I've added the OBFL PR to the description. Still under discussion. I just moved the PR to the new repository.

Best regards
Daniel

@kalaspuffar kalaspuffar force-pushed the mark_capital_letters branch from 8d62c84 to 5975c26 Compare March 2, 2021 08:36
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.

2 participants