Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --normalize flag for Java #1155

Closed
wants to merge 7 commits into from
Closed

Conversation

brodmo
Copy link
Contributor

@brodmo brodmo commented Jun 21, 2023

Adresses #1028. I'm not too happy with the way language-specific options work right now but I guess that's a topic for another day.

@tsaglam tsaglam added enhancement Issue/PR that involves features, improvements and other changes minor Minor issue/feature/contribution/change labels Jun 22, 2023
@TwoOfTwelve
Copy link
Contributor

TwoOfTwelve commented Jun 22, 2023

The way you documented the normalization flag indicates it is a global option. If your intent is a global option, that can be applied to all languages I would suggest adding it as a global option and just passing the value to the language for parsing.

If the intent is a language specific option, that is available for all languages you could also add it to the global LanguageOptions class.

Otherwise I could easily add a mechanism for shared options.

Language specific options should only affect a single language module and should not be refereed to from the core module.

@TwoOfTwelve
Copy link
Contributor

I implemented an alternative way to add the flag. The branch is named normalize-flag-suggestion.

@brodmo
Copy link
Contributor Author

brodmo commented Jun 22, 2023

Thanks, where can I view it? Your JPlag fork isn't public

@TwoOfTwelve
Copy link
Contributor

I committed it to your fork

@brodmo
Copy link
Contributor Author

brodmo commented Jun 22, 2023

You can do that? I can't find it

@TwoOfTwelve
Copy link
Contributor

Sorry, I don't like forks very much, so I rarely use them. I forked your fork and pushed my branch here: https://github.com/TwoOfTwelve/JPlagMbrdl/tree/normalize-flag-suggestion

@brodmo
Copy link
Contributor Author

brodmo commented Jun 22, 2023

Looks good, thanks 👍

@brodmo
Copy link
Contributor Author

brodmo commented Jun 22, 2023

But maybe normalization shouldn't be a language-specific option at all, since in principle any language can support it. Maybe it should just be a global option with a disclaimer. idk

@tsaglam tsaglam requested a review from a team June 26, 2023 13:12
@@ -125,6 +125,9 @@ Advanced
-x, --exclusion-file=<exclusionFileName>
All files named in this file will be ignored in the
comparison (line-separated list)

--normalize (Java only) Enable token string normalization,
which can help detect certain cases of plagiarism.
Copy link
Contributor

Choose a reason for hiding this comment

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

This documentation does not fit the implementation. This implies, that --normalize is a global argument, but it is implemented as language specific.

@@ -67,6 +67,9 @@ Advanced
-x, --exclusion-file=<exclusionFileName>
All files named in this file will be ignored in the
comparison (line-separated list)

--normalize (Java only) Enable token string normalization,
which can help detect certain cases of plagiarism.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above


public class JavaLanguageOptions extends LanguageOptions {
public JavaLanguageOptions() {
super(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

This solution is fine, if we choose to implement --normalize as a language specific option.

@tsaglam tsaglam added the language PR / Issue deals (partly) with new and/or existing languages for JPlag label Jul 5, 2023
@tsaglam
Copy link
Member

tsaglam commented Jul 5, 2023

@mbrdl we still have some open requests here.

@@ -0,0 +1,38 @@
package de.jplag.options;

class DummyOption<T> implements LanguageOption<T> {
Copy link
Member

Choose a reason for hiding this comment

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

Javadoc to explain the purpose.

this.options = new ArrayList<>();
if (supportsNormalization) {
var description = "Enable token string normalization, which can help detect certain cases of plagiarism.";
Copy link
Member

Choose a reason for hiding this comment

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

Avoid var, especially when String is nearly just as short.

@brodmo
Copy link
Contributor Author

brodmo commented Jul 6, 2023

Putting this off for now due to unresolved design decisions and lack of urgency

@brodmo
Copy link
Contributor Author

brodmo commented Jul 15, 2023

todo: add cli tests for the flag

# Conflicts:
#	languages/java/src/main/java/de/jplag/java/JavaLanguage.java
@sonarcloud
Copy link

sonarcloud bot commented Jul 15, 2023

[JPlag Plagiarism Detector] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 4 Code Smells

80.0% 80.0% Coverage
0.0% 0.0% Duplication

Copy link
Member

@dfuchss dfuchss left a comment

Choose a reason for hiding this comment

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

Minor comment

Comment on lines +29 to +31
/**
* New instance
*/
Copy link
Member

Choose a reason for hiding this comment

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

Document default option

@dfuchss
Copy link
Member

dfuchss commented Sep 13, 2023

@mbrdl this branch has some merge conflicts; could you resolve them :)

@brodmo
Copy link
Contributor Author

brodmo commented Sep 13, 2023

This PR is on ice for now, we'll probably implement the option globally instead

@brodmo brodmo closed this Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issue/PR that involves features, improvements and other changes language PR / Issue deals (partly) with new and/or existing languages for JPlag minor Minor issue/feature/contribution/change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants