use of com.ibm.watson.personality_insights.v3.model.ProfileOptions in project java-sdk by watson-developer-cloud.
the class PersonalityInsightsIT method getProfileWithTextAsCSVNoHeaders.
/**
* Gets the profile with text as a CSV string without headers.
*
* @throws Exception the exception
*/
@Test
public void getProfileWithTextAsCSVNoHeaders() throws Exception {
File file = new File(RESOURCE + "en.txt");
String englishText = getStringFromInputStream(new FileInputStream(file));
ProfileOptions options = new ProfileOptions.Builder().text(englishText).build();
String profileString = service.getProfileAsCSV(options, false).execute();
Assert.assertNotNull(profileString);
Assert.assertTrue(profileString.split("\n").length == 1);
}
use of com.ibm.watson.personality_insights.v3.model.ProfileOptions in project java-sdk by watson-developer-cloud.
the class PersonalityInsightsIT method getProfileWithContentItems.
/**
* Gets the profile from a list of content items.
*
* @throws Exception the exception
*/
@Test
public void getProfileWithContentItems() throws Exception {
final Content content = loadFixture(RESOURCE + "v3-contentItems.json", Content.class);
ProfileOptions options = new ProfileOptions.Builder().content(content).consumptionPreferences(true).rawScores(true).build();
Profile profile = service.profile(options).execute();
assertProfile(profile);
}
use of com.ibm.watson.personality_insights.v3.model.ProfileOptions in project java-sdk by watson-developer-cloud.
the class PersonalityInsightsIT method testReadme.
/**
* Test example in Readme.
*/
@Test
public void testReadme() {
// PersonalityInsights service = new PersonalityInsights("2016-10-19");
// service.setUsernameAndPassword("<username>", "<password>");
// Demo content from Moby Dick by Hermann Melville (Chapter 1)
String text = "Call me Ishmael. Some years ago-never mind how long precisely-having " + "little or no money in my purse, and nothing particular to interest me on shore, " + "I thought I would sail about a little and see the watery part of the world. " + "It is a way I have of driving off the spleen and regulating the circulation. " + "Whenever I find myself growing grim about the mouth; whenever it is a damp, " + "drizzly November in my soul; whenever I find myself involuntarily pausing before " + "coffin warehouses, and bringing up the rear of every funeral I meet; and especially " + "whenever my hypos get such an upper hand of me, that it requires a strong moral " + "principle to prevent me from deliberately stepping into the street, and methodically " + "knocking people's hats off-then, I account it high time to get to sea as soon as I can. " + "This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself " + "upon his sword; I quietly take to the ship. There is nothing surprising in this. " + "If they but knew it, almost all men in their degree, some time or other, cherish " + "very nearly the same feelings towards the ocean with me. There now is your insular " + "city of the Manhattoes, belted round by wharves as Indian isles by coral reefs-commerce surrounds " + "it with her surf. Right and left, the streets take you waterward.";
ProfileOptions options = new ProfileOptions.Builder().text(text).build();
Profile profile = service.profile(options).execute();
System.out.println(profile);
}
use of com.ibm.watson.personality_insights.v3.model.ProfileOptions in project java-sdk by watson-developer-cloud.
the class PersonalityInsightsIT method getProfileWithContentItems.
/**
* Gets the profile from a list of content items.
*
* @throws Exception the exception
*/
@Test
public void getProfileWithContentItems() throws Exception {
final Content content = loadFixture(RESOURCE + "v3-contentItems.json", Content.class);
ProfileOptions options = new ProfileOptions.Builder().content(content).consumptionPreferences(true).rawScores(true).build();
Profile profile = service.profile(options).execute().getResult();
assertProfile(profile);
}
use of com.ibm.watson.personality_insights.v3.model.ProfileOptions in project java-sdk by watson-developer-cloud.
the class PersonalityInsightsIT method getProfileWithText.
/**
* Gets the profile with text.
*
* @throws Exception the exception
*/
@Test
public void getProfileWithText() throws Exception {
File file = new File(RESOURCE + "en.txt");
String englishText = getStringFromInputStream(new FileInputStream(file));
ProfileOptions options = new ProfileOptions.Builder().text(englishText).build();
Profile profile = service.profile(options).execute().getResult();
Assert.assertNotNull(profile);
Assert.assertNotNull(profile.getProcessedLanguage());
Assert.assertNotNull(profile.getValues());
Assert.assertNotNull(profile.getNeeds());
Assert.assertNotNull(profile.getPersonality());
}
Aggregations