奇怪的API结果格式

问题描述 投票:0回答:1

我找到了从谷歌翻译(非 API)获取额外翻译的正确查询,但它的格式非常奇怪,我以前从未见过。

http://translate.google.com/translate_a/t?client=t&sl=auto&tl=en&hl=en&sc=2&ie=UTF-8&oe=UTF-8&uptl=en&alttl=ru&pc=1&oc=1&otf=1&ssel=0&tsel=0&q= %D0%B2%D0%BC%D0%B5%D1%81%D1%82%D0%B5

[[["together","вместе","","vmeste"]],[["adverb",["together","along","in conjunction","along with","teamwise"],[["together",["вместе","друг с другом","одновременно","воедино","сообща","заодно"],,0.472366542],["along",["вдоль","вместе","вперед","с собой","по длине","дальше"],,0.0944792554],["in conjunction",["вместе","сообща"],,0.0089263292],["along with",["вместе"],,0.000561794208],["teamwise",["сообща","вместе"],,3.34055039e-06]],"вместе",4],["preposition",["including"],[["including",["включая","в том числе","вместе"],,0.00272237672]],"вместе",5]],"ru",,[["together",[4],1,0,999,0,1,0]],[["вместе",4,[["together",999,1,0],["along",0,1,0],["with",0,1,0]],[[0,6]],"вместе"]],,,[],64]

我能够用代码很好地解码它

    $kl = str_replace('[[','[',$kl);
    $kl = str_replace(']]',']',$kl);
    $kl = str_replace('[[','[',$kl);
    $kl = str_replace(']]',']',$kl);
    $kl = explode('],', $kl);
    $kl = $kl[1];
    $kl = str_replace('"',"",$kl);
    $kl = str_replace(",["," - ",$kl);
    $kl = str_replace(",",", ",$kl);
    $kl = str_replace('[','',$kl);

有人认识这种格式或愿意尝试破译它吗?

php json google-translate text-parsing
1个回答
1
投票

它看起来像递归自然语言解析中使用的深度嵌套的 JavaScript 数组。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.