Search in sources :

Example 1 with Content

use of com.ibm.watson.personality_insights.v3.model.Content in project atlas-deer by atlasapi.

the class ContentSerializerImpl method serialize.

@Override
public Content serialize(org.atlasapi.content.Content content) {
    Content internal = new Content();
    setType(internal, content);
    contentSetter.serialize(internal, content);
    itemSetter.serialize(internal, content);
    songSetter.serialize(internal, content);
    episodeSetter.serialize(internal, content);
    filmSetter.serialize(internal, content);
    containerSetter.serialize(internal, content);
    brandSetter.serialize(internal, content);
    seriesSetter.serialize(internal, content);
    return internal;
}
Also used : Content(org.atlasapi.content.v2.model.Content)

Example 2 with Content

use of com.ibm.watson.personality_insights.v3.model.Content 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);
}
Also used : ProfileOptions(com.ibm.watson.developer_cloud.personality_insights.v3.model.ProfileOptions) Content(com.ibm.watson.developer_cloud.personality_insights.v3.model.Content) Profile(com.ibm.watson.developer_cloud.personality_insights.v3.model.Profile) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Example 3 with Content

use of com.ibm.watson.personality_insights.v3.model.Content in project java-sdk by watson-developer-cloud.

the class PersonalityInsightsTest method testContentBuilders.

/**
 * Test content builders.
 */
@Test
public void testContentBuilders() {
    final String content1 = "Wow, I liked @TheRock before , now I really SEE how special he is. " + "The daughter story was IT for me. So great! #MasterClass";
    final String content2 = "Wow aren't you loving @TheRock and his candor? #Masterclass";
    Long now = new Date().getTime();
    final ContentItem cItem1 = new ContentItem.Builder(content1).language(ContentItem.Language.EN).contenttype("text/plain").created(now).updated(now).id(UUID.randomUUID().toString()).forward(false).reply(false).parentid(null).build();
    ContentItem cItem2 = cItem1.newBuilder().content(content2).id(UUID.randomUUID().toString()).build();
    assertEquals(cItem2.contenttype(), "text/plain");
    assertEquals(cItem2.created(), now);
    assertEquals(cItem2.updated(), now);
    assertNotEquals(cItem1.id(), cItem2.id());
    final Content content = new Content.Builder().addContentItem(cItem1).addContentItem(cItem2).build();
    assertEquals(content.contentItems().size(), 2);
    final Content newContent = content.newBuilder().build();
    assertEquals(newContent.contentItems().size(), 2);
}
Also used : Content(com.ibm.watson.developer_cloud.personality_insights.v3.model.Content) Date(java.util.Date) ContentItem(com.ibm.watson.developer_cloud.personality_insights.v3.model.ContentItem) Test(org.junit.Test) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest)

Example 4 with Content

use of com.ibm.watson.personality_insights.v3.model.Content 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);
}
Also used : ProfileOptions(com.ibm.watson.personality_insights.v3.model.ProfileOptions) Content(com.ibm.watson.personality_insights.v3.model.Content) Profile(com.ibm.watson.personality_insights.v3.model.Profile) WatsonServiceTest(com.ibm.watson.common.WatsonServiceTest) Test(org.junit.Test)

Example 5 with Content

use of com.ibm.watson.personality_insights.v3.model.Content in project java-sdk by watson-developer-cloud.

the class PersonalityInsightsIT method getProfileWithASingleContentItem.

/**
 * Gets the profile from a single content item.
 *
 * @throws Exception the exception
 */
