diff --git "a/\043game\043" "b/\043game\043" new file mode 100644 index 0000000..e69de29 --- /dev/null +++ "b/\043game\043" diff --git "a/\043syoukai.rb\043" "b/\043syoukai.rb\043" new file mode 100755 index 0000000..835639c --- /dev/null +++ "b/\043syoukai.rb\043" @@ -0,0 +1,5 @@ +#!/usr/bin/env ruby +# -*- coding: utf-8-emacs -*- +puts("ピコン!") +puts("こんにちは!") +puts("どこの都道府県を知りたいですか?") diff --git "a/\043\351\203\275\351\201\223\345\272\234\347\234\214\043" "b/\043\351\203\275\351\201\223\345\272\234\347\234\214\043" new file mode 100755 index 0000000..c91e147 --- /dev/null +++ "b/\043\351\203\275\351\201\223\345\272\234\347\234\214\043" @@ -0,0 +1,40 @@ + + +#!/usr/bin/env ruby +# -*- coding: utf-8 -*- +puts "ピコン!" +puts"どの都道府県の情報を知りたいですか?" +while trus +print "都道府県を入力" +kotae = gets.chomp.to._i +if kotae == 山形 +puts"山形" +puts"人口..約99万人" +puts"特産品...サクランボ、ラ・フランスなど、" +puts"キャラクター..きてけろくん、ぺろりんなど、" +puts"面積..約9325K㎡" +redo +elsif kotae == 北海道 +puts"北海道" +puts"人口..約522万人" +puts"特産品..鮭、カニ、ウニ" +puts"キャラクター..メロン熊、きゅんちゃん" +puts"面積..約83460K㎡" +redo +elsif kotae == 青森 +puts"青森" +puts"人口..約166万5千人" +puts"特産品..りんご、こんにゃく、ごぼう" +puts"キャラクター..たか丸くん、おいらくん、もーりー" +puts"面積..約9606K㎡" +redo +elsif kotae == 岩手 +puts"岩手" +puts"人口..約117万人" +puts"特産品..かもめの玉子、あんバター" +puts"キャラクター..わんこ兄弟、ケロ平" +puts"面積..15280万K㎡" +redo +else +puts"?" +redo diff --git "a/.\043game" "b/.\043game" new file mode 120000 index 0000000..63d6575 --- /dev/null +++ "b/.\043game" @@ -0,0 +1 @@ +j2518@jd.koeki-u.ac.jp.1075:1762959638 \ No newline at end of file diff --git "a/.\043syoukai.rb" "b/.\043syoukai.rb" new file mode 120000 index 0000000..63d6575 --- /dev/null +++ "b/.\043syoukai.rb" @@ -0,0 +1 @@ +j2518@jd.koeki-u.ac.jp.1075:1762959638 \ No newline at end of file diff --git "a/.\043\351\203\275\351\201\223\345\272\234\347\234\214" "b/.\043\351\203\275\351\201\223\345\272\234\347\234\214" new file mode 120000 index 0000000..70a8c27 --- /dev/null +++ "b/.\043\351\203\275\351\201\223\345\272\234\347\234\214" @@ -0,0 +1 @@ +j2518@jd.koeki-u.ac.jp.4690:1762959638 \ No newline at end of file diff --git "a/.~lock.J25xx-YourName.odp\043" "b/.~lock.J25xx-YourName.odp\043" deleted file mode 100644 index 3f2c233..0000000 --- "a/.~lock.J25xx-YourName.odp\043" +++ /dev/null @@ -1 +0,0 @@ -,j2518,jd.koeki-u.ac.jp,20.09.2025 15:11,file:///home/j2518/.config/libreoffice/4; \ No newline at end of file diff --git a/J25xx-YourName.odp b/J25xx-YourName.odp index 7806143..6af3e39 100644 --- a/J25xx-YourName.odp +++ b/J25xx-YourName.odp Binary files differ diff --git a/jdlogo.png b/jdlogo.png new file mode 100644 index 0000000..c3262a8 --- /dev/null +++ b/jdlogo.png Binary files differ diff --git a/kyoutsuugo.txt b/kyoutsuugo.txt new file mode 100644 index 0000000..4f07c3e --- /dev/null +++ b/kyoutsuugo.txt @@ -0,0 +1,13 @@ +いや~今日のテストわからなくて苦労したよ +わからなくても大丈夫さ +大丈夫なんてお前たちダメでしょう +しっかり勉強しないと偉くなれないよ +偉くなんてならなくてもいいよ +ぺらぺら言わないで早く勉強しなさい +お父さんはいつもうるさいね~ +いいか言うこと聞かないと怒るぞ +でも今日のテストのプリントどこにやったかわからないんだもの +わからないなんてきちんとさがして勉強しなさい +勉強の前にご飯食べさせて +たくさん食べなさい +はい食べます \ No newline at end of file diff --git a/shonaiben_translator.rb b/shonaiben_translator.rb new file mode 100644 index 0000000..18ce909 --- /dev/null +++ b/shonaiben_translator.rb @@ -0,0 +1,44 @@ +#!/usr/koeki/bin/ruby +# -*- coding: utf-8 -*- + +def levenshtein(string1, string2, memo={}) # レーベンシュタイン距離を計算するメソッド + return memo[[string1, string2]] if memo[[string1, string2]] + return string2.size if string1.empty? + return string1.size if string2.empty? + return levenshtein(string1[1..], string2[1..], memo) if string1[0] == string2[0] + min_dist = 1 + [levenshtein(string1[1..], string2, memo), + levenshtein(string1, string2[1..], memo), + levenshtein(string1[1..], string2[1..], memo) + ].min + memo[[string1, string2]] = min_dist + min_dist +end + +source = File.readlines("shounaiben.txt") # 庄内弁の文章をファイルから読み込み、配列に保存 +candidates = File.readlines("kyoutsuugo.txt") # 共通語の訳文をファイルから読み込み、配列に保存 + +i = 0 +while i < source.length # 庄内弁の文章ごとに同じ処理を繰り返す + dist2target = levenshtein(source[i].chomp, candidates[i].chomp) # 正解訳文への編集距離の計算 + min_dist = dist2target # 最短編集距離の初期値(=正解訳文への編集距離) + count_same_or_lower = 0 # 編集距離が正解への距離以下である文章の総数の初期値 + best_cand = candidates[i].chomp # 最短編集距離の訳文の初期値(=正解訳文) + for cand in candidates # それぞれの共通語の文章への編集距離を調べる + dist = levenshtein(source[i].chomp, cand.chomp) + if dist < min_dist + min_dist = dist + best_cand = cand + end + if dist <= dist2target + count_same_or_lower += 1 + end + end + printf("庄内弁の文章: %s\n", source[i].chomp) + printf("共通語の訳文(正解): %s\n", candidates[i].chomp) + printf("最短編集距離の訳文: %s\n", best_cand.chomp) + printf("正解訳文への編集距離: %d\n", dist2target) + printf("最短編集距離: %d\n", min_dist) + printf("編集距離が正解訳文への距離以下である文章の総数: %d\n", count_same_or_lower) + puts + i += 1 +end \ No newline at end of file diff --git a/shounaiben.txt b/shounaiben.txt new file mode 100644 index 0000000..8266081 --- /dev/null +++ b/shounaiben.txt @@ -0,0 +1,13 @@ +いや~今日のテストわがらねぐでよいでねけ~ +わがらねたってなんでもね~ +なんでもでねんでろおめだだめだんねあんが +ちゃんと勉強しねど偉ぐならんねさげの~ +偉ぐなんてなんねぐてもいさげ +しゃべっちょこいでねでちゃっちゃど勉強せ +だだはいっつもやがましちゃ +いがの~言うごど聞がねどごげっぞ +したって今日のテストのプリントどごさやたがわがらねもの~ +わがらねどちゃんとさがして勉強せ +勉強の前さままかせでくれ +ほれいっぺけ~ +せばく~ \ No newline at end of file diff --git a/syoukai.rb b/syoukai.rb new file mode 100644 index 0000000..ab3b206 --- /dev/null +++ b/syoukai.rb @@ -0,0 +1,5 @@ +#/usr/bin/env ruby +# -*- coding: utf-8 -*- +print("ピコン!") +print("こんにちは!\n") + diff --git "a/\351\203\275\351\201\223\345\272\234\347\234\214" "b/\351\203\275\351\201\223\345\272\234\347\234\214" new file mode 100755 index 0000000..0fc84d0 --- /dev/null +++ "b/\351\203\275\351\201\223\345\272\234\347\234\214" @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# -*- coding: utf-8 -*- +puts "ピコン!" +puts"どの都道府県の情報を知りたいですか?" +while trus +print "都道府県を入力" +kotae = gets.chomp.to._i +if kotae == 1 +puts"1は,,," +redo +elsif kotae == 2 +puts"2は,,," +redo +else +puts"?" +redo