Skip to main content

Presentation Language

By default, entities and tags of analysis or recommendation are reported in the language of the document or photo. However, we can request them in other languages as well (currently, Czech, Dutch, English, French, German, Polish, Portuguese, Slovak, and Spanish are supported) using the parameter presentationLanguage with the ISO code of the desired language.

Basic code common for all the guide pages

Basic code

To use the API, you need a valid API key with appropriate authorizations. Please get in touch with us if you do not have it here. In the code below, replace <YOUR_API_KEY> with the API key.

Note that we do not provide SDKs for the API yet, but our G3 SDKs can be used to perform NLP analysis.

No special setup necessary

Presentation Language in Article Content Analysis

Below, is an example reporting entities and tags in French. The code is the same as in this example except the presentationLanguage parameter.

const analyze = async (config, input) => {
const response = await axios.post('nlp/analyze', input, config);
return response.data;
};

const input = {
id: '1234',
title: 'Emmanuel Macron in Germany.',
text: 'Mr. Macron visited a trade show in Munich.'
presentationLanguage: 'fr'
}

analyze(config, input).then(report);

produces the following result (see the Analysis reference page for explanation. Note that we have omitted the relations field for simplicity).

{
version: '3.2.1',
id: '1234',
language: { detected: 'en' },
entities: [
{ id: 'e0', gkbId: 'G57305', stdForm: 'salon', type: 'general' },
{ id: 'e1', gkbId: 'G183', stdForm: 'Allemagne', type: 'location' },
{ id: 'e2', gkbId: 'G1726', stdForm: 'Munich', type: 'location' },
{ id: 'e3', gkbId: 'G3052772', stdForm: 'Emmanuel Macron', type: 'person' },
{ id: 'e4', gkbId: 'G183', stdForm: 'Allemagne', type: 'country', feats: {derivedBy: 'gkb2:[gkbp:adminCountry]'} },
{ id: 'e5', gkbId: 'G980', stdForm: 'Bavière', type: 'region', feats: { derivedBy: 'gkb2:[gkbp:region]' } }
],
tags: [
{ id: 't0', gkbId: 'G3052772', stdForm: 'Emmanuel Macron', type: 'media', relevance: 22.605, feats: { wikidataId: 'Q3052772' } },
{ id: 't1', gkbId: 'G183', stdForm: 'Allemagne', type: 'media', relevance: 18.365, feats: { wikidataId: 'Q183' } },
{ id: 't2', gkbId: 'G1726', stdForm: 'Munich', type: 'media', relevance: 7.57, feats: { wikidataId: 'Q1726' } }
],
relations: [..],
docSentiment: { mean: 0.0, label: 'neutral', positive: 0.0, negative: 0.0 },
usedChars: 100
}

Presentation Language in Photo Recommendation

Documentation coming soon.

Multiple Presentation Languages

Sometimes more than one presentation language is needed. Obviously, we could perform repeated analyses or recommendations, each with one of the desired presentation language. However, it is typically faster to perform one analysis/recommendation and then ask the knowledgebase for translation of entities and tags to other languages.

For example, the following code, translates two tags (e.g., from a Photo Recommendations) to Polish:

const kbStdForms = async (input, config) => {
const response = await axios.post("knowledgebase/stdforms", input, config);
return response.data;
};

input = {
ids: ["G458", "G567"],
language: "pl",
};

kbStdForms(input, config).then(report);
{
G458: { value: 'Unia Europejska', language: 'pl' },
G567: { value: 'Angela Merkel', language: 'pl' }
}