本文整理匯總了Java中com.github.irobson.jgenderize.model.NameGender類的典型用法代碼示例。如果您正苦於以下問題:Java NameGender類的具體用法?Java NameGender怎麽用?Java NameGender使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NameGender類屬於com.github.irobson.jgenderize.model包,在下文中一共展示了NameGender類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getGenders
import com.github.irobson.jgenderize.model.NameGender; //導入依賴的package包/類
public List<NameGender> getGenders(String[] names, Locale locale) {
if (names.length == 0) {
return Collections.emptyList();
}
WebTarget target = client.target(GENDERIZE_IO_API_URL);
for (int i = 0; i < names.length; i++) {
target = target.queryParam(String.format("name[%d]", i), names[i]);
}
if (locale != null) {
target = target.queryParam("country_id", locale.getCountry());
target = target.queryParam("language_id", locale.getLanguage());
}
if (apiKey != null) {
target = target.queryParam("apikey", apiKey);
}
Invocation.Builder builder = target.request(MediaType.APPLICATION_JSON_TYPE);
return builder.get(NAME_GENDER_LIST_TYPE);
}
示例2: testGetMultiNameGenderByLocalization
import com.github.irobson.jgenderize.model.NameGender; //導入依賴的package包/類
@Test
public void testGetMultiNameGenderByLocalization() {
Genderize api = GenderizeIoAPI.create();
List<NameGender> genders = api.getGenders(new String[]{"Robson", "Gilmar", "Marlise"}, new Locale("pt", "BR"));
Assert.assertEquals(3, genders.size());
Assert.assertTrue(genders.get(0).isMale());
Assert.assertTrue(genders.get(1).isMale());
Assert.assertTrue(genders.get(2).isFemale());
}
示例3: testGetMultiNameGender
import com.github.irobson.jgenderize.model.NameGender; //導入依賴的package包/類
@Test
public void testGetMultiNameGender() {
Genderize api = GenderizeIoAPI.create();
List<NameGender> genders = api.getGenders("Robson", "John", "Anna");
Assert.assertEquals(3, genders.size());
Assert.assertTrue(genders.get(0).isMale());
Assert.assertTrue(genders.get(1).isMale());
Assert.assertTrue(genders.get(2).isFemale());
}
示例4: getGender
import com.github.irobson.jgenderize.model.NameGender; //導入依賴的package包/類
public NameGender getGender(String name, Locale locale) {
return getGenders(new String[]{name}, locale).get(0);
}
示例5: testNullGender
import com.github.irobson.jgenderize.model.NameGender; //導入依賴的package包/類
@Test
public void testNullGender() {
NameGender name = new NameGender();
name.setGender("null");
Assert.assertEquals(Gender.NULL, name.getGenderType());
}
示例6: testFemaleGender
import com.github.irobson.jgenderize.model.NameGender; //導入依賴的package包/類
@Test
public void testFemaleGender() {
NameGender name = new NameGender();
name.setGender("female");
Assert.assertEquals(Gender.FEMALE, name.getGenderType());
}
示例7: testMaleGender
import com.github.irobson.jgenderize.model.NameGender; //導入依賴的package包/類
@Test
public void testMaleGender() {
NameGender name = new NameGender();
name.setGender("male");
Assert.assertEquals(Gender.MALE, name.getGenderType());
}
示例8: testGetSingleNameGender
import com.github.irobson.jgenderize.model.NameGender; //導入依賴的package包/類
@Test
public void testGetSingleNameGender() {
Genderize api = GenderizeIoAPI.create();
NameGender gender = api.getGender("Kim");
Assert.assertTrue(gender.isFemale());
}
示例9: testGetSingleNameGenderByLocalization
import com.github.irobson.jgenderize.model.NameGender; //導入依賴的package包/類
@Test
public void testGetSingleNameGenderByLocalization() {
Genderize api = GenderizeIoAPI.create();
NameGender gender = api.getGender("Kim", new Locale("da", "DK"));
Assert.assertTrue(gender.isMale());
}
示例10: testGetNoNames
import com.github.irobson.jgenderize.model.NameGender; //導入依賴的package包/類
@Test
public void testGetNoNames() {
List<NameGender> genders = GenderizeIoAPI.create().getGenders();
Assert.assertEquals(0, genders.size());
}
示例11: testGetSingleNameGenderWithMultiMethod
import com.github.irobson.jgenderize.model.NameGender; //導入依賴的package包/類
@Test
public void testGetSingleNameGenderWithMultiMethod() {
List<NameGender> genders = GenderizeIoAPI.create().getGenders("Robson");
Assert.assertEquals(1, genders.size());
Assert.assertTrue(genders.get(0).isMale());
}
示例12: testGetSingleNameUnknownGender
import com.github.irobson.jgenderize.model.NameGender; //導入依賴的package包/類
@Test
public void testGetSingleNameUnknownGender() {
NameGender gender = GenderizeIoAPI.create().getGender("Thunderhorse");
Assert.assertFalse(gender.isFemale());
Assert.assertFalse(gender.isMale());
}
示例13: getCharacters
import com.github.irobson.jgenderize.model.NameGender; //導入依賴的package包/類
/**
* Get the characters.
*
* @return an ArrayList of characters
*/
public ArrayList<Person> getCharacters() {
ArrayList<Person> people = new ArrayList<Person>();
Genderize api = GenderizeIoAPI.create();
AbstractSequenceClassifier<CoreLabel> classifier;
String fileContents;
List<Triple<String, Integer, Integer>> list;
HashSet<String> existingNames;
try {
classifier = CRFClassifier.getClassifier(CLASSIFIER);
fileContents = IOUtils.slurpFile(filename);
list = classifier.classifyToCharacterOffsets(fileContents);
existingNames = new HashSet<String>();
for (Triple<String, Integer, Integer> item : list) {
if (item.first().equals("PERSON")) {
String nameStr = fileContents.substring(item.second(),
item.third());
nameStr = nameStr.replace("\n", " ")
.replace("\r", " ")
.replaceAll("\\s+", " ")
.trim();
if (!existingNames.contains(nameStr)) {
existingNames.add(nameStr);
String[] names = nameStr.split(" ");
Person p = new Person();
p.setFirstname(names[0]);
if (names.length > 1) {
p.setLastname(names[1]);
}
NameGender gender = api.getGender(p.getFirstname());
if (gender.getGender() != null) {
p.setGender(gender.isMale() ? male : female);
} else {
p.setGender(getRandomGender());
}
people.add(p);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return people;
}
示例14: getGender
import com.github.irobson.jgenderize.model.NameGender; //導入依賴的package包/類
NameGender getGender(String name);
示例15: getGenders
import com.github.irobson.jgenderize.model.NameGender; //導入依賴的package包/類
List<NameGender> getGenders(String... names);