Skip to main content

Presentation Language

By default, entities and tags returned from analysis or recommendation are provided in the language of the input document or photo.

However, you can request that they be returned in a different language, by using the presentationLanguage parameter.

Currently supported values include the ISO codes for:

  • Czech (cs)
  • Dutch (nl)
  • English (en)
  • French (fr)
  • German (de)
  • Polish (pl)
  • Portuguese (pt)
  • Slovak (sk)
  • Spanish (ex)
Basic code common to all guide pages

Basic Code

To use the API, you'll need a valid API key with the appropriate permissions. If you don't have one, please contact us here.

In the code below, replace <YOUR_API_KEY> with your actual API key.

Note: We do not currently provide dedicated SDKs for this API, but our G3 SDKs can be used to perform NLP analysis.

# No special setup necessary

Presentation Language in Article Content Analysis

The following example demonstrates how to request entities and tags in French, regardless of the input language.

This example is the same as the one in the Quickstart, with the addition of 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);

This produces the following result: (See the Analysis reference for a detailed explanation of each field. The relations field is omitted here for brevity.)

{
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

In cases where you need the output in multiple presentation languages, you have two options:

  1. Repeat the analysis/recommendation with a different presentationLanguage value each time.
  2. Translate entities or tags after the initial analysis using the Knowledge Base API, which is generally more efficient.

Example: Translating tags to Polish
Let's assume you've already received tags (e.g., from Photo Recommendation), and you want their names in Polish.

Use the Knowledge Base stdforms endpoint to get the translated standard forms:

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);

Example output

{
G458: { value: 'Unia Europejska', language: 'pl' },
G567: { value: 'Angela Merkel', language: 'pl' }
}