examples/translate.rb in wwwjdic-14.0.0 vs examples/translate.rb in wwwjdic-15.0.0

- old
+ new

@@ -1,8 +1,8 @@ #-- # wwwjdic -# Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani +# © 2014 Marco Bresciani # # This file is part of wwwjdic. # # wwwjdic is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the @@ -14,115 +14,164 @@ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License # along with wwwjdic. If not, see <http://www.gnu.org/licenses/>. +# +# SPDX-FileCopyrightText: 2014 Marco Bresciani +# +# SPDX-License-Identifier: GPL-3.0-or-later #++ require_relative '../lib/wwwjdic' i = 0 -# Creates the WWWJDic object +# Create the WWWJDic object +puts '==========================================' +puts "TRANSLATE #{i}: Create the WWWJDic object." +puts 'a_wwwjdic = WWWJDic::breener' +a_wwwjdic = WWWJDic.breener puts '------------------------------------------' -puts "Basics: '#{i}'. Creates the WWWJDic object." -puts 'irb(main):001:0> a_wwwjdic = WWWJDic::breener' -a_wwwjdic = WWWJDic::breener puts i += 1 -# Translate '翻訳' in English, with default options -puts '------------------------------------------' -puts "Basics: '#{i}'. Translate '翻訳' in English, with default options." -puts "irb(main):001:0> a_wwwjdic.translate '翻訳'" +# Translate '翻訳' in English, with default options. +# <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +# <HTML> +# <HEAD><META http-equiv="Content-Type" content="text/html; charset=UTF-8"><TITLE>WWWJDIC: Word Display</TITLE> +# </HEAD><BODY> +# <br>&nbsp;<br> +# <pre> +# 翻訳(P);飜訳 [ほんやく] /(n,vs) (1) translation/(n,vs) (2) deciphering/decoding/(n) (3) {biol} translation/(P)/ +# 翻訳アセンブラ指示文 [ほんやくアセンブラしじぶん] /(n) {comp} assembler directive/ +# 翻訳コンパイラ指示文 [ほんやくコンパイラしじぶん] /(n) {comp} compiler directive/ +# 翻訳ソフトウェア [ほんやくソフトウェア] /(n) {comp} (automatic) translation software/ +# 翻訳テーブル [ほんやくテーブル] /(n) {comp} translation table/ +# 翻訳プログラム [ほんやくプログラム] /(n) {comp} translator/translation program/ +# 翻訳プログラム指示文 [ほんやくプログラムしじぶん] /(n) {comp} translator directive/ +# 翻訳メモリ [ほんやくメモリ] /(n) translation memory/ +# 翻訳ルーチン [ほんやくルーチン] /(n) {comp} compiler/ +# 翻訳家 [ほんやくか] /(n) translator/ +# 翻訳会社 [ほんやくかいしゃ] /(n) translation agency/ +# 翻訳解釈実行プログラム指示文 [ほんやくかいしゃくじっこうプログラムしじぶん] /(n) {comp} interpreter directive/ +# 翻訳学 [ほんやくがく] /(n) translation studies/ +# 翻訳権 [ほんやくけん] /(n) translation rights (to a book)/ +# 翻訳研究 [ほんやくけんきゅう] /(n) translation studies/ +# 翻訳元言語 [ほんやくもとげんご] /(n) language being translated from/source language/ +# 翻訳後修飾 [ほんやくごしゅうしょく] /(n) {biol} post-translational modification/PTM/ +# 翻訳語 [ほんやくご] /(n) (1) term used in translation/translation equivalent/(n) (2) word borrowed and translated from another language/ +# 翻訳指示文 [ほんやくしじぶん] /(n) {comp} compiler directing statement/ +# 翻訳時 [ほんやくじ] /(n) {comp} translation time/compile time/ +# 翻訳時間 [ほんやくじかん] /(n) {comp} translation time/ +# 翻訳者 [ほんやくしゃ] /(n) translator/ +# 翻訳借用 [ほんやくしゃくよう] /(n) loan translation/calque/ +# 翻訳書 [ほんやくしょ] /(n) translation/ +# 翻訳先言語 [ほんやくさきげんご] /(n) language being translated to/target language/ +# 翻訳単位のプログラム [ほんやくたんいのプログラム] /(n) {comp} separately compiled program/ +# 翻訳調 [ほんやくちょう] /(n) translationese/translatese/translatorese/ +# 翻訳文 [ほんやくぶん] /(n) translation/piece of translated writing/translated sentence/ +# 翻訳用計算機 [ほんやくようけいさんき] /(n) {comp} source-computer/ +# 翻訳用計算機記述項 [ほんやくようけいさんききじゅつこう] /(n) {comp} source computer entry/ +# </pre> +# </BODY> +# </HTML> +puts '==========================================' +puts "TRANSLATE #{i}: Translate '翻訳' in English, with default options [...]." +puts "a_wwwjdic.translate '翻訳'" puts a_wwwjdic.translate '翻訳' -puts -i += 1 - -# Computes the default raw URI to translate '翻訳' in English -# (http://www.edrdg.org/cgi-bin/wwwjdic/wwwjdic.cgi?1ZUQ%E7%BF%BB%E8%A8%B3) puts '------------------------------------------' -puts "Basics: '#{i}'. Computes the default raw URI to translate '翻訳' in English (http://www.edrdg.org/cgi-bin/wwwjdic/wwwjdic.cgi?1ZUQ%E7%BF%BB%E8%A8%B3)." -puts "irb(main):001:0> a_wwwjdic.raw_uri '翻訳'" -puts a_wwwjdic.raw_uri '翻訳' puts i += 1 -# Computes the default JSON URI to translate '翻訳' in English -# ({"翻訳":"http://www.edrdg.org/cgi-bin/wwwjdic/wwwjdic.cgi?1MUQ%E7%BF%BB%E8%A8%B3"}) +# Translate the word 'word'. +# <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +# <HTML> +# <HEAD><META http-equiv="Content-Type" content="text/html; charset=UTF-8"><TITLE>WWWJDIC: Word Display</TITLE> +# </HEAD><BODY> +# <br>&nbsp;<br> +# <pre> +# 伝言 [でんごん] /(n,vs) verbal message/word (from someone)/(P)/ +# 伝言 [つてこと] /(n) (1) (See 伝言・でんごん) verbal message/word (from someone)/(n) (2) rumour/rumor/ +# 一議 [いちぎ] /(n) word (opinion, objection)/ +# 言の葉 [ことのは;ことのえ] /(n) (1) (arch) word/(n) (2) (See 和歌) waka (classic Japanese poem, esp. a tanka)/ +# ワード /(n) (1) word/(n) (2) {comp} word/(n) (3) {comp} Word/Microsoft Word/(P)/ +# 語 [ご] /(n,n-suf) (1) language/(n,n-suf,ctr) (2) word/(P)/ +# 単語 [たんご] /(n,adj-no) {ling} word/vocabulary/(usually) single-character word/(P)/ +# 訪れ [おとずれ] /(n) (1) visit/call/(n) (2) arrival (e.g. of spring)/advent/coming/appearance/(n) (3) news/tidings/word/(P)/ +# 音沙汰;音さた [おとさた] /(n) news (from someone)/word/contact/ +# 言 [げん(P);こと] /(n) word/remark/statement/(P)/ +# 知らせ(P);報せ [しらせ] /(n) (1) (See お知らせ) news/word/tidings/notice/notification/information/(n) (2) omen/(P)/ +# 言葉(P);詞;辞 [ことば(P);けとば(言葉)(ok)] /(n) (1) (See 言語) language/dialect/(n) (2) (See 単語) word/words/phrase/term/expression/remark/(n) (3) speech/(manner of) speaking/(n) (4) learning to speak/language acquisition/(P)/ +# </pre> +# </BODY> +# </HTML> +puts '==========================================' +puts "TRANSLATE #{i}: Translate the word 'word' [...]." +puts "a_wwwjdic.translate 'word'" +puts a_wwwjdic.translate 'word' puts '------------------------------------------' -puts "Basics: '#{i}'. Computes the default JSON URI to translate '翻訳' in English ({\"翻訳\":\"http://www.edrdg.org/cgi-bin/wwwjdic/wwwjdic.cgi?1MUQ%E7%BF%BB%E8%A8%B3\"})." -puts "irb(main):001:0> a_wwwjdic.json_uri '翻訳'" -puts a_wwwjdic.json_uri '翻訳' puts i += 1 -# Computes the default basic URI to translate '翻訳' in Italian -# (http://www.edrdg.org/cgi-bin/wwwjdic/wwwjdic.cgi?OMUQ%E7%BF%BB%E8%A8%B3) +# Translate the word 'Sprache' with German dictionary. +# <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +# <HTML> +# <HEAD><META http-equiv="Content-Type" content="text/html; charset=UTF-8"><TITLE>WWWJDIC: Word Display</TITLE> +# </HEAD><BODY> +# <br>&nbsp;<br> +# <pre> +# 語学 [ごがく] /(n) (1) Sprachwissenschaft/Linguistik/(2) Fremdsprachenstudium/(3) Fremdsprache/Sprache (als Fach)/ +# +# 辞令 [じれい] /(n) (1) Ernennungsurkunde/Entlassungsurkunde/(2) Redensart/Redeweise/Ausdrucksweise/Sprache/ +# +# 言語 [ごんご] /(n) Worte/Sprache/ +# +# ランゲージ /(n) Sprache/ +# +# 辞命 [じめい] /(n) Redensart/Redeweise/Ausdrucksweise/Sprache/ +# +# 話 [わ] /(n,wordcomponent) (1) Erzählung/Geschichte/(2) Zählwort für Kapitel, Erzählungen, Episoden usw./Reden/Gespräch/Erzählung/Geschichte/Sprache/ +# +# …語 […ご] /(suf) (1) Wort/(2) Vokabel/(3) …isch/…-Sprache/ +# +# 言詞 [げんし] /(n) Sprache/ +# +# 語 [ご] /(n) (1) Wort/(2) Sprache/ +# +# 言辞 [げんじ] /(n) Worte/Rede/Sprache/ +# +# 言葉;ことば;コトバ;辞;詞 [コトバ] /(n) (1) Sprache/(2) Muttersprache/(3) Wort/(4) Dialekt/Mundart/(5) Ausdruck/Sprechweise/Diktion/Wortlaut/Wortwahl/ +# +# 言語 [げんご] /(n) (1) Sprache/(2) Sprechen/Worte/(3) Langue (im Gegensatz zu Parole bei F. de Saussure)/(4) Programmiersprache/ +# +# 言 [こと] /(n) (1) Wort/(2) Sprache/(3) Ruf/(4) Waka/ +# +# 言葉遣い;言葉遣;言葉づかい;ことばづかい;辞遣い;辞遣 [ことばづかい] /(n) Sprache/Ausdrucksweise/Diktion/ +# +# 弁;瓣;辯 [べん] /(n) (1) Sprechen/Sprechweise/Sprache/Reden/(2) Dialekt/Mundart/Akzent/ +# +# 口;くち;クチ [クチ] /(n) (1) Mund/Maul/Schnauze/(2) Sprache/Sprechen/(3) Mündlichkeit/(4) Gerücht/Gerede/(5) Sprechweise/(6) Essen und Trinken/(7) Genuss beim Essen/Geschmack/(8) Zahl der mit Nahrung zu versorgenden Münder/(9) Broterwerb/Beschäftigung/Stellung/(10) Öffnung/Loch/Schnabel/Mundstück/(11) Fassspund/Zapfen/Hahn/(12) Beginn/Anfang/(13) Sorte/(14) Gebiss/als Gebiss dienendes Seil/ +# +# 用語 [ようご] /(n) (1) Fachausdruck/Fachwort/Terminus technicus/Terminologie/(2) Wortschatz/Sprache/Vokabular/ +# +# 言の葉 [ことのは] /(n) Sprache/Wort/ +# +# </pre> +# </BODY> +# </HTML> +puts '==========================================' +puts "TRANSLATE #{i}: Translate the word 'Sprache' with German dictionary [...]." +puts "a_wwwjdic.translate 'Sprache', dict: 'Japanese-German (WaDoku)'" +puts a_wwwjdic.translate 'Sprache', dict: 'Japanese-German (WaDoku)' puts '------------------------------------------' -puts "Basics: '#{i}'. Computes the default basic URI to translate '翻訳' in Italian (http://www.edrdg.org/cgi-bin/wwwjdic/wwwjdic.cgi?OMUQ%E7%BF%BB%E8%A8%B3)." -puts "irb(main):001:0> a_wwwjdic.uri '翻訳', dict: 'Japanese-Italian'" -puts a_wwwjdic.uri '翻訳', dict: 'Japanese-Italian' puts i += 1 -# Computes the default JSON URI to translate '翻訳' in German -# (http://www.csse.monash.edu.au/~jwb/cgi-bin/wwwjdic.cgi?GMUQ%E7%BF%BB%E8%A8%B3) +# Translate the word 'parola' with Italian dictionary, in JSON format. +# {"parola":"http://www.edrdg.org/cgi-bin/wwwjdic/wwwjdic.cgi?OZDQparola","title":"WWWJDIC: Word Display","translation":"単語 [たんご] /(n,adj-no) parola/vocabolo/parola di un singolo carattere/\n\n一言(P);ひと言 [ひとこと(P);いちげん(一言);いちごん(一言)] /(n,vs) singola parola/(singola) parola/una sola parola/\n\n言論 [げんろん] /(n) espressione/(libertà di) parola/discussione/\n\n発言 [はつげん] /(n,vs) parola/intrvento (in un discorso)/\n\n言葉(P);詞;辞 [ことば(P);けとば(言葉)(ok)] /(n) parola/termine/vocabolo/lessico/lingua/linguaggio/dialetto/discorso/conversazione/modo di parlare/\n\nワード /(n) parola/{inf.} Microsoft Word (abbr.)/(en: word)/","message":null,"lines":["単語 [たんご] /(n,adj-no) parola/vocabolo/parola di un singolo carattere/","一言(P);ひと言 [ひとこと(P);いちげん(一言);いちごん(一言)] /(n,vs) singola parola/(singola) parola/una sola parola/","言論 [げんろん] /(n) espressione/(libertà di) parola/discussione/","発言 [はつげん] /(n,vs) parola/intrvento (in un discorso)/","言葉(P);詞;辞 [ことば(P);けとば(言葉)(ok)] /(n) parola/termine/vocabolo/lessico/lingua/linguaggio/dialetto/discorso/conversazione/modo di parlare/","ワード /(n) parola/{inf.} Microsoft Word (abbr.)/(en: word)/"],"content":[{"word":"単語","kana":"たんご","text":"(n,adj-no) parola/vocabolo/parola di un singolo carattere","meanings":["(n,adj-no) parola","vocabolo","parola di un singolo carattere"]},{"word":"一言(P);ひと言","kana":"ひとこと(P);いちげん(一言);いちごん(一言)","text":"(n,vs) singola parola/(singola) parola/una sola parola","meanings":["(n,vs) singola parola","(singola) parola","una sola parola"]},{"word":"言論","kana":"げんろん","text":"(n) espressione/(libertà di) parola/discussione","meanings":["(n) espressione","(libertà di) parola","discussione"]},{"word":"発言","kana":"はつげん","text":"(n,vs) parola/intrvento (in un discorso)","meanings":["(n,vs) parola","intrvento (in un discorso)"]},{"word":"言葉(P);詞;辞","kana":"ことば(P);けとば(言葉)(ok)","text":"(n) parola/termine/vocabolo/lessico/lingua/linguaggio/dialetto/discorso/conversazione/modo di parlare","meanings":["(n) parola","termine","vocabolo","lessico","lingua","linguaggio","dialetto","discorso","conversazione","modo di parlare"]},{"kana":"ワード","word":"ワード","text":"(n) parola/{inf.} Microsoft Word (abbr.)/(en: word)","meanings":["(n) parola","{inf.} Microsoft Word (abbr.)","(en: word)"]}]} +puts '==========================================' +puts "TRANSLATE #{i}: Translate the word 'parola' with Italian dictionary in JSON format (...)." +puts "a_wwwjdic.translate 'parola', dict: 'Japanese-Italian'" +puts a_wwwjdic.json_translate 'parola', dict: 'Japanese-Italian' puts '------------------------------------------' -puts "Basics: '#{i}'. Computes the default basic URI to translate '翻訳' in German, through Monash university URI (http://www.csse.monash.edu.au/~jwb/cgi-bin/wwwjdic.cgi?GMUQ%E7%BF%BB%E8%A8%B3)." -puts "irb(main):001:0> a_wwwjdic.uri '翻訳', dict: 'Japanese-German (WaDoku)', server: :monash" -puts a_wwwjdic.uri '翻訳', dict: 'Japanese-German (WaDoku)', server: :monash -puts -i += 1 - -# Prints the current (default) WWWJDic configuration URL. -# (http://www.edrdg.org/cgi-bin/wwwjdic/wwwjdic.cgi?1M) -puts '------------------------------------------' -puts "Basics: '#{i}'. Prints the current (default) WWWJDic configuration URL (http://www.edrdg.org/cgi-bin/wwwjdic/wwwjdic.cgi?1M)." -puts 'irb(main):001:0> puts a_wwwjdic' -puts a_wwwjdic -puts -i += 1 - -# Change the server value to Monash one. -# () -puts '------------------------------------------' -puts "Basics: '#{i}'. Change the server value to Monash one." -puts 'irb(main):001:0> a_wwwjdic.server = :monash' -a_wwwjdic.server = :monash -puts -i += 1 - -# Prints the (currently set) server -# (http://www.csse.monash.edu.au/~jwb/cgi-bin/wwwjdic.cgi?) -puts '------------------------------------------' -puts "Basics: '#{i}'. Prints the (currently set) server (http://www.csse.monash.edu.au/~jwb/cgi-bin/wwwjdic.cgi?)." -puts 'irb(main):001:0> puts a_wwwjdic.server' -puts a_wwwjdic.server -puts -i += 1 - -# Prints the WWWJDic configuration URL with currently set configuration. -# (http://www.csse.monash.edu.au/~jwb/cgi-bin/wwwjdic.cgi?1M) -puts '------------------------------------------' -puts "Basics: '#{i}'. Prints the WWWJDic configuration URL with currently set configuration (http://www.csse.monash.edu.au/~jwb/cgi-bin/wwwjdic.cgi?1M)." -puts 'irb(main):001:0> puts a_wwwjdic' -puts a_wwwjdic -puts -i += 1 - -# Resets the configuration to default values. -# (http://www.csse.monash.edu.au/~jwb/cgi-bin/wwwjdic.cgi?1M) -puts '------------------------------------------' -puts "Basics: '#{i}'. Resets the configuration to default values." -puts 'irb(main):001:0> a_wwwjdic.reset' -a_wwwjdic.reset -puts -i += 1 - -# Prints the current (default) WWWJDic configuration URL. -# (http://www.edrdg.org/cgi-bin/wwwjdic/wwwjdic.cgi?1M) -puts '------------------------------------------' -puts "Basics: '#{i}'. Prints the current (default) WWWJDic configuration URL (http://www.edrdg.org/cgi-bin/wwwjdic/wwwjdic.cgi?1M)." -puts 'irb(main):001:0> puts a_wwwjdic' -puts a_wwwjdic puts