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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more