Skip to content

Commit

Permalink
feature: Add japanese people names (#269)
Browse files Browse the repository at this point in the history
* chore: Ignore .cache/ directory

The clangd index stores information about the whole codebase in .cache files.
It’s used to provide LSP features where the AST of the current file doesn’t
have the information we need.

* feature: Added japanese people names
  • Loading branch information
braw-lee authored Nov 17, 2023
1 parent 182196f commit cdeea6f
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ CMakeSettings.json
out/
build-linux-gxx
build-linux-clang
#clangd index files
.cache/
17 changes: 10 additions & 7 deletions include/faker-cxx/types/Country.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ enum class Country
Denmark,
Sweden,
Brazil,
Norway
Norway,
Japan,
};

const std::vector<Country> countries{Country::Usa, Country::England, Country::Poland, Country::Italy,
Country::France, Country::Germany, Country::Russia, Country::Romania,
Country::India, Country::Finland, Country::Nepal, Country::Spain,
Country::Turkey, Country::Czech, Country::Slovakia, Country::Ukraine,
Country::Denmark, Country::Sweden, Country::Brazil, Country::Norway};
const std::vector<Country> countries{
Country::Usa, Country::England, Country::Poland, Country::Italy, Country::France, Country::Germany,
Country::Russia, Country::Romania, Country::India, Country::Finland, Country::Nepal, Country::Spain,
Country::Turkey, Country::Czech, Country::Slovakia, Country::Ukraine, Country::Denmark, Country::Sweden,
Country::Brazil, Country::Norway, Country::Japan,
};

inline std::string toString(Country country)
{
Expand All @@ -45,7 +47,8 @@ inline std::string toString(Country country)
{Country::Finland, "Finland"}, {Country::Nepal, "Nepal"}, {Country::Spain, "Spain"},
{Country::Turkey, "Turkey"}, {Country::Czech, "Czech"}, {Country::Slovakia, "Slovakia"},
{Country::Ukraine, "Ukraine"}, {Country::Denmark, "Denmark"}, {Country::Sweden, "Sweden"},
{Country::Brazil, "Brazil"}, {Country::Norway, "Norway"}};
{Country::Brazil, "Brazil"}, {Country::Norway, "Norway"}, {Country::Japan, "Japan"},
};

return countryToStringMapping.at(country);
}
Expand Down
5 changes: 4 additions & 1 deletion src/modules/person/Person.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "data/Hobbies.h"
#include "data/india/IndianPeopleNames.h"
#include "data/italy/ItalianPeopleNames.h"
#include "data/japan/JapanesePeopleNames.h"
#include "data/JobTitles.h"
#include "data/Languages.h"
#include "data/Nationalities.h"
Expand Down Expand Up @@ -50,7 +51,9 @@ const std::map<Country, PeopleNames> countryToPeopleNamesMapping{
{Country::Czech, czechPeopleNames}, {Country::Slovakia, slovakPeopleNames},
{Country::Ukraine, ukrainianPeopleNames}, {Country::Denmark, danishPeopleNames},
{Country::Sweden, swedishPeopleNames}, {Country::Usa, usaPeopleNames},
{Country::Brazil, brazilianPeopleNames}, {Country::Norway, norwegianPeopleNames}};
{Country::Brazil, brazilianPeopleNames}, {Country::Norway, norwegianPeopleNames},
{Country::Japan, japanesePeopleNames},
};

std::string middleNameForCountry(Country country, std::optional<Sex> sex);
std::string prefixForCountry(Country country, std::optional<Sex> sex);
Expand Down
9 changes: 7 additions & 2 deletions src/modules/person/PersonTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "data/Hobbies.h"
#include "data/india/IndianPeopleNames.h"
#include "data/italy/ItalianPeopleNames.h"
#include "data/japan/JapanesePeopleNames.h"
#include "data/JobTitles.h"
#include "data/Languages.h"
#include "data/Nationalities.h"
Expand Down Expand Up @@ -50,7 +51,9 @@ const std::map<Country, PeopleNames> countryToPeopleNamesMapping{
{Country::Czech, czechPeopleNames}, {Country::Slovakia, slovakPeopleNames},
{Country::Ukraine, ukrainianPeopleNames}, {Country::Denmark, danishPeopleNames},
{Country::Sweden, swedishPeopleNames}, {Country::Usa, usaPeopleNames},
{Country::Brazil, brazilianPeopleNames}, {Country::Norway, norwegianPeopleNames}};
{Country::Brazil, brazilianPeopleNames}, {Country::Norway, norwegianPeopleNames},
{Country::Japan, japanesePeopleNames},
};

