finished second 2 ipynb

This commit is contained in:
Adam Stelmaszyk 2024-04-13 14:23:30 +02:00
parent 22d22f8f7f
commit e343070e32

View File

@ -57,7 +57,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 22,
"id": "confident-prison", "id": "confident-prison",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -80,25 +80,44 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 43,
"id": "continental-submission", "id": "continental-submission",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"data": {
"text/plain": [
"['The printer is switched off',\n",
" 'Check the network settings',\n",
" 'System restart required']"
]
},
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"\n",
"def ice_lookup(sentence, prev_sentence, next_sentence):\n", "def ice_lookup(sentence, prev_sentence, next_sentence):\n",
" sentence = sentence.lower()\n",
" prev_sentence = prev_sentence.lower()\n",
" next_sentence = next_sentence.lower()\n",
" for index in range(len(translation_memory)):\n", " for index in range(len(translation_memory)):\n",
" if index == 0:\n", " if index == 0:\n",
" if len(translation_memory) > 1:\n", " continue\n",
" if sentence == translation_memory[index] and next_sentence == translation_memory[index+1]:\n", " elif index + 1 >= len(translation_memory):\n",
" return True\n", " return []\n",
" else if sentence == translation_memory[index]:\n", " else:\n",
" return True\n", " middleText = translation_memory[index]\n",
" \n", " prevText = translation_memory[index-1]\n",
" \n", " nextText = translation_memory[index+1]\n",
" # return [entry[1] for entry in translation_memory if entry[0] == sentence]" " if(sentence == middleText[0] and prev_sentence == prevText[0] and next_sentence == nextText[0]):\n",
" return [middleText[1], prevText[1], nextText[1]]\n",
" \n",
" return []\n",
" \n",
"\n",
" \n",
" \n",
"ice_lookup('Drukarka jest wyłączona','Sprawdź ustawienia sieciowe','Wymagane ponowne uruchomienie komputera') \n"
] ]
}, },
{ {
@ -131,7 +150,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 44,
"id": "fourth-pillow", "id": "fourth-pillow",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -153,7 +172,7 @@
"id": "graduate-theorem", "id": "graduate-theorem",
"metadata": {}, "metadata": {},
"source": [ "source": [
"Odpowiedź:" "Odpowiedź: Tak, Spełnia warunki dla 1,2,3,4, "
] ]
}, },
{ {
@ -191,7 +210,7 @@
"id": "metallic-leave", "id": "metallic-leave",
"metadata": {}, "metadata": {},
"source": [ "source": [
"Odpowiedź:" "Odpowiedź: Nie, Spełnia dla warunku 3, poniewaz x = 4, y = 4, to wychodzi d(x,y) = 3, a nie 0"
] ]
}, },
{ {
@ -235,7 +254,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 45,
"id": "secondary-wrist", "id": "secondary-wrist",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -245,7 +264,7 @@
"2" "2"
] ]
}, },
"execution_count": 5, "execution_count": 45,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -266,7 +285,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 46,
"id": "associate-tuner", "id": "associate-tuner",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -285,7 +304,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": 47,
"id": "focal-pathology", "id": "focal-pathology",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -295,7 +314,7 @@
"0.9166666666666666" "0.9166666666666666"
] ]
}, },
"execution_count": 7, "execution_count": 47,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -306,7 +325,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": 48,
"id": "roman-ceiling", "id": "roman-ceiling",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -316,7 +335,7 @@
"0.9428571428571428" "0.9428571428571428"
] ]
}, },
"execution_count": 8, "execution_count": 48,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -327,7 +346,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": 49,
"id": "invisible-cambodia", "id": "invisible-cambodia",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -337,7 +356,7 @@
"0.631578947368421" "0.631578947368421"
] ]
}, },
"execution_count": 9, "execution_count": 49,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -356,13 +375,26 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": 51,
"id": "genetic-cradle", "id": "genetic-cradle",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"data": {
"text/plain": [
"['Press the ENTER button']"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"def fuzzy_lookup(sentence, threshold):\n", "def fuzzy_lookup(sentence, threshold):\n",
" return []" " return [entry[1] for entry in translation_memory if levenshtein_similarity(entry[0],sentence ) > threshold]\n",
"\n",
"fuzzy_lookup('Wciśnij przycisk Enter', 0.5)"
] ]
} }
], ],
@ -385,7 +417,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.8.10" "version": "3.11.7"
}, },
"subtitle": "2. Zaawansowane użycie pamięci tłumaczeń", "subtitle": "2. Zaawansowane użycie pamięci tłumaczeń",
"title": "Komputerowe wspomaganie tłumaczenia", "title": "Komputerowe wspomaganie tłumaczenia",