Skip to content

Update import/export handling of Vernacular#3626

Merged
imnasnainaec merged 16 commits intomasterfrom
citation
Mar 11, 2025
Merged

Update import/export handling of Vernacular#3626
imnasnainaec merged 16 commits intomasterfrom
citation

Conversation

@imnasnainaec
Copy link
Collaborator

@imnasnainaec imnasnainaec commented Feb 27, 2025

Fixes #3532

  • Track if citation form instead of lexical form was used for Vernacular (and export to citation form if imported with citation form and Vernacular is unchanged)
  • When a LIFT file is selected in project settings for import into an existing project, compare the LIFT's ldml languages against the projects vernacular language (and require user confirmation if the languages don't match)
  • Only import words that have a citation or lexical form in the same language as the projects vernacular language (and toast the number of words imported)

This change is Reviewable

@imnasnainaec imnasnainaec self-assigned this Feb 27, 2025
@imnasnainaec imnasnainaec changed the title Citation Track if imported word uses CitationForm for its Vernacular Feb 27, 2025
@codecov
Copy link

codecov bot commented Feb 27, 2025

Codecov Report

Attention: Patch coverage is 67.39130% with 15 lines in your changes missing coverage. Please review.

Project coverage is 74.24%. Comparing base (ea4537e) to head (ea49d7b).
Report is 29 commits behind head on master.

Files with missing lines Patch % Lines
src/components/ProjectSettings/ProjectImport.tsx 38.88% 9 Missing and 2 partials ⚠️
src/components/Dialogs/CancelConfirmDialog.tsx 25.00% 3 Missing ⚠️
Backend/Services/MergeService.cs 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3626      +/-   ##
==========================================
- Coverage   74.27%   74.24%   -0.03%     
==========================================
  Files         285      285              
  Lines       11116    11143      +27     
  Branches     1370     1373       +3     
==========================================
+ Hits         8256     8273      +17     
- Misses       2467     2476       +9     
- Partials      393      394       +1     
Flag Coverage Δ
backend 83.97% <95.83%> (+0.08%) ⬆️
frontend 65.78% <36.36%> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@imnasnainaec imnasnainaec marked this pull request as ready for review March 3, 2025 21:33
@jasonleenaylor
Copy link
Contributor

Backend/Services/LiftService.cs line 775 at r1 (raw file):

                if (string.IsNullOrWhiteSpace(vern))
                {
                    vern = entry.CitationForm.FirstOrDefault(x => !string.IsNullOrWhiteSpace(x.Value.Text)).Value?.Text;

What if we didn't do this?

var hashCode = new Word { Guid = _commonGuid, Vernacular = "1" }.GetHashCode();
Assert.That(hashCode, Is.Not.EqualTo(new Word { Guid = _commonGuid, Vernacular = "2" }.GetHashCode()));
Assert.That(hashCode, Is.Not.EqualTo(
new Word { Guid = _commonGuid, Vernacular = "1", UsingCitationForm = true }.GetHashCode()));
Copy link
Contributor

Choose a reason for hiding this comment

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

you've got a bug in your test. UsingCitationForm is not referenced in GetHashCode for Word, which is a bug. But the real issue is that this test didn't catch that. Here's a failing test that should pass which demonstrates the issue

var word1 = new Word { Guid = _commonGuid, Vernacular = "1" };
var word2 = new Word { Guid = _commonGuid, Vernacular = "1" };
var word1HashCode = word1.GetHashCode();
var word2HashCode = word2.GetHashCode();
Assert.That(word1HashCode, Is.EqualTo(word2HashCode));

the hash codes aren't the same even though they should be. I think this is because the HashCode class just calls GetHashCode on the objects passed in, and most objects (List<T> for example) don't overload GetHashCode, which means that the hash code is unique per instance of the list, not based on it's contents. Eg: new List<string>().GetHashCode() != new List<string>().GetHashCode() this is expected and by design as a hash code is expected to not change for a given object over it's lifetime, otherwise it wouldn't work as a key in a dictionary for example. I could go more into this but I'll stop before I write an essay.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@imnasnainaec imnasnainaec marked this pull request as draft March 4, 2025 19:15
@imnasnainaec imnasnainaec marked this pull request as ready for review March 6, 2025 22:34
@imnasnainaec imnasnainaec requested a review from hahn-kev March 6, 2025 22:34
@imnasnainaec imnasnainaec changed the title Track if imported word uses CitationForm for its Vernacular Update import/export handling of Vernacular Mar 7, 2025
Copy link
Contributor

@jasonleenaylor jasonleenaylor left a comment

Choose a reason for hiding this comment

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

Reviewed 8 of 8 files at r1, 7 of 7 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @hahn-kev)

Copy link
Collaborator Author

@imnasnainaec imnasnainaec left a comment

Choose a reason for hiding this comment

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

Dismissed @hahn-kev from a discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @imnasnainaec)

@imnasnainaec imnasnainaec enabled auto-merge (squash) March 11, 2025 12:01
@imnasnainaec imnasnainaec merged commit 7d92ffb into master Mar 11, 2025
18 checks passed
@imnasnainaec imnasnainaec deleted the citation branch March 11, 2025 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FLEx] Citation form overwritten by lexeme form in round-trip

3 participants