@Test
public void getProfileWithASingleContentItem() throws Exception {
    File file = new File(RESOURCE + "en.txt");
    String englishText = getStringFromInputStream(new FileInputStream(file));
    Long now = new Date().getTime();
    ContentItem cItem = new ContentItem.Builder(englishText).language(ContentItem.Language.EN).contenttype("text/plain").created(now).updated(now).id(UUID.randomUUID().toString()).forward(false).reply(false).parentid(null).build();
    Content content = new Content.Builder(Collections.singletonList(cItem)).build();
    ProfileOptions options = new ProfileOptions.Builder().content(content).consumptionPreferences(true).acceptLanguage(ProfileOptions.AcceptLanguage.EN).rawScores(true).build();
    Profile profile = service.profile(options).execute().getResult();
    assertProfile(profile);
    Assert.assertTrue(profile.getValues().size() > 0);
    Assert.assertNotNull(profile.getValues().get(0).getCategory());
    Assert.assertNotNull(profile.getValues().get(0).getName());
    Assert.assertNotNull(profile.getValues().get(0).getTraitId());
    Assert.assertNotNull(profile.getValues().get(0).getPercentile());
    Assert.assertNotNull(profile.getValues().get(0).getRawScore());
    Assert.assertNotNull(profile.getBehavior());
    Assert.assertTrue(profile.getBehavior().size() > 0);
    Assert.assertNotNull(profile.getBehavior().get(0).getCategory());
    Assert.assertNotNull(profile.getBehavior().get(0).getName());
    Assert.assertNotNull(profile.getBehavior().get(0).getTraitId());
    Assert.assertNotNull(profile.getBehavior().get(0).getPercentage());
    Assert.assertTrue(profile.getConsumptionPreferences().size() > 0);
    Assert.assertNotNull(profile.getConsumptionPreferences().get(0).getName());
    Assert.assertNotNull(profile.getConsumptionPreferences().get(0).getConsumptionPreferenceCategoryId());
    Assert.assertNotNull(profile.getConsumptionPreferences().get(0).getConsumptionPreferences());
    Assert.assertTrue(profile.getConsumptionPreferences().get(0).getConsumptionPreferences().size() > 0);
    ConsumptionPreferences preference = profile.getConsumptionPreferences().get(0).getConsumptionPreferences().get(0);
    Assert.assertNotNull(preference.getConsumptionPreferenceId());
    Assert.assertNotNull(preference.getName());
    Assert.assertNotNull(preference.getScore());
}
Also used : FileInputStream(java.io.FileInputStream) Date(java.util.Date) Profile(com.ibm.watson.personality_insights.v3.model.Profile) ProfileOptions(com.ibm.watson.personality_insights.v3.model.ProfileOptions) Content(com.ibm.watson.personality_insights.v3.model.Content) ConsumptionPreferences(com.ibm.watson.personality_insights.v3.model.ConsumptionPreferences) File(java.io.File) ContentItem(com.ibm.watson.personality_insights.v3.model.ContentItem) WatsonServiceTest(com.ibm.watson.common.WatsonServiceTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)10 Content (com.ibm.watson.developer_cloud.personality_insights.v3.model.Content)6 Profile (com.ibm.watson.personality_insights.v3.model.Profile)6 ProfileOptions (com.ibm.watson.personality_insights.v3.model.ProfileOptions)6 Content (com.ibm.watson.personality_insights.v3.model.Content)5 WatsonServiceTest (com.ibm.watson.common.WatsonServiceTest)4 Profile (com.ibm.watson.developer_cloud.personality_insights.v3.model.Profile)4 ProfileOptions (com.ibm.watson.developer_cloud.personality_insights.v3.model.ProfileOptions)4 ContentItem (com.ibm.watson.personality_insights.v3.model.ContentItem)4 File (java.io.File)4 FileInputStream (java.io.FileInputStream)4 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)3 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)3 ContentItem (com.ibm.watson.developer_cloud.personality_insights.v3.model.ContentItem)3 Date (java.util.Date)3 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)3 MockResponse (okhttp3.mockwebserver.MockResponse)2 Content (org.atlasapi.content.v2.model.Content)2 Test (org.testng.annotations.Test)2 ImmutableList (com.google.common.collect.ImmutableList)1