Public
Edited
Jan 5, 2024
Insert cell
Insert cell
Insert cell
Insert cell
page = await wiki.summary('Die Hard', { content: true, lang: "es" });
Insert cell
html `${await getWikipediaIntro("Die Hard", "es")}`
Insert cell
Insert cell
allLangs = await wiki.langLinks('Die Hard');
Insert cell
Promise.all(allLangs.slice(0, 5).map(async e =>{
try {
const wikiIntro = await getWikipediaIntro(e.title, e.lang);
const objectName = await extractObjectName(e.lang, wikiIntro);
const currLang = await Promise.all(objectName.map(async obj=>({
origLang: e.lang,
origNameCountry: obj.country,
origName: obj.name ,
url: e.url,
targetLang,
translation: await translateWithGpt(e.lang, targetLang, obj.name)
})));
return currLang;
} catch (error) {
console.error(error);
return {
origLang: e.lang,
error: error.message
}
}
}))
Insert cell
Insert cell
Insert cell
getWikipediaLanguages("Die Hard", "es")
Insert cell
getTranslation("Die hard", "es", "ru")
Insert cell
extractObjectName("an", "<i><b>Die Hard</b></i> (títol orichinal en anglés, en aragonés <i><b>Duros de matar</b></i>, enguerada en Aragón con o títol en castellano de <i><b>Jungla de cristal</b></i>, <i><b>Chungla de cristal</b></i> en aragonés) ye una cinta de cine d'acción estausunidense de l'anyo 1988 dirichida por John McTiernan seguntes un guión adaptau por Jeb Stuart y Steven E. de Souza\nd'a novela <i>Nothing Lasts Forever</i>, de Roderick Thorp (1979). La dirección de fotografía d'a cinta ye de Jan de Bont y la Banda Sonora Orichinal ye un treballo de Michael Kamen. Producida por Lawrence Gordon y Joel Silver ta las productoras cinematograficas <i>Gordon Company</i> y <i>Silver Pictures</i>, en l'elenco d'a cinta amanixen como actors destacaus Bruce Willis, Alan Rickman, Alexander Godunov, Bonnie Bedelia, Paul Gleason y Reginald VelJohnson.\n")
Insert cell
Insert cell
function extractObjectName(lang, caption){
const assistantId = "asst_xrL6uikrKUCMnlr90KfZMG4j";
const inputText = `${lang}
${caption}`;
const result = askOpenAiAssistant(assistantId, inputText)
.then(result=>JSON.parse(result));
return result;
}
Insert cell
function translateWithGpt(source, target, text){
const assistantId = "asst_RC2lrJIssjz7fZekKtdTOmFR";
const inputText = `source: "${source}"
target: "${target}"
text: "${text}"`;

const result = askOpenAiAssistant(assistantId, inputText);
return result;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more