diff --git "a/.~lock.J2419-\345\205\265\350\227\244 \346\235\217-12-21.odp\043" "b/.~lock.J2419-\345\205\265\350\227\244 \346\235\217-12-21.odp\043" new file mode 100644 index 0000000..4e48cce --- /dev/null +++ "b/.~lock.J2419-\345\205\265\350\227\244 \346\235\217-12-21.odp\043" @@ -0,0 +1 @@ +,j2419,jd.koeki-u.ac.jp,14.12.2024 15:29,file:///home/j2419/.config/libreoffice/4; \ No newline at end of file diff --git "a/J2419-\345\205\265\350\227\244 \346\235\217-12-21.odp" "b/J2419-\345\205\265\350\227\244 \346\235\217-12-21.odp" new file mode 100644 index 0000000..40090b7 --- /dev/null +++ "b/J2419-\345\205\265\350\227\244 \346\235\217-12-21.odp" Binary files differ diff --git a/kozin.rb b/kozin.rb new file mode 100644 index 0000000..1cf8d55 --- /dev/null +++ b/kozin.rb @@ -0,0 +1,45 @@ +import random + +word_list = [ + {"word":"apple","meaning":"りんご"}, + {"word":"book":"meaning":"本"}, + {"word":"cat":"meaning":"猫"}, + {"word":"dog":"meaning":"犬"}, + {"word":"elephant":"meaning"}, +] + +def quiz(): + print("英単語クイズを始めます!") + score = 0 + + for i in range(5): + question = +random.choice(word_list) + print(f"問題{i+1}: +{question['meaning']}は英語でなんといいますか?") + answer = input("答え:").strip() + if answr.lower() == +question['word'].lower() + print("正解!") + score +=1 + else: + print(f"あなたのスコアは {score}/5 点でした!") +def mani(): + while True: + print("\n=== 英語学習プログラム ===") + print("1.クイズをする") + print("2.単語を追加する") + print("3.終了する") + choice = input("選択肢を入力してください: ").strip() + + if choice == "1": + quzi() + elif choice == "2": + add_word() + elif choice == "3": + print("プログラムを終了します。お疲れ様でした!") + break + else: + print("無効な入力です。再試行してください。") +if __name__ == "__main__": + main() 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