-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
fix for 9699. Added bimap for language-lcid mapping #9729
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good initial shot.
MSBibConverter.java also should be adapted.
Please add test for MsBibConverter using Ctrl+Shift+T
Press then Enter
Then create a test case with a BibEntry.
See IEEETest.java for a more complete example.
@@ -24,6 +24,45 @@ public class MSBibMapping { | |||
|
|||
private static final HashBiMap<Field, String> BIBLATEX_TO_MS_BIB = HashBiMap.create(); | |||
|
|||
private static final HashBiMap<String, Integer> LANG_TO_LCID = HashBiMap.create(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really need HashBiMap
here? Isn't BiMap enough?
See https://github.com/HugoMatilla/Effective-JAVA-Summary#52-refer-to-objects-by-their-interface for a longer explanation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesnt the same logic apply for BIBLATEX_TO_MS_BIB as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so.
@@ -131,8 +170,8 @@ public static MSBibEntryType getMSBibEntryType(EntryType bibtexType) { | |||
*/ | |||
public static int getLCID(String language) { | |||
// TODO: add language to LCID mapping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This TODO can be removed.
Also fix the checkstyle issue!
My bad about the unit tests. I'll take a look and make some fixes. Thanks for the quick feedback. |
In regards to the unit tests failing, Not quite sure what to do here. Additionally, since @Alexandra-Stath was assigned to this problem first, you do not need to review this PR until she submits a PR as well or says it is okay. I just do not want this to get merged, since she was technically assigned it first as a course project! |
Without thinking much, my question would be, why can't Are all these null pointer exceptions really because of this? |
I think the tests are failing because the xml files for the tests probably contain 0 for the language. And there is no map entry with 0 inside. So either add an entry for 0 or do something like getOrDefault |
@Siedlerchr I'm not sure if that's the case, because the previous implementation of getLCID() returned the hexidecimal value of 1033, which is the LCID for american english. |
This is good! Without thinking deeper about the consequences, just fallback to (And please adapt the wrong comment |
I added MSBibConverterTest but I am not sure if that is what you guys are expecting. (my last commit had some missing files, which is why the unit tests were failing :,( ) |
*/ | ||
public static int getLCID(String language) { | ||
if (!LANG_TO_LCID.containsKey(language)) { | ||
return 1033; | ||
} | ||
return LANG_TO_LCID.get(language); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use getOrDefault
Not sure why that one test is now suddenly failing, it works fine on my local machine... |
The test sometimes fails randomly on CI. Don't worry. If you think your PR is ready then you can mark it as ready for review. In my opinion it looks good now |
Add import as well
@@ -381,7 +381,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve | |||
- We moved the union/intersection view button in the group sidepane to the left of the other controls. [#8202](https://github.com/JabRef/jabref/pull/8202) | |||
- We improved the Drag and Drop behavior in the "Customize Entry Types" Dialog [#6338](https://github.com/JabRef/jabref/issues/6338) | |||
- When determining the URL of an ArXiV eprint, the URL now points to the version [#8149](https://github.com/JabRef/jabref/pull/8149) | |||
- We Included all standard fields with citation key when exporting to Old OpenOffice/LibreOffice Calc Format [#8176](https://github.com/JabRef/jabref/pull/8176) | |||
- We Included all standard fields with citation key when exporting to Old OpenOffice/LibreExpoa Calc Format [#8176](https://github.com/JabRef/jabref/pull/8176) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Siedlerchr What is "LibreExpoa"? Is this change in CHANGELOG.md really intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was editing this on the github, this was not intended
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it directly in main
at 461e915
Fixes #9699
Added a private static bimap for supporting more lcids/languages when exporting to MS Office 2007.
Added simple unit tests, but not sure if those are necessary.
Tasks