This commit is contained in:
Jakub Pokrywka 2022-02-22 14:34:59 +01:00
parent a16acc0027
commit 225a0414fd
2 changed files with 893 additions and 118 deletions

View File

@ -7,19 +7,12 @@
"![Logo 1](https://git.wmi.amu.edu.pl/AITech/Szablon/raw/branch/master/Logotyp_AITech1.jpg)\n",
"<div class=\"alert alert-block alert-info\">\n",
"<h1> Ekstrakcja informacji </h1>\n",
"<h2> 0. <i>Język</i> [ćwiczenia]</h2> \n",
"<h2> 0. <i>Kodowanie tekstu</i> [ćwiczenia]</h2> \n",
"<h3> Jakub Pokrywka (2022)</h3>\n",
"</div>\n",
"\n",
"![Logo 2](https://git.wmi.amu.edu.pl/AITech/Szablon/raw/branch/master/Logotyp_AITech2.jpg)"
]
},
{
"cell_type": "code",
"execution_count": 278,
"metadata": {},
"outputs": [],
"source": [
"![Logo 2](https://git.wmi.amu.edu.pl/AITech/Szablon/raw/branch/master/Logotyp_AITech2.jpg)\n",
"\n",
"NR_INDEKSU = 375985"
]
},
@ -34,7 +27,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Kodowanie"
"## Kodowanie znaku na bity"
]
},
{
@ -51,7 +44,7 @@
},
{
"cell_type": "code",
"execution_count": 279,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
@ -60,7 +53,7 @@
},
{
"cell_type": "code",
"execution_count": 280,
"execution_count": 3,
"metadata": {},
"outputs": [
{
@ -69,7 +62,7 @@
"10755"
]
},
"execution_count": 280,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
@ -80,7 +73,7 @@
},
{
"cell_type": "code",
"execution_count": 281,
"execution_count": 4,
"metadata": {},
"outputs": [
{
@ -89,7 +82,7 @@
"'⨃'"
]
},
"execution_count": 281,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
@ -100,7 +93,7 @@
},
{
"cell_type": "code",
"execution_count": 282,
"execution_count": 5,
"metadata": {},
"outputs": [
{
@ -109,7 +102,7 @@
"0"
]
},
"execution_count": 282,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
@ -128,7 +121,7 @@
},
{
"cell_type": "code",
"execution_count": 283,
"execution_count": 6,
"metadata": {},
"outputs": [
{
@ -137,7 +130,7 @@
"0"
]
},
"execution_count": 283,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
@ -155,7 +148,7 @@
},
{
"cell_type": "code",
"execution_count": 284,
"execution_count": 7,
"metadata": {},
"outputs": [
{
@ -164,7 +157,7 @@
"14"
]
},
"execution_count": 284,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
@ -175,7 +168,7 @@
},
{
"cell_type": "code",
"execution_count": 285,
"execution_count": 8,
"metadata": {},
"outputs": [
{
@ -184,7 +177,7 @@
"'0010101000000011'"
]
},
"execution_count": 285,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
@ -209,7 +202,7 @@
},
{
"cell_type": "code",
"execution_count": 286,
"execution_count": 9,
"metadata": {},
"outputs": [
{
@ -218,7 +211,7 @@
"'11100010 10101000 10000011'"
]
},
"execution_count": 286,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
@ -229,7 +222,7 @@
},
{
"cell_type": "code",
"execution_count": 287,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
@ -238,7 +231,7 @@
},
{
"cell_type": "code",
"execution_count": 288,
"execution_count": 11,
"metadata": {},
"outputs": [
{
@ -255,7 +248,7 @@
},
{
"cell_type": "code",
"execution_count": 289,
"execution_count": 12,
"metadata": {},
"outputs": [
{
@ -272,7 +265,7 @@
},
{
"cell_type": "code",
"execution_count": 290,
"execution_count": 13,
"metadata": {},
"outputs": [
{
@ -281,7 +274,7 @@
"'\\x0c'"
]
},
"execution_count": 290,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
@ -294,21 +287,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## ZADANIE SAMODZIELNE 1 ( 10 punktów)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- 2 ostatnie cyfry indeksu\n",
"- 3 ostatnie cyfy indeksu\n",
"- (5 ostatnich cyfr indeksu ) odjąć 123"
"### ZADANIE SAMODZIELNE 1 ( 10 punktów)\n",
"\n",
"Zakoduj poniższe znaki na bity wykonując niezbędne oblicznia"
]
},
{
"cell_type": "code",
"execution_count": 291,
"execution_count": 14,
"metadata": {},
"outputs": [
{
@ -317,7 +303,7 @@
"'U'"
]
},
"execution_count": 291,
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
@ -328,7 +314,7 @@
},
{
"cell_type": "code",
"execution_count": 292,
"execution_count": 15,
"metadata": {},
"outputs": [
{
@ -337,7 +323,7 @@
"'ϙ'"
]
},
"execution_count": 292,
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
@ -348,7 +334,7 @@
},
{
"cell_type": "code",
"execution_count": 293,
"execution_count": 16,
"metadata": {},
"outputs": [
{
@ -357,7 +343,7 @@
"'\\U00012856'"
]
},
"execution_count": 293,
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
@ -367,17 +353,29 @@
]
},
{
"cell_type": "code",
"execution_count": 294,
"cell_type": "markdown",
"metadata": {},
"source": [
"#### START ZADANIA"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### KONIEC ZADANIA"
]
},
{
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": [
"### Jakie są zakresy znaków?"
]
},
{
"cell_type": "code",
"execution_count": 295,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
@ -398,7 +396,7 @@
},
{
"cell_type": "code",
"execution_count": 296,
"execution_count": 18,
"metadata": {},
"outputs": [
{
@ -421,12 +419,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## ZADANIE SAMODZIELNE 2 ( 10 punktów)"
"## ZADANIE SAMODZIELNE 2 ( 10 punktów)\n",
"\n",
"Zamień poniższy ciąg binarny na tekst UTF-8. Jeżeli tekst nie zaczyna się od prawidłowego bitu/bitów należy je pominąć."
]
},
{
"cell_type": "code",
"execution_count": 297,
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
@ -435,7 +435,7 @@
},
{
"cell_type": "code",
"execution_count": 298,
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
@ -444,7 +444,7 @@
},
{
"cell_type": "code",
"execution_count": 299,
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
@ -453,8 +453,10 @@
},
{
"cell_type": "code",
"execution_count": 300,
"metadata": {},
"execution_count": 22,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
@ -462,7 +464,7 @@
"'00101100 00001010 01001010 01100001 01101011 00100000 01100010 01111001 11000101 10000010 00100000 01010011 01110100 01100101 01100110 01100101 01101011 00100000 01000010 01110101 01110010 01100011 01111010 01111001 01101101 01110101 01100011 01101000 01100001 11100010 10000000 10100110 00001010 11100010 10000000 10010100 00100000 01001010 01100001 00100000 01101110 01101001 01101011 01101111 01100111 01101111 00100000 01110011 01101001 11000100 10011001 00100000 01101110 01101001 01100101 00100000 01100010 01101111 01101010 11000100 10011001 00100001 00001010 01000011 01101000 01101111 11000100 10000111 01100010 01111001 00100000 01101110 01101001 01100101 01100100 11000101 10111010 01110111 01101001 01100101 01100100 11000101 10111010 11100010 10000000 10100110 00100000 01110100'"
]
},
"execution_count": 300,
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
@ -475,12 +477,28 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## ZADANIE SAMODZIELNE 3 ( 10 punktów)"
"#### START ZADANIA"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### KONIEC ZADANIA"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## ZADANIE SAMODZIELNE 3 ( 10 punktów)\n",
"\n",
"Zamień poniższy ciąg binarny na tekst UTF-8. Jeżeli tekst nie zaczyna się od prawidłowego bitu/bitów należy je pominąć."
]
},
{
"cell_type": "code",
"execution_count": 301,
"execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
@ -489,7 +507,7 @@
},
{
"cell_type": "code",
"execution_count": 302,
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
@ -498,7 +516,7 @@
},
{
"cell_type": "code",
"execution_count": 303,
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
@ -507,8 +525,10 @@
},
{
"cell_type": "code",
"execution_count": 273,
"metadata": {},
"execution_count": 26,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
@ -516,7 +536,7 @@
"'0x2e 0x20 0x31 0x36 0x37 0x30 0x2c 0x20 0x70 0x72 0x7a 0x65 0x64 0x20 0x75 0x70 0x61 0x64 0x6b 0x69 0x65 0x6d 0x20 0x4b 0x61 0x6d 0x69 0x65 0xc5 0x84 0x63 0x61 0x20 0x69 0x20 0x68 0x61 0x6e 0x69 0x65 0x62 0x6e 0x79 0x6d 0x69 0x20 0x75 0x6b 0xc5 0x82 0x61 0x64 0x61 0x6d 0x69 0x20 0x62 0x75 0x63 0x7a 0x61 0x63 0x6b 0x69 0x6d 0x69 0x2c 0x20 0x6b 0x74 0xc3 0xb3 0x72 0x65 0x20 0x6f 0x62 0x6f 0x77 0x69 0xc4 0x85 0x7a 0x79 0x77 0x61 0xc5 0x82'"
]
},
"execution_count": 273,
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
@ -529,66 +549,104 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## ZADANIE SAMODZIELNE 4 (10 punktów)"
"#### START ZADANIA"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"zabrać pliki a.txt i b.txt łącząć je spacją\n",
"\n",
"tylko linijki gdzie nie ma cyfr z numeru indeksu, \n",
"\n",
"usunąć wszystkie litery 'a',\n",
"\n",
"zamienić wszystkie litery 'c' na literę d\n",
"\n",
"potroić każde wystąpienie litery e (małe i wielkie)\n",
"\n",
"posortować linijki od końca\n",
"\n",
"zabrać tylko linjki od piatej do piątej od końca\n",
"\n",
"zapisać do pliku a.txt\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"pipe, paste, sed, awk, tr, grep, head, tail, cut, echo, redirect"
"#### KONIEC ZADANIA"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## ZADANIE SAMODZIELNE 5 (10 punktów)"
"## ZADANIE SAMODZIELNE 4 (5 punktów)"
]
},
{
"cell_type": "code",
"execution_count": 317,
"cell_type": "markdown",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['a', 'aa']"
]
},
"execution_count": 317,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sorted(['aa','a'])"
"Wykonaj następujące operacje w jednym bashowym/shellowym pipelinie:\n",
"\n",
"- scal a.txt i b.txt łącząc je spacją (tak, że pierwszy wiersz a.txt i pierwszy wiersz b.txt są połaczone spacją w nowy wiersz, drugi wiersz a.txt i drugi wiersz b.txt są połaczone spacją w następny wiersz, itp.) \n",
"\n",
"- wyfiltruj tylko linijki gdzie nie ma cyfr z Twojego numeru indeksu\n",
"\n",
"- usuń wszystkie litery 'a',\n",
"\n",
"- zamień wszystkie litery 'c' na literę 'd'\n",
"\n",
"- potrój każde wystąpienie litery e (małe i wielkie)\n",
"\n",
"- przestaw kolejność wiersz od końca (ostatni wiersz jest pierwszym, przedostani drugim, itp.)\n",
"\n",
"- wyfiltruj linijki od piątej do szóstej od końca (wg nowej kolejności)\n",
"\n",
"- zapisz pliku c.txt\n",
"\n",
"\n",
"Następnie wyprintuj zawartość pliku c.txt do tego notebooka\n",
"\n",
"\n",
"\n",
"Możesz użyć nastepujących programów: pipe, paste, sed, awk, tr, grep, head, tail, cut, echo, redirect. Nie używaj pythona, perla, ani innych podobnych języków."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### START ZADANIA"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### KONIEC ZADANIA"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## ZADANIE SAMODZIELNE 5 (5 punktów)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Napisz funkcję sortującą dla stringów, która będzie działać \n",
"\n",
"- sortujemy słowa zgodnie z polskim alfabetem\n",
"- jeżeli są małe litery i wielkie to wielkie przed małymi\n",
"- jeżeli wyraz `x` jest początkiem wyrazu `y`, to wyraz `x` ma być pierwszy\n"
]
},
{
"cell_type": "code",
"execution_count": 329,
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
"przykladowa_lista = ['ą', 'a','b','cef', 'ce', 'A','Ą', 'ż', ]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"tak nie chcemy:"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
@ -597,32 +655,40 @@
"['A', 'a', 'b', 'ce', 'cef', 'Ą', 'ą', 'ż']"
]
},
"execution_count": 329,
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sorted(['ą', 'a','b','cef', 'ce', 'A','Ą', 'ż', ])"
"sorted(przykladowa_lista)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- usuwamy słowa, które nie są składają sie wyłacznie z polskiego alfabetu\n",
"- najpierw zgodnie z polskim alfabetem\n",
"- jeżeli są małe litery i wielkie to wielkie przed małymi\n",
"- jeżeli wyraz `x` jest początkiem wyrazu `y`, to wyraz `x` ma być pierwszy\n"
"tak chcemy:"
]
},
{
"cell_type": "code",
"execution_count": 327,
"execution_count": 29,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"['A', 'Ą', 'a', 'ą', 'b', 'ce', 'cef', 'ż']"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"expected = ['A', 'Ą', 'a', 'ą' ,'b', 'ce', 'cef', 'ż']"
"['A', 'Ą', 'a', 'ą' ,'b', 'ce', 'cef', 'ż']"
]
},
{
@ -633,11 +699,32 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": []
"source": [
"#### START ZADANIA"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### KONIEC ZADANIA"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## WYKONANIE ZADAŃ\n",
"\n",
"- skopiuj niniejszy notebook\n",
"- podmień wartość zmiennej NR_INDEKSU na własny numer indeksu\n",
"- zadania wykonaj w tym jupyterze- dodawaj własne komórki tylko miedzy komórkami START ZADANIA, a KONIEC ZADANIA\n",
"- Zadania wykonaj tak, żeby po kliknięciu w Kernel → Restart & Run All notebook wykonał się bez błędów\n",
"- następnie wygeneruj z notebooka PDF (File → Download As → PDF via Latex).\n",
"- notebook z kodem oraz PDF zamieść w zakładce zadań w MS TEAMS"
]
}
],
"metadata": {

File diff suppressed because one or more lines are too long