Text Tags

textTags.predict(data, [params])
Determine the topics in the phrase or document.

Current Version: 2

Arguments

data – String | List – required – text to be analyzed
[api_key] – String – optional – your indico API key
[cloud] – String – optional – your private cloud subdomain
[v or version] – Integer – optional (defaults to 2) – specify model version
[top_n] – Integer – optionals – only return this many of the most likely topics
[threshold] – Float (defaults to 0.) – optional – only return topics with likelihood greater than this number

Output

This function will return a dictionary with 111 key-value pairs. These key-value pairs represent the likelihood that the analyzed text is about each of the 111 possible topics. The keys in the dictionary are strings containing the topic names and the values are the probabilities that the analyzed text is about each topic.

# single output
{
    'anime': 0.003982535730280216,
    'anthropology': 0.020311181569223534,
    'archery': 0.4893124752591462,
    ... 105 topics omitted ...,
    'wrestling': 0.0009661379304299885,
    'writing': 0.00532591437084736,
    'yoga': 0.001874647791589776
}

# batch output
[
    {
        'anime': 0.003982535730280216,
        'anthropology': 0.020311181569223534,
        'archery': 0.4893124752591462,
        ... 105 topics omitted ...,
        'wrestling': 0.0009661379304299885,
        'writing': 0.00532591437084736,
        'yoga': 0.001874647791589776
    },
    {
        'anime': 0.0020400125677411812,
        'anthropology': 0.010790799662278016,
        'archery': 0.002072348777350773,
        ... 105 topics omitted ...,
        'wrestling': 0.0012626451944395167,
        'writing': 0.004772236821288096,
        'yoga': 0.22969626130844248
    }
]

Complete List of Tags

anime, anthropology, archery, architecture, art, astronomy, atheism, aviation, baseball, beer, bicycling, biology, books, boxing, buddhism, business, cars, christianity, climbing, comedy, comics, conspiracy, cooking, crafts, cricket, design, dieting, diy, drugs, economic_discussion, education, electronics, energy, entertainment_news, environmental, fashion, fiction, film, fishing, fitness, gaming, gardening, gender_issues, general_food, golf, guns, health, history, hockey, hunting, individualist_politics, investment, islam, jobs, judaism, left_politics, lgbt, math, medicine, military, music, nba, news, nfl, nostalgia, nutrition, parenting, personal, personal_care_and_beauty, personalfinance, pets, philosophy, photography, poetry, poker, political_discussion, programming, psychology, realestate, relationships, religion, right_politics, romance, rugby, running, sailing, school, science, scuba, singing, skateboarding, soccer, sports, startups_and_entrepreneurship, surfing, swimming, tattoo, technology, television, tennis, travel, ultimate, vegan, vegetarian, weather, wedding, weight_training, wine, wrestling, writing, yoga

Example

import io.indico.Indico;
import io.indico.api.text.TextTag;
import io.indico.api.IndicoResult;
import io.indico.api.BatchIndicoResult;
import java.util.HashMap;

Map params = new HashMap();
params.put("threshold", 0.1)

// single example
Indico indico = new Indico("YOUR_API_KEY");
IndicoResult single = indico.textTags.predict(
    "The most common form of arrow consists of a shaft with an arrowhead attached to the front end and with fletchings and a nock attached to the other end.", params
);
Map result = single.getTextTags();
System.out.println(result);

// batch example
String[] example = {
    "The most common form of arrow consists of a shaft with an arrowhead attached to the front end and with fletchings and a nock attached to the other end.",
    "Yoga in Indian traditions, however, is more than physical exercise, it has a meditative and spiritual core."
};
BatchIndicoResult multiple = indico.textTags.predict(example, params);
List> results = multiple.getTextTags();
System.out.println(results);