const std::map<Country, std::string> generatedTestName{
{Country::England, "shouldGenerateEnglishName"}, {Country::France, "shouldGenerateFrenchName"},
Expand All @@ -62,7 +65,9 @@ const std::map<Country, std::string> generatedTestName{
{Country::Czech, "shouldGenerateCzechName"}, {Country::Slovakia, "shouldGenerateSlovakName"},
{Country::Ukraine, "shouldGenerateUkrainianName"}, {Country::Denmark, "shouldGenerateDanishName"},
{Country::Sweden, "shouldGenerateSwedishName"}, {Country::Usa, "shouldGenerateAmericanName"},
{Country::Brazil, "shouldGenerateBrazilianName"}, {Country::Norway, "shouldGenerateNorwegianName"}};
{Country::Brazil, "shouldGenerateBrazilianName"}, {Country::Norway, "shouldGenerateNorwegianName"},
{Country::Japan, "shouldGenerateJapaneseName"},
};
}

class PersonTest : public TestWithParam<Country>
Expand Down
35 changes: 35 additions & 0 deletions src/modules/person/data/japan/JapaneseFirstNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> japaneseMaleFirstNames{
"正一", "正二", "正三", "", "辰雄", "三郎", "昭二", "昭三", "", "", "", "", "", "",
"", "", "", "", "健一", "大輔", "達也", "翔太", "拓也", "健太", "大輝", "", "駿", "",
"大翔", "", "悠真", "", "", "", "", "和夫", "", "浩一", "哲也", "", "大介", "海斗",
"拓海", "颯太", "悠斗", "陽翔", "", "", "", "正雄", "勝利", "", "和彦", "", "直樹", "健太郎",
"大和", "陽向", "瑛太", "陽太", "", "一郎", "", "", "浩二", "", "大樹", "", "義雄", "昭一",
"", "", "", "和也", "大地", "", "悠人", "朝陽", "", "武雄", "英樹", "秀樹", "祐介", "雄太",
"翔平", "大貴", "太陽", "", "陽斗", "颯真", "蒼空", "優斗", "正治", "", "竜也", "", "貴大", "直人",
"", "優太", "悠太", "陸斗", "太一", "", "浩之", "", "博之", "亮太", "一輝", "", "陽大", "正夫",
"秀雄", "幸雄", "", "", "洋平", "拓哉", "涼太", "大雅", "海翔", "龍生", "結翔", "悠翔", "", "正男",
"辰男", "一男", "", "雄大", "康平", "智也", "", "悠希", "歩夢",
};
const std::vector<std::string> japaneseFemaleFirstNames{
"千代子", "静子", "文子", "キヨ", "千代", "ハル", "キミ", "久子", "ヨシ", "清子", "正子", "貞子",
"八重子", "きよ", "フミ", "ハナ", "和子", "愛子", "きみ", "トミ", "はる", "マサ", "美代子", "光子",
"幸子", "照子", "芳子", "節子", "昭子", "信子", "敏子", "典子", "君子", "弘子", "洋子", "美智子",
"京子", "悦子", "栄子", "孝子", "良子", "恵子", "勝子", "紀子", "恵美子", "啓子", "久美子", "由美子",
"裕子", "順子", "智子", "明美", "", "", "麻衣", "麻美", "香織", "美穂", "", "沙織",
"愛美", "絵美", "", "恵美", "陽子", "成美", "あゆみ", "美香", "理恵", "友美", "智美", "明日香",
"由佳", "", "麻衣子", "彩香", "真由美", "純子", "直美", "優子", "裕美", "由美", "直子", "めぐみ",
"美紀", "浩子", "ゆかり", "さくら", "美咲", "陽菜", "", "七海", "美羽", "結衣", "美月", "",
"美優", "未来", "優奈", "", "優花", "美桜", "莉子", "菜月", "結愛", "結菜", "花音", "心優",
"真央", "玲奈", "ひなた", "彩乃", "彩花", "優衣", "琴音", "百花", "", "里奈", "", "千尋",
"", "亜美", "佳奈", "真由", "桃子", "菜々子", "千夏", "菜摘", "奈々", "早紀", "", "陽葵",
"芽依", "結月", "咲良", "", "", "心愛", "", "心春", "愛莉", "愛菜", "", "心結",
"美結",
};
}
12 changes: 12 additions & 0 deletions src/modules/person/data/japan/JapaneseLastNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> japaneseLastNames{
"佐藤", "鈴木", "高橋", "田中", "渡辺", "伊藤", "山本", "中村", "小林", "加藤",
"吉田", "山田", "佐々木", "山口", "斎藤", "松本", "井上", "木村", "", "清水",
};
}
14 changes: 14 additions & 0 deletions src/modules/person/data/japan/JapanesePeopleNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include "../NameFormats.h"
#include "../PeopleNames.h"
#include "JapaneseFirstNames.h"
#include "JapaneseLastNames.h"

namespace faker
{
const NameFormats japanesePeopleNameFormats{{"{lastName} {firstName}", 1}};
const PeopleNames japanesePeopleNames{{japaneseMaleFirstNames, {}, japaneseLastNames, {}, {}},
{japaneseFemaleFirstNames, {}, japaneseLastNames, {}, {}},
japanesePeopleNameFormats};
}

0 comments on commit cdeea6f

Please sign in to comment.