Use aylien news api - Java Natural Language Processing

Java examples for Natural Language Processing:aylien

Description

Use aylien news api

Demo Code

import com.aylien.newsapi.*;
import com.aylien.newsapi.auth.*;
import com.aylien.newsapi.models.*;
import com.aylien.newsapi.parameters.*;
import com.aylien.newsapi.api.DefaultApi;

import java.util.Arrays;
import java.util.List;

public class Main {

    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();

        // Configure API key authorization: app_id
        ApiKeyAuth app_id = (ApiKeyAuth) defaultClient
                .getAuthentication("app_id");
        app_id.setApiKey("{{current_app_id}}");

        // Configure API key authorization: app_key
        ApiKeyAuth app_key = (ApiKeyAuth) defaultClient
                .getAuthentication("app_key");
        app_key.setApiKey("{{current_app_key}}");

        DefaultApi apiInstance = new DefaultApi();

        List<Long> id = Arrays.asList(985744L);
        List<Long> notId = Arrays.asList(5241L, 4412L);
        String title = "startup AND (raise OR raised OR raising OR raises)";
        String body = "startup";
        String text = "startup company";
        List<String> language = Arrays.asList("en", "es", "es");
        List<String> notLanguage = Arrays.asList("fr", "pt", "it");
        String publishedAtStart = "NOW-3MONTHS/DAY";
        String publishedAtEnd = "NOW-10DAYS";
        String categoriesTaxonomy = "iab-qag";
        Boolean categoriesConfident = true;
        List<String> categoriesId = Arrays.asList("IAB15", "IAB13-1");
        List<String> notCategoriesId = Arrays.asList("IAB3-2");
        List<Integer> categoriesLevel = Arrays.asList(2);
        List<Integer> notCategoriesLevel = Arrays.asList(1, 3);
        List<String> entitiesTitleText = Arrays.asList("GNU/Linux",
                "Microsoft Windows");
        List<String> notEntitiesTitleText = Arrays.asList("Ireland",
                "Dublin");
        List<String> entitiesTitleType = Arrays.asList("Software",
                "Organization");
        List<String> notEntitiesTitleType = Arrays
                .asList("Agent", "Person");
        List<String> entitiesTitleLinksDbpedia = Arrays
                .asList("http://dbpedia.org/resource/Linux");
        List<String> notEntitiesTitleLinksDbpedia = Arrays
                .asList("http://dbpedia.org/resource/Windows");
        List<String> entitiesBodyText = Arrays.asList("GNU/Linux",
                "Microsoft Windows");
        List<String> notEntitiesBodyText = Arrays.asList("Trump");
        List<String> entitiesBodyType = Arrays.asList("Agent", "Person");
        List<String> notEntitiesBodyType = Arrays.asList("Software",
                "Organization");
        List<String> entitiesBodyLinksDbpedia = Arrays
                .asList("entitiesBodyLinksDbpedia_example");
        List<String> notEntitiesBodyLinksDbpedia = Arrays
                .asList("http://dbpedia.org/resource/Linux");
        String sentimentTitlePolarity = "negative";
        String notSentimentTitlePolarity = "positive";
        String sentimentBodyPolarity = "neutral";
        String notSentimentBodyPolarity = "negative";
        Integer mediaImagesCountMin = 2;
        Integer mediaImagesCountMax = 4;
        Integer mediaImagesWidthMin = 640;
        Integer mediaImagesWidthMax = 1024;
        Integer mediaImagesHeightMin = 480;
        Integer mediaImagesHeightMax = 800;
        Integer mediaImagesContentLengthMin = 25411;
        Integer mediaImagesContentLengthMax = 369541;
        List<String> mediaImagesFormat = Arrays
                .asList("JPEG", "BMP", "GIF");
        List<String> notMediaImagesFormat = Arrays.asList("PNG", "TIFF");
        Integer mediaVideosCountMin = 1;
        Integer mediaVideosCountMax = 2;
        List<Integer> authorId = Arrays.asList(36521);
        List<Integer> notAuthorId = Arrays.asList(2541);
        String authorName = "John Doe";
        String notAuthorName = "Mike Wally";
        List<Integer> sourceId = Arrays.asList(1411);
        List<Integer> notSourceId = Arrays.asList(251);
        List<String> sourceName = Arrays.asList("BBC");
        List<String> notSourceName = Arrays.asList("Fox News");
        List<String> sourceDomain = Arrays.asList("bbc.co.uk");
        List<String> notSourceDomain = Arrays.asList("foxnews.com");
        List<String> sourceLocationsCountry = Arrays.asList("US", "IE");
        List<String> notSourceLocationsCountry = Arrays.asList("IR");
        List<String> sourceLocationsState = Arrays.asList("California");
        List<String> notSourceLocationsState = Arrays.asList("Arizona");
        List<String> sourceLocationsCity = Arrays.asList("Los Angeles");
        List<String> notSourceLocationsCity = Arrays.asList("Dublin City");
        List<String> sourceScopesCountry = Arrays.asList("IE", "NG");
        List<String> notSourceScopesCountry = Arrays.asList("US", "GB");
        List<String> sourceScopesState = Arrays.asList("Co Dublin");
        List<String> notSourceScopesState = Arrays.asList("Co Wicklow");
        List<String> sourceScopesCity = Arrays.asList("Dublin City");
        List<String> notSourceScopesCity = Arrays.asList("Cork");
        List<String> sourceScopesLevel = Arrays.asList("national");
        List<String> notSourceScopesLevel = Arrays.asList("local");
        Integer sourceLinksInCountMin = 354211;
        Integer sourceLinksInCountMax = 587412;
        Integer sourceRankingsAlexaRankMin = 10;
        Integer sourceRankingsAlexaRankMax = 2500;
        List<String> sourceRankingsAlexaCountry = Arrays.asList("IE");
        Integer socialSharesCountFacebookMin = 3521;
        Integer socialSharesCountFacebookMax = 5841;
        Integer socialSharesCountGooglePlusMin = 2514;
        Integer socialSharesCountGooglePlusMax = 36521;
        Integer socialSharesCountLinkedinMin = 6521;
        Integer socialSharesCountLinkedinMax = 36521;
        Integer socialSharesCountRedditMin = 14125;
        Integer socialSharesCountRedditMax = 95412;
        Boolean cluster = false;/*from www .  j  a v a2s . c  o  m*/
        String clusterAlgorithm = "stc";
        List<String> _return = Arrays.asList("id", "title", "body");
        Long storyId = 789L;
        String storyUrl = "https://techcrunch.com/2016/04/07/aylien-launches-news-analysis-api-powered-by-its-deep-learning-tech/";
        String storyTitle = "Aylien launches news analysis API powered by its deep learning tech";
        String storyBody = "Text analysis startup Aylien, which uses deep learning...";
        String boostBy = "recency";
        String storyLanguage = "auto";
        Integer perPage = 6;

        RelatedStoriesParams.Builder relatedStoriesBuilder = RelatedStoriesParams
                .newBuilder();

        relatedStoriesBuilder.setId(id);
        relatedStoriesBuilder.setNotId(notId);
        relatedStoriesBuilder.setTitle(title);
        relatedStoriesBuilder.setBody(body);
        relatedStoriesBuilder.setText(text);
        relatedStoriesBuilder.setLanguage(language);
        relatedStoriesBuilder.setNotLanguage(notLanguage);
        relatedStoriesBuilder.setPublishedAtStart(publishedAtStart);
        relatedStoriesBuilder.setPublishedAtEnd(publishedAtEnd);
        relatedStoriesBuilder.setCategoriesTaxonomy(categoriesTaxonomy);
        relatedStoriesBuilder.setCategoriesConfident(categoriesConfident);
        relatedStoriesBuilder.setCategoriesId(categoriesId);
        relatedStoriesBuilder.setNotCategoriesId(notCategoriesId);
        relatedStoriesBuilder.setCategoriesLevel(categoriesLevel);
        relatedStoriesBuilder.setNotCategoriesLevel(notCategoriesLevel);
        relatedStoriesBuilder.setEntitiesTitleText(entitiesTitleText);
        relatedStoriesBuilder.setNotEntitiesTitleText(notEntitiesTitleText);
        relatedStoriesBuilder.setEntitiesTitleType(entitiesTitleType);
        relatedStoriesBuilder.setNotEntitiesTitleType(notEntitiesTitleType);
        relatedStoriesBuilder
                .setEntitiesTitleLinksDbpedia(entitiesTitleLinksDbpedia);
        relatedStoriesBuilder
                .setNotEntitiesTitleLinksDbpedia(notEntitiesTitleLinksDbpedia);
        relatedStoriesBuilder.setEntitiesBodyText(entitiesBodyText);
        relatedStoriesBuilder.setNotEntitiesBodyText(notEntitiesBodyText);
        relatedStoriesBuilder.setEntitiesBodyType(entitiesBodyType);
        relatedStoriesBuilder.setNotEntitiesBodyType(notEntitiesBodyType);
        relatedStoriesBuilder
                .setEntitiesBodyLinksDbpedia(entitiesBodyLinksDbpedia);
        relatedStoriesBuilder
                .setNotEntitiesBodyLinksDbpedia(notEntitiesBodyLinksDbpedia);
        relatedStoriesBuilder
                .setSentimentTitlePolarity(sentimentTitlePolarity);
        relatedStoriesBuilder
                .setNotSentimentTitlePolarity(notSentimentTitlePolarity);
        relatedStoriesBuilder
                .setSentimentBodyPolarity(sentimentBodyPolarity);
        relatedStoriesBuilder
                .setNotSentimentBodyPolarity(notSentimentBodyPolarity);
        relatedStoriesBuilder.setMediaImagesCountMin(mediaImagesCountMin);
        relatedStoriesBuilder.setMediaImagesCountMax(mediaImagesCountMax);
        relatedStoriesBuilder.setMediaImagesWidthMin(mediaImagesWidthMin);
        relatedStoriesBuilder.setMediaImagesWidthMax(mediaImagesWidthMax);
        relatedStoriesBuilder.setMediaImagesHeightMin(mediaImagesHeightMin);
        relatedStoriesBuilder.setMediaImagesHeightMax(mediaImagesHeightMax);
        relatedStoriesBuilder
                .setMediaImagesContentLengthMin(mediaImagesContentLengthMin);
        relatedStoriesBuilder
                .setMediaImagesContentLengthMax(mediaImagesContentLengthMax);
        relatedStoriesBuilder.setMediaImagesFormat(mediaImagesFormat);
        relatedStoriesBuilder.setNotMediaImagesFormat(notMediaImagesFormat);
        relatedStoriesBuilder.setMediaVideosCountMin(mediaVideosCountMin);
        relatedStoriesBuilder.setMediaVideosCountMax(mediaVideosCountMax);
        relatedStoriesBuilder.setAuthorId(authorId);
        relatedStoriesBuilder.setNotAuthorId(notAuthorId);
        relatedStoriesBuilder.setAuthorName(authorName);
        relatedStoriesBuilder.setNotAuthorName(notAuthorName);
        relatedStoriesBuilder.setSourceId(sourceId);
        relatedStoriesBuilder.setNotSourceId(notSourceId);
        relatedStoriesBuilder.setSourceName(sourceName);
        relatedStoriesBuilder.setNotSourceName(notSourceName);
        relatedStoriesBuilder.setSourceDomain(sourceDomain);
        relatedStoriesBuilder.setNotSourceDomain(notSourceDomain);
        relatedStoriesBuilder
                .setSourceLocationsCountry(sourceLocationsCountry);
        relatedStoriesBuilder
                .setNotSourceLocationsCountry(notSourceLocationsCountry);
        relatedStoriesBuilder.setSourceLocationsState(sourceLocationsState);
        relatedStoriesBuilder
                .setNotSourceLocationsState(notSourceLocationsState);
        relatedStoriesBuilder.setSourceLocationsCity(sourceLocationsCity);
        relatedStoriesBuilder
                .setNotSourceLocationsCity(notSourceLocationsCity);
        relatedStoriesBuilder.setSourceScopesCountry(sourceScopesCountry);
        relatedStoriesBuilder
                .setNotSourceScopesCountry(notSourceScopesCountry);
        relatedStoriesBuilder.setSourceScopesState(sourceScopesState);
        relatedStoriesBuilder.setNotSourceScopesState(notSourceScopesState);
        relatedStoriesBuilder.setSourceScopesCity(sourceScopesCity);
        relatedStoriesBuilder.setNotSourceScopesCity(notSourceScopesCity);
        relatedStoriesBuilder.setSourceScopesLevel(sourceScopesLevel);
        relatedStoriesBuilder.setNotSourceScopesLevel(notSourceScopesLevel);
        relatedStoriesBuilder
                .setSourceLinksInCountMin(sourceLinksInCountMin);
        relatedStoriesBuilder
                .setSourceLinksInCountMax(sourceLinksInCountMax);
        relatedStoriesBuilder
                .setSourceRankingsAlexaRankMin(sourceRankingsAlexaRankMin);
        relatedStoriesBuilder
                .setSourceRankingsAlexaRankMax(sourceRankingsAlexaRankMax);
        relatedStoriesBuilder
                .setSourceRankingsAlexaCountry(sourceRankingsAlexaCountry);
        relatedStoriesBuilder
                .setSocialSharesCountFacebookMin(socialSharesCountFacebookMin);
        relatedStoriesBuilder
                .setSocialSharesCountFacebookMax(socialSharesCountFacebookMax);
        relatedStoriesBuilder
                .setSocialSharesCountGooglePlusMin(socialSharesCountGooglePlusMin);
        relatedStoriesBuilder
                .setSocialSharesCountGooglePlusMax(socialSharesCountGooglePlusMax);
        relatedStoriesBuilder
                .setSocialSharesCountLinkedinMin(socialSharesCountLinkedinMin);
        relatedStoriesBuilder
                .setSocialSharesCountLinkedinMax(socialSharesCountLinkedinMax);
        relatedStoriesBuilder
                .setSocialSharesCountRedditMin(socialSharesCountRedditMin);
        relatedStoriesBuilder
                .setSocialSharesCountRedditMax(socialSharesCountRedditMax);
        relatedStoriesBuilder.setCluster(cluster);
        relatedStoriesBuilder.setClusterAlgorithm(clusterAlgorithm);
        relatedStoriesBuilder.set_return(_return);
        relatedStoriesBuilder.setStoryId(storyId);
        relatedStoriesBuilder.setStoryUrl(storyUrl);
        relatedStoriesBuilder.setStoryTitle(storyTitle);
        relatedStoriesBuilder.setStoryBody(storyBody);
        relatedStoriesBuilder.setBoostBy(boostBy);
        relatedStoriesBuilder.setStoryLanguage(storyLanguage);
        relatedStoriesBuilder.setPerPage(perPage);

        try {
            RelatedStories result = apiInstance
                    .listRelatedStories(relatedStoriesBuilder.build());
            System.out.println(result);
        } catch (ApiException e) {
            System.err
                    .println("Exception when calling DefaultApi#listRelatedStories");
            e.printStackTrace();
        }
    }
}

Related Tutorials