Skip to content

fix(locale): weight common chinese surnames more frequently #3467

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

Open
wants to merge 3 commits into
base: next
Choose a base branch
from

Conversation

matthewmayer
Copy link
Contributor

POC to fix #3466

Weights 20 common Chinese surnames to appear 80% of the time

@matthewmayer matthewmayer requested a review from a team as a code owner April 6, 2025 11:27
Copy link

netlify bot commented Apr 6, 2025

Deploy Preview for fakerjs ready!

Name Link
🔨 Latest commit fb45c17
🔍 Latest deploy log https://app.netlify.com/sites/fakerjs/deploys/67f94f2ec09c430008cd9494
😎 Deploy Preview https://deploy-preview-3467.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Apr 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.97%. Comparing base (b2c5298) to head (fb45c17).

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #3467      +/-   ##
==========================================
- Coverage   99.97%   99.97%   -0.01%     
==========================================
  Files        2830     2830              
  Lines      218533   218538       +5     
  Branches      951      951              
==========================================
+ Hits       218480   218483       +3     
- Misses         53       55       +2     
Files with missing lines Coverage Δ
src/locales/zh_CN/person/last_name.ts 100.00% <100.00%> (ø)
src/locales/zh_CN/person/last_name_pattern.ts 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 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.

@xDivisionByZerox xDivisionByZerox added c: bug Something isn't working p: 1-normal Nothing urgent c: locale Permutes locale definitions m: person Something is referring to the person module labels Apr 11, 2025
@xDivisionByZerox xDivisionByZerox added this to the vAnytime milestone Apr 11, 2025
@@ -1,4 +1,26 @@
export default {
generic_common: [
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about this extra key as it is not included in the module definitions type contract. I'd be in favor to allow (not enforce!) weighted lists in the name schemas in general. I could see this being introduced as a workaround at most for now.

@yyz945947732
Copy link
Contributor

yyz945947732 commented Apr 14, 2025

zh_TW (Taiwan) also only includes a subset of common surnames, and it works quite well. so I think zh_CN could do the same — weighting may not be necessary (consider generic_common is not a module type). just removing the rare surnames and keeping the common ones might be enough.

If you're aligned with this idea, I'm happy to submit a PR for the change (pick surnames), which would only change the locals.

@matthewmayer
Copy link
Contributor Author

I'm not 100% sure this is the best approach (versus just using common surnames) though I'd say the fact that generic_common is not in the module definition is not enough to disqualify it as an approach, there are plenty of other edge cases in the locales which use non-standard keys.

For example company.legal_entity_type and company.category used in various definitions and locales.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: bug Something isn't working c: locale Permutes locale definitions m: person Something is referring to the person module p: 1-normal Nothing urgent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

using "common last_name" when generate chinese name
4 participants