Compare commits
No commits in common. "master" and "0c23da0e153573ae78d2f7407931a2eaa92aa6a0" have entirely different histories.
master
...
0c23da0e15
349
README.md
349
README.md
@ -1,11 +1,6 @@
|
|||||||
|
|
||||||
## Zajęcia 1
|
## Zajęcia 1
|
||||||
|
|
||||||
Copyright AMU Poznan
|
|
||||||
|
|
||||||
Made by multiple people
|
|
||||||
|
|
||||||
|
|
||||||
### Informacje na temat przedmiotu
|
### Informacje na temat przedmiotu
|
||||||
|
|
||||||
Prowadzący: Jacek Kałużny
|
Prowadzący: Jacek Kałużny
|
||||||
@ -23,3 +18,347 @@ W ten sposób będziemy aktualizować zadania co zajęcia.
|
|||||||
Zadania robimy do końca soboty poprzedzającej zajęcia
|
Zadania robimy do końca soboty poprzedzającej zajęcia
|
||||||
|
|
||||||
Rozwiązanie zapisujemy w pliku run.py
|
Rozwiązanie zapisujemy w pliku run.py
|
||||||
|
|
||||||
|
|
||||||
|
## Zajęcia 2 Wyrażenia regularne
|
||||||
|
|
||||||
|
Dokumentacja wyrażeń regularnych w python3: https://docs.python.org/3/library/re.html
|
||||||
|
|
||||||
|
### Podstawowe funkcje
|
||||||
|
|
||||||
|
search - zwraca pierwsze dopasowanie w napisie
|
||||||
|
|
||||||
|
findall - zwraca listę wszystkich dopasowań (nienakładających się na siebie)
|
||||||
|
|
||||||
|
match - zwraca dopasowanie od początku string
|
||||||
|
|
||||||
|
To tylko podstawowe funkcje, z których będziemy korzystać. W dokumentacji opisane są wszystkie.
|
||||||
|
|
||||||
|
### Obiekt match
|
||||||
|
|
||||||
|
```
|
||||||
|
import re
|
||||||
|
answer = re.search('na','banan')
|
||||||
|
print(answer)
|
||||||
|
print(answer.start())
|
||||||
|
print(answer.end())
|
||||||
|
print(answer.group())
|
||||||
|
|
||||||
|
answer = re.search('na','kabanos')
|
||||||
|
print(answer)
|
||||||
|
type(answer)
|
||||||
|
|
||||||
|
if answer:
|
||||||
|
print(answer.group())
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
```
|
||||||
|
|
||||||
|
### Metaznaki
|
||||||
|
|
||||||
|
|
||||||
|
- [] - zbiór znaków
|
||||||
|
- . - jakikolwiek znak
|
||||||
|
|
||||||
|
- ^ - początek napisu
|
||||||
|
- $ - koniec napisu
|
||||||
|
|
||||||
|
- ? - znak występuje lub nie występuje
|
||||||
|
- \* - zero albo więcej pojawień się
|
||||||
|
- \+ - jeden albo więcej pojawień się
|
||||||
|
- {} - dokładnie tyle pojawień się
|
||||||
|
|
||||||
|
- | - lub
|
||||||
|
- () - grupa
|
||||||
|
- \ -znak ucieczki
|
||||||
|
|
||||||
|
- \d digit
|
||||||
|
- \D nie digit
|
||||||
|
- \s whitespace
|
||||||
|
- \S niewhitespace
|
||||||
|
|
||||||
|
|
||||||
|
### Flagi
|
||||||
|
|
||||||
|
Można użyć specjalnych flag, np:
|
||||||
|
`re.search('ma', 'AlA Ma KoTa', re.IGNORECASE)`.
|
||||||
|
|
||||||
|
### Przykłady (objaśnienia na laboratoriach)
|
||||||
|
|
||||||
|
Do nauki lepiej użyć pythona w wersji interaktywnej, a najlepiej ipython.
|
||||||
|
|
||||||
|
```
|
||||||
|
import re
|
||||||
|
|
||||||
|
text = 'Ala ma kota i hamak, oraz 150 bananów.'
|
||||||
|
|
||||||
|
re.search('ma',text)
|
||||||
|
re.match('ma',text)
|
||||||
|
re.match('Ala ma',text)
|
||||||
|
re.findall('ma',text)
|
||||||
|
|
||||||
|
re.findall('[mn]a',text)
|
||||||
|
re.findall('[0-9]',text)
|
||||||
|
re.findall('[0-9abc]',text)
|
||||||
|
re.findall('[a-z][a-z]ma[a-z]',text)
|
||||||
|
re.findall('[a-zA-Z][a-zA-Z]ma[a-zA-z0-9]',text)
|
||||||
|
re.findall('\d',text)
|
||||||
|
|
||||||
|
re.search('[0-9][0-9][0-9]',text)
|
||||||
|
re.search('[\d][\d][\d]',text)
|
||||||
|
|
||||||
|
re.search('\d{2}',text)
|
||||||
|
re.search('\d{3}',text)
|
||||||
|
|
||||||
|
re.search('\d+',text)
|
||||||
|
|
||||||
|
re.search('\d+ bananów',text)
|
||||||
|
re.search('\d* bananów','Ala ma dużo bananów')
|
||||||
|
re.search('\d* bananów',text)
|
||||||
|
re.search('ma \d? bananów','Ala ma 5 bananów')
|
||||||
|
re.search('ma ?\d? bananów','Ala ma bananów')
|
||||||
|
re.search('ma( \d)? bananów','Ala ma bananów')
|
||||||
|
|
||||||
|
re.search('\d+ bananów','Ala ma 10 bananów albo 20 bananów')
|
||||||
|
re.search('\d+ bananów$','Ala ma 10 bananów albo 20 bananów')
|
||||||
|
|
||||||
|
text = 'Ala ma kota i hamak, oraz 150 bananów.'
|
||||||
|
|
||||||
|
re.search('\d+ bananów',text)
|
||||||
|
|
||||||
|
re.search('\d+\sbananów',text)
|
||||||
|
|
||||||
|
re.search('kota . hamak',text)
|
||||||
|
|
||||||
|
re.search('kota . hamak','Ala ma kota z hamakiem')
|
||||||
|
|
||||||
|
re.search('kota .* hamak','Ala ma kota lub hamak')
|
||||||
|
|
||||||
|
re.search('\.',text)
|
||||||
|
|
||||||
|
re.search('kota|psa','Ala ma kota lub hamak')
|
||||||
|
|
||||||
|
re.findall('kota|psa','Ala ma kota lub psa')
|
||||||
|
|
||||||
|
re.search('kota (i|lub) psa','Ala ma kota lub psa')
|
||||||
|
|
||||||
|
re.search('mam (kota).*(kota|psa)','Ja mam kota. Ala ma psa.').group(0)
|
||||||
|
|
||||||
|
re.search('mam (kota).*(kota|psa)','Ja mam kota. Ala ma psa.').group(1)
|
||||||
|
|
||||||
|
re.search('mam (kota).*(kota|psa)','Ja mam kota. Ala ma psa.').group(2)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Przykłady wyrażenia regularne 2 (objaśnienia na laboratoriach)
|
||||||
|
|
||||||
|
#### ^
|
||||||
|
```
|
||||||
|
re.search('[0-9]+', '123-456-789')
|
||||||
|
re.search('[^0-9][0-9]+[^0-9]', '123-456-789')
|
||||||
|
```
|
||||||
|
|
||||||
|
#### cudzysłów
|
||||||
|
'' oraz "" - oznaczają to samo w pythonie
|
||||||
|
|
||||||
|
' ala ma psa o imieniu "Burek"'
|
||||||
|
|
||||||
|
" ala ma psa o imieniu 'Burek' "
|
||||||
|
|
||||||
|
' ala ma psa o imieniu \'Burek\' '
|
||||||
|
|
||||||
|
" ala ma psa o imieniu \"Burek\" "
|
||||||
|
|
||||||
|
#### multiline string
|
||||||
|
|
||||||
|
#### raw string
|
||||||
|
|
||||||
|
przy raw string znaki \ traktowane są jako zwykłe znaki \
|
||||||
|
|
||||||
|
chociaż nawet w raw string nadal są escapowane (ale wtedy \ pozostają również w stringu bez zmian)
|
||||||
|
|
||||||
|
https://docs.python.org/3/reference/lexical_analysis.html
|
||||||
|
|
||||||
|
dobra praktyka - wszędzie escapować
|
||||||
|
|
||||||
|
```
|
||||||
|
'\\'
|
||||||
|
print('\\')
|
||||||
|
|
||||||
|
r'\\'
|
||||||
|
print(r'\\')
|
||||||
|
|
||||||
|
|
||||||
|
print("abcd")
|
||||||
|
print("ab\cd")
|
||||||
|
print(r"ab\cd")
|
||||||
|
|
||||||
|
print("ab\nd")
|
||||||
|
print(r"ab\nd")
|
||||||
|
|
||||||
|
|
||||||
|
print("\"")
|
||||||
|
print(r"\"")
|
||||||
|
|
||||||
|
print("\")
|
||||||
|
print(r"\")
|
||||||
|
|
||||||
|
re.search('\\', r'a\bc')
|
||||||
|
re.search(r'\\', r'a\bc')
|
||||||
|
re.search('\\\\', r'a\bc')
|
||||||
|
```
|
||||||
|
|
||||||
|
#### RE SUB
|
||||||
|
```
|
||||||
|
re.sub(pattern, replacement, string)
|
||||||
|
|
||||||
|
re.sub('a','b', 'ala ma kota')
|
||||||
|
```
|
||||||
|
|
||||||
|
#### backreferencje:
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
re.search(r' \d+ \d+', 'ala ma 41 41 kota')
|
||||||
|
re.search(r' \d+ \d+', 'ala ma 41 123 kota')
|
||||||
|
re.search(r' (\d+) \1', 'ala ma 41 41 kota')
|
||||||
|
re.search(r' (\d+) \1', 'ala ma 41 123 kota')
|
||||||
|
```
|
||||||
|
|
||||||
|
#### lookahead ( to sa takie assercje):
|
||||||
|
```
|
||||||
|
re.search(r'ma kot', 'ala ma kot')
|
||||||
|
re.search(r'ma kot(?=[ay])', 'ala ma kot')
|
||||||
|
re.search(r'ma kot(?=[ay])', 'ala ma kotka')
|
||||||
|
re.search(r'ma kot(?=[ay])', 'ala ma koty')
|
||||||
|
re.search(r'ma kot(?=[ay])', 'ala ma kota')
|
||||||
|
|
||||||
|
re.search(r'ma kot(?![ay])', 'ala ma kot')
|
||||||
|
re.search(r'ma kot(?![ay])', 'ala ma kotka')
|
||||||
|
re.search(r'ma kot(?![ay])', 'ala ma koty')
|
||||||
|
re.search(r'ma kot(?![ay])', 'ala ma kota')
|
||||||
|
```
|
||||||
|
|
||||||
|
#### named groups
|
||||||
|
```
|
||||||
|
r = re.search(r'ma (?P<ilepsow>\d+) kotow i (?P<ilekotow>\d+) psow', 'ala ma 100 kotow i 200 psow')
|
||||||
|
r.groups()
|
||||||
|
r.groups('ilepsow')
|
||||||
|
r.groups('ilekotow')
|
||||||
|
```
|
||||||
|
|
||||||
|
#### re.split
|
||||||
|
```
|
||||||
|
('a,b.c,d').split(',')
|
||||||
|
('a,b.c,d').split(',')
|
||||||
|
('a,b.c,d').split(',.')
|
||||||
|
re.split(r',', 'a,b.c,d')
|
||||||
|
re.split(r'[.,]', 'a,b.c,d')
|
||||||
|
```
|
||||||
|
#### \w word character
|
||||||
|
```
|
||||||
|
\w - matchuje Unicod word character , jeżeli flaga ASCII to [a-zA-Z0-9_]
|
||||||
|
\w - odwrotne do \W, jezeli flaga ASCI to [^a-zA-Z0-9_]
|
||||||
|
|
||||||
|
re.findall(r'\w+', 'ala ma 3 koty.')
|
||||||
|
re.findall(r'\W+', 'ala ma 3 koty.')
|
||||||
|
```
|
||||||
|
#### początek albo koniec słowa | word boundary
|
||||||
|
```
|
||||||
|
re.search(r'\bkot\b', 'Ala ma kota')
|
||||||
|
re.search(r'\bkot\b', 'Ala ma kot')
|
||||||
|
re.search(r'\bkot\b', 'Ala ma kot.')
|
||||||
|
re.search(r'\bkot\b', 'Ala ma kot ')
|
||||||
|
|
||||||
|
re.search(r'\Bot\B', 'Ala ma kot ')
|
||||||
|
re.search(r'\Bot\B', 'Ala ma kota ')
|
||||||
|
```
|
||||||
|
#### MULTILINE
|
||||||
|
```
|
||||||
|
re.findall(r'^Ma', 'Ma kota Ala\nMa psa Jacek')
|
||||||
|
re.findall(r'^Ma', 'Ma kota Ala\nMa psa Jacek', re.MULTILINE)
|
||||||
|
```
|
||||||
|
#### RE.COMPILE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## zajęcia 6
|
||||||
|
|
||||||
|
instalacja https://pypi.org/project/google-re2/
|
||||||
|
|
||||||
|
### DFA i NDFA
|
||||||
|
|
||||||
|
```
|
||||||
|
import re2 as re
|
||||||
|
n = 50
|
||||||
|
regexp = "a?"*n+"a"*n
|
||||||
|
s = "a"*n
|
||||||
|
re.match(regexp, s)
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
re.match(r"(\d)abc\1", "3abc3") # re2 nie obsługuje backreferencji
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
re2 max memory - podniesienie limitu
|
||||||
|
time # mierzenie czasu działania
|
||||||
|
|
||||||
|
|
||||||
|
gdyby ktoś chciał poczytać więcej:
|
||||||
|
https://swtch.com/~rsc/regexp/regexp1.html
|
||||||
|
|
||||||
|
### UTF-8
|
||||||
|
```
|
||||||
|
c = "ℋ"
|
||||||
|
ord(c)
|
||||||
|
chr(8459)
|
||||||
|
8* 16**2 + 0 * 16**(1) + 0*16**(0)
|
||||||
|
15*16**3 + 15* 16**2 + 15 * 16**(1) + 15*16**(0)
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
xxd -b file
|
||||||
|
xxd file
|
||||||
|
```
|
||||||
|
|
||||||
|
termin oddawania zadań - 15. listopada
|
||||||
|
|
||||||
|
|
||||||
|
## Zajęcia 7
|
||||||
|
https://www.openfst.org/twiki/bin/view/GRM/Thrax
|
||||||
|
|
||||||
|
https://www.cs.jhu.edu/~jason/465/hw-ofst/hw-ofst.pdf
|
||||||
|
|
||||||
|
Wszystkie zadania proszę robić na wzór `TaskH00`. Proszę umieszczać gramatykę w pliku `grammar.grm` oraz
|
||||||
|
opisywać finalną regułę nazwą `FinalRule`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## KOLOKWIUM
|
||||||
|
Operatory, obowiązujące na kolokwium
|
||||||
|
====================================
|
||||||
|
|
||||||
|
* kwantyfikatory `-` `*` `+` `?` `{n}` `{n,}` `{n, m}`
|
||||||
|
* alternatywa — `|`
|
||||||
|
* klasy znaków — `[...]`
|
||||||
|
* zanegowane klasy znaków — `[^...]`
|
||||||
|
* dowolny znak — `.`
|
||||||
|
* unieważnianie znaków specjalnych — \
|
||||||
|
* operatory zakotwiczające — `^` `$`
|
||||||
|
|
||||||
|
|
||||||
|
Na kolokwium do każdego z 4 pytań będą 3 podpunkty. Na każdy podpunkt odpowiadamy TAK/NIE. Czas trwania to 15 minut.
|
||||||
|
|
||||||
|
- zawsze daszek i dolar
|
||||||
|
- nie bierzemy pod uwagę capturing (jeżeli są pytania o równoważne)
|
||||||
|
- proponuję wydrukować cały test w wersji bez opdowiedzi i sprawdzać
|
||||||
|
|
||||||
|
|
||||||
|
Do zaliczenia należy zdobyć conajmniej 10 punktów.
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
def contains_word(to_be_checked: str, word: str) -> bool:
|
|
||||||
word_len: int = len(word)
|
|
||||||
word_character_number: int = 0
|
|
||||||
for c in to_be_checked:
|
|
||||||
if c != word[word_character_number]:
|
|
||||||
word_character_number = 0
|
|
||||||
continue
|
|
||||||
if word_character_number == word_len - 1:
|
|
||||||
return True
|
|
||||||
word_character_number += 1
|
|
||||||
return False
|
|
||||||
|
|
||||||
file = open('shakespeare.exp', 'r', encoding='utf8')
|
|
||||||
result = []
|
|
||||||
line_number = 0
|
|
||||||
for line in file:
|
|
||||||
if contains_word(line, 'Hamlet'):
|
|
||||||
result.append(line_number)
|
|
||||||
line_number += 1
|
|
||||||
print(result)
|
|
@ -1,62 +0,0 @@
|
|||||||
class Machine:
|
|
||||||
_state: int = 0
|
|
||||||
|
|
||||||
def consume_character(self, char: str) -> None:
|
|
||||||
if self._state == 0:
|
|
||||||
if char == 'P' or char == 'p':
|
|
||||||
self._state = 1
|
|
||||||
else:
|
|
||||||
self._state = 6
|
|
||||||
elif self._state == 1:
|
|
||||||
if char == 'I' or char == 'i':
|
|
||||||
self._state = 2
|
|
||||||
else:
|
|
||||||
self._state = 6
|
|
||||||
elif self._state == 2:
|
|
||||||
if char == 'E' or char == 'e':
|
|
||||||
self._state = 3
|
|
||||||
else:
|
|
||||||
self._state = 6
|
|
||||||
elif self._state == 3:
|
|
||||||
if char == 'S' or char == 's':
|
|
||||||
self._state = 4
|
|
||||||
else:
|
|
||||||
self._state = 6
|
|
||||||
elif self._state == 4:
|
|
||||||
if char == '\n' or char == ' ' or char == '\t' or char == '\r':
|
|
||||||
self._state = 5
|
|
||||||
else:
|
|
||||||
self._state = 6
|
|
||||||
elif self._state == 6:
|
|
||||||
if char == ' ' or char == '\t':
|
|
||||||
self._state = 0
|
|
||||||
|
|
||||||
def is_success_state(self) -> bool:
|
|
||||||
return self._state == 5
|
|
||||||
|
|
||||||
def restart(self) -> None:
|
|
||||||
self._state = 0
|
|
||||||
|
|
||||||
def find_lines_with_pies(text: str) -> list[int]:
|
|
||||||
output: list[int] = []
|
|
||||||
line_number = 0
|
|
||||||
machine = Machine()
|
|
||||||
for char in text:
|
|
||||||
machine.consume_character(char)
|
|
||||||
if char == '\n':
|
|
||||||
if machine.is_success_state():
|
|
||||||
output.append(line_number)
|
|
||||||
machine.restart()
|
|
||||||
line_number += 1
|
|
||||||
if machine.is_success_state():
|
|
||||||
output.append(line_number)
|
|
||||||
line_number += 1
|
|
||||||
return output
|
|
||||||
|
|
||||||
|
|
||||||
text: str = None
|
|
||||||
with open('polish_wiki_excerpt.exp', 'r', encoding='utf8') as file:
|
|
||||||
text = file.read()
|
|
||||||
|
|
||||||
result = find_lines_with_pies(text)
|
|
||||||
print(result)
|
|
@ -1,70 +0,0 @@
|
|||||||
class Machine:
|
|
||||||
_state: int = 0
|
|
||||||
|
|
||||||
def consume_character(self, char: str) -> None:
|
|
||||||
if self._state == 0:
|
|
||||||
if char == '1':
|
|
||||||
self._state = 1
|
|
||||||
else:
|
|
||||||
self._state = 0
|
|
||||||
elif self._state == 1:
|
|
||||||
if char == '9':
|
|
||||||
self._state = 2
|
|
||||||
else:
|
|
||||||
self._state = 0
|
|
||||||
elif self._state == 2:
|
|
||||||
if char == '1' or char == '2' or char == '3' or char == '4' or char == '5' or char == '6' or char == '7' or char == '8' or char == '9':
|
|
||||||
self._state = 3
|
|
||||||
else:
|
|
||||||
self._state = 0
|
|
||||||
elif self._state == 3:
|
|
||||||
if char == '1' or char == '2' or char == '3' or char == '4' or char == '5' or char == '6' or char == '7' or char == '8' or char == '9':
|
|
||||||
self._state = 4
|
|
||||||
else:
|
|
||||||
self._state = 0
|
|
||||||
elif self._state == 4:
|
|
||||||
if char == ' ':
|
|
||||||
self._state = 5
|
|
||||||
else:
|
|
||||||
self._state = 0
|
|
||||||
elif self._state == 5:
|
|
||||||
if char == 'r':
|
|
||||||
self._state = 6
|
|
||||||
else:
|
|
||||||
self._state = 0
|
|
||||||
elif self._state == 6:
|
|
||||||
if char == '.':
|
|
||||||
self._state = 7
|
|
||||||
else:
|
|
||||||
self._state = 0
|
|
||||||
|
|
||||||
|
|
||||||
def is_success_state(self) -> bool:
|
|
||||||
return self._state == 7
|
|
||||||
|
|
||||||
def restart(self) -> None:
|
|
||||||
self._state = 0
|
|
||||||
|
|
||||||
def find_lines_with_date(text: str) -> list[int]:
|
|
||||||
output: list[int] = []
|
|
||||||
line_number = 0
|
|
||||||
machine = Machine()
|
|
||||||
for char in text:
|
|
||||||
machine.consume_character(char)
|
|
||||||
if char == '\n':
|
|
||||||
if machine.is_success_state():
|
|
||||||
output.append(line_number)
|
|
||||||
machine.restart()
|
|
||||||
line_number += 1
|
|
||||||
if machine.is_success_state():
|
|
||||||
output.append(line_number)
|
|
||||||
line_number += 1
|
|
||||||
return output
|
|
||||||
|
|
||||||
|
|
||||||
text: str = None
|
|
||||||
with open('polish_wiki_excerpt.exp', 'r', encoding='utf8') as file:
|
|
||||||
text = file.read()
|
|
||||||
|
|
||||||
result = find_lines_with_date(text)
|
|
||||||
print(result)
|
|
@ -1,51 +0,0 @@
|
|||||||
class Machine:
|
|
||||||
_state: int = 0
|
|
||||||
_current_digital_substring: str = ''
|
|
||||||
_results: list[str] = []
|
|
||||||
|
|
||||||
def consume_character(self, char: str) -> None:
|
|
||||||
if self._state == 0:
|
|
||||||
if self._is_digit(char):
|
|
||||||
self._state = 1
|
|
||||||
self._current_digital_substring += char
|
|
||||||
elif not self._is_separator(char):
|
|
||||||
self.state = 2
|
|
||||||
elif self._state == 1:
|
|
||||||
if self._is_digit(char):
|
|
||||||
self._current_digital_substring += char
|
|
||||||
elif not self._is_separator(char):
|
|
||||||
self.state = 2
|
|
||||||
self._current_digital_substring = ''
|
|
||||||
else:
|
|
||||||
self.finish()
|
|
||||||
elif self._state == 2:
|
|
||||||
if self._is_separator(char):
|
|
||||||
self.state = 0
|
|
||||||
|
|
||||||
def _is_separator(self, char) -> bool:
|
|
||||||
return char == '\n' or char == ' ' or char == '\t'
|
|
||||||
|
|
||||||
def _is_digit(self, char: str) -> bool:
|
|
||||||
return char == '1' or char == '2' or char == '3' or char == '4' or char == '5' or char == '6' or char == '7' or char == '8' or char == '9'
|
|
||||||
|
|
||||||
def finish(self) -> None:
|
|
||||||
if self._current_digital_substring != '':
|
|
||||||
self._results.append(self._current_digital_substring)
|
|
||||||
self._current_digital_substring = ''
|
|
||||||
self._state = 0
|
|
||||||
|
|
||||||
def get_results(self) -> list[int]:
|
|
||||||
return self._results
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
text: str = None
|
|
||||||
with open('simple.exp', 'r', encoding='utf8') as file:
|
|
||||||
text = file.read()
|
|
||||||
|
|
||||||
machine = Machine()
|
|
||||||
for c in text:
|
|
||||||
machine.consume_character(c)
|
|
||||||
machine.finish()
|
|
||||||
|
|
||||||
print(machine.get_results())
|
|
@ -1,8 +0,0 @@
|
|||||||
Read a description of a deterministic finite-state automaton in the AT&T format
|
|
||||||
(without weights) from the file in the first argument.
|
|
||||||
|
|
||||||
Read strings from the standard input.
|
|
||||||
If a string is accepted by the
|
|
||||||
automaton, write YES, otherwise- write NO.
|
|
||||||
|
|
||||||
The program is invoked like this: ./run.py fsa_description.arg < test1.in > test1.out
|
|
@ -1,16 +0,0 @@
|
|||||||
0 1 x
|
|
||||||
1 2 y
|
|
||||||
2 3 z
|
|
||||||
0 4 y
|
|
||||||
0 4 z
|
|
||||||
1 4 x
|
|
||||||
1 4 z
|
|
||||||
2 4 x
|
|
||||||
2 4 y
|
|
||||||
3 4 x
|
|
||||||
3 4 y
|
|
||||||
3 4 z
|
|
||||||
4 4 x
|
|
||||||
4 4 y
|
|
||||||
4 4 z
|
|
||||||
3
|
|
@ -1,36 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import pandas as pd
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def automat_fun(recursive_df: pd.DataFrame):
|
|
||||||
first_row = recursive_df.iloc[0]
|
|
||||||
recursive_df = recursive_df.iloc[1:,:]
|
|
||||||
return lambda char, state: first_row[1] if state == first_row[0] and char == first_row[2] else automat_fun(recursive_df)(char, state)
|
|
||||||
|
|
||||||
def create_automat_from_file(file_path: str):
|
|
||||||
df = pd.read_csv(file_path, sep='\t', header=None)
|
|
||||||
accept_state = df.tail(1).iloc[0, 0]
|
|
||||||
df = df.iloc[:-1,:]
|
|
||||||
return accept_state, automat_fun(df)
|
|
||||||
|
|
||||||
file_path = os.path.join(os.path.dirname(__file__), 'fsa_description.arg')
|
|
||||||
accept_state, automat_function = create_automat_from_file(file_path)
|
|
||||||
|
|
||||||
input_file_path = os.path.join(os.path.dirname(__file__), 'test1.in')
|
|
||||||
output_file_path = os.path.join(os.path.dirname(__file__), 'test1.out')
|
|
||||||
results: list[str] = []
|
|
||||||
|
|
||||||
with open(input_file_path, 'r', encoding='utf8') as input_file:
|
|
||||||
for line in input_file:
|
|
||||||
state = 0
|
|
||||||
for c in line:
|
|
||||||
if c == '\n':
|
|
||||||
continue
|
|
||||||
state = automat_function(c, state)
|
|
||||||
results.append('YES\n' if state == accept_state else 'NO\n')
|
|
||||||
|
|
||||||
|
|
||||||
with open(output_file_path, 'w') as output_file:
|
|
||||||
output_file.writelines(results)
|
|
@ -1,9 +0,0 @@
|
|||||||
NO
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
@ -1,9 +0,0 @@
|
|||||||
xxyz
|
|
||||||
xyz
|
|
||||||
xy
|
|
||||||
zz
|
|
||||||
xxy
|
|
||||||
yzx
|
|
||||||
|
|
||||||
x
|
|
||||||
xyzz
|
|
@ -1,9 +0,0 @@
|
|||||||
NO
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
@ -1,10 +0,0 @@
|
|||||||
Use a deterministic finite-state automaton (FSA) engine from the TaskE00.
|
|
||||||
Create your own FSA description to check whether the string starts with "01" and ends with "01.
|
|
||||||
Save it to fsa_description.arg file.
|
|
||||||
|
|
||||||
The alphabet is "0", "1".
|
|
||||||
|
|
||||||
Read strings from the standard input.
|
|
||||||
If a string is accepted by the
|
|
||||||
automaton, write YES, otherwise- write NO.
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
|||||||
0 4 1
|
|
||||||
4 4 0
|
|
||||||
4 4 1
|
|
||||||
0 1 0
|
|
||||||
1 4 0
|
|
||||||
1 2 1
|
|
||||||
2 3 0
|
|
||||||
2 3 1
|
|
||||||
3 3 0
|
|
||||||
3 2 1
|
|
||||||
2
|
|
@ -1,29 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import pandas as pd
|
|
||||||
import os
|
|
||||||
|
|
||||||
def automat_fun(recursive_df: pd.DataFrame):
|
|
||||||
first_row = recursive_df.iloc[0]
|
|
||||||
recursive_df = recursive_df.iloc[1:,:]
|
|
||||||
return lambda char, state: first_row[1] if state == first_row[0] and char == first_row[2] else automat_fun(recursive_df)(char, state)
|
|
||||||
|
|
||||||
def create_automat_from_file(file_path: str):
|
|
||||||
df = pd.read_csv(file_path, sep=' ', header=None)
|
|
||||||
accept_state = df.tail(1).iloc[0, 0]
|
|
||||||
df = df.iloc[:-1,:]
|
|
||||||
return accept_state, automat_fun(df)
|
|
||||||
|
|
||||||
file_path = os.path.join(os.path.dirname(__file__), 'fsa_description.arg')
|
|
||||||
accept_state, automat_function = create_automat_from_file(file_path)
|
|
||||||
|
|
||||||
txt = input('Write binary sequence: ')
|
|
||||||
|
|
||||||
while txt != 'exit':
|
|
||||||
state = 0
|
|
||||||
for c in txt:
|
|
||||||
if (c == '\n'):
|
|
||||||
break
|
|
||||||
state = automat_function(int(c), state)
|
|
||||||
print('YES' if state == accept_state else "NO")
|
|
||||||
txt = input('Write binary sequence: ')
|
|
@ -1,14 +0,0 @@
|
|||||||
YES
|
|
||||||
NO
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
@ -1,14 +0,0 @@
|
|||||||
01
|
|
||||||
10
|
|
||||||
0101
|
|
||||||
1010
|
|
||||||
011101
|
|
||||||
101010
|
|
||||||
100010
|
|
||||||
0100001
|
|
||||||
|
|
||||||
00110
|
|
||||||
0000
|
|
||||||
10101
|
|
||||||
0
|
|
||||||
1
|
|
@ -1,9 +0,0 @@
|
|||||||
Use a deterministic finite-state automaton (FSA) engine from the TaskE00.
|
|
||||||
Create your own FSA description to check whether the string starts with "10" and ends with "10.
|
|
||||||
Save it to fsa_description.arg file.
|
|
||||||
|
|
||||||
The alphabet is "0", "1".
|
|
||||||
|
|
||||||
Read strings from the standard input.
|
|
||||||
If a string is accepted by the
|
|
||||||
automaton, write YES, otherwise- write NO.
|
|
@ -1,11 +0,0 @@
|
|||||||
0 4 0
|
|
||||||
4 4 1
|
|
||||||
4 4 0
|
|
||||||
0 1 1
|
|
||||||
1 4 1
|
|
||||||
1 2 0
|
|
||||||
2 3 1
|
|
||||||
2 3 0
|
|
||||||
3 3 1
|
|
||||||
3 2 0
|
|
||||||
2
|
|
@ -1,29 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import pandas as pd
|
|
||||||
import os
|
|
||||||
|
|
||||||
def automat_fun(recursive_df: pd.DataFrame):
|
|
||||||
first_row = recursive_df.iloc[0]
|
|
||||||
recursive_df = recursive_df.iloc[1:,:]
|
|
||||||
return lambda char, state: first_row[1] if state == first_row[0] and char == first_row[2] else automat_fun(recursive_df)(char, state)
|
|
||||||
|
|
||||||
def create_automat_from_file(file_path: str):
|
|
||||||
df = pd.read_csv(file_path, sep=' ', header=None)
|
|
||||||
accept_state = df.tail(1).iloc[0, 0]
|
|
||||||
df = df.iloc[:-1,:]
|
|
||||||
return accept_state, automat_fun(df)
|
|
||||||
|
|
||||||
file_path = os.path.join(os.path.dirname(__file__), 'fsa_description.arg')
|
|
||||||
accept_state, automat_function = create_automat_from_file(file_path)
|
|
||||||
|
|
||||||
txt = input('Write binary sequence: ')
|
|
||||||
|
|
||||||
while txt != 'exit':
|
|
||||||
state = 0
|
|
||||||
for c in txt:
|
|
||||||
if (c == '\n'):
|
|
||||||
break
|
|
||||||
state = automat_function(int(c), state)
|
|
||||||
print('YES' if state == accept_state else "NO")
|
|
||||||
txt = input('Write binary sequence: ')
|
|
@ -1,14 +0,0 @@
|
|||||||
NO
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
YES
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
@ -1,14 +0,0 @@
|
|||||||
01
|
|
||||||
10
|
|
||||||
0101
|
|
||||||
1010
|
|
||||||
011101
|
|
||||||
101010
|
|
||||||
100010
|
|
||||||
0100001
|
|
||||||
|
|
||||||
00110
|
|
||||||
0000
|
|
||||||
10101
|
|
||||||
0
|
|
||||||
1
|
|
@ -1,11 +0,0 @@
|
|||||||
Use a deterministic finite-state automaton (FSA) engine from the TaskE00.
|
|
||||||
Create your own FSA description to check whether the string contains "0"
|
|
||||||
even number of times.
|
|
||||||
Save it to fsa_description.arg file.
|
|
||||||
|
|
||||||
The alphabet is "0", "1".
|
|
||||||
|
|
||||||
Read strings from the standard input.
|
|
||||||
If a string is accepted by the
|
|
||||||
automaton, write YES, otherwise- write NO.
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
|||||||
0 1 0
|
|
||||||
1 0 0
|
|
||||||
0 0 1
|
|
||||||
1 1 1
|
|
||||||
0
|
|
@ -1,29 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import pandas as pd
|
|
||||||
import os
|
|
||||||
|
|
||||||
def automat_fun(recursive_df: pd.DataFrame):
|
|
||||||
first_row = recursive_df.iloc[0]
|
|
||||||
recursive_df = recursive_df.iloc[1:,:]
|
|
||||||
return lambda char, state: first_row[1] if state == first_row[0] and char == first_row[2] else automat_fun(recursive_df)(char, state)
|
|
||||||
|
|
||||||
def create_automat_from_file(file_path: str):
|
|
||||||
df = pd.read_csv(file_path, sep=' ', header=None)
|
|
||||||
accept_state = df.tail(1).iloc[0, 0]
|
|
||||||
df = df.iloc[:-1,:]
|
|
||||||
return accept_state, automat_fun(df)
|
|
||||||
|
|
||||||
file_path = os.path.join(os.path.dirname(__file__), 'fsa_description.arg')
|
|
||||||
accept_state, automat_function = create_automat_from_file(file_path)
|
|
||||||
|
|
||||||
txt = input('Write binary sequence: ')
|
|
||||||
|
|
||||||
while txt != 'exit':
|
|
||||||
state = 0
|
|
||||||
for c in txt:
|
|
||||||
if (c == '\n'):
|
|
||||||
break
|
|
||||||
state = automat_function(int(c), state)
|
|
||||||
print('YES' if state == accept_state else "NO")
|
|
||||||
txt = input('Write binary sequence: ')
|
|
@ -1,14 +0,0 @@
|
|||||||
NO
|
|
||||||
NO
|
|
||||||
YES
|
|
||||||
YES
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
YES
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
YES
|
|
@ -1,14 +0,0 @@
|
|||||||
01
|
|
||||||
10
|
|
||||||
0101
|
|
||||||
1010
|
|
||||||
011101
|
|
||||||
101010
|
|
||||||
100010
|
|
||||||
0100001
|
|
||||||
|
|
||||||
00110
|
|
||||||
0000
|
|
||||||
10101
|
|
||||||
0
|
|
||||||
1
|
|
@ -1,11 +0,0 @@
|
|||||||
Use a deterministic finite-state automaton (FSA) engine from the TaskE00.
|
|
||||||
Create your own FSA description to check whether the string contains "0"
|
|
||||||
odd number of times.
|
|
||||||
Save it to fsa_description.arg file.
|
|
||||||
|
|
||||||
The alphabet is "0", "1".
|
|
||||||
|
|
||||||
Read strings from the standard input.
|
|
||||||
If a string is accepted by the
|
|
||||||
automaton, write YES, otherwise- write NO.
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
|||||||
0 1 0
|
|
||||||
1 0 0
|
|
||||||
0 0 1
|
|
||||||
1 1 1
|
|
||||||
1
|
|
@ -1,29 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import pandas as pd
|
|
||||||
import os
|
|
||||||
|
|
||||||
def automat_fun(recursive_df: pd.DataFrame):
|
|
||||||
first_row = recursive_df.iloc[0]
|
|
||||||
recursive_df = recursive_df.iloc[1:,:]
|
|
||||||
return lambda char, state: first_row[1] if state == first_row[0] and char == first_row[2] else automat_fun(recursive_df)(char, state)
|
|
||||||
|
|
||||||
def create_automat_from_file(file_path: str):
|
|
||||||
df = pd.read_csv(file_path, sep=' ', header=None)
|
|
||||||
accept_state = df.tail(1).iloc[0, 0]
|
|
||||||
df = df.iloc[:-1,:]
|
|
||||||
return accept_state, automat_fun(df)
|
|
||||||
|
|
||||||
file_path = os.path.join(os.path.dirname(__file__), 'fsa_description.arg')
|
|
||||||
accept_state, automat_function = create_automat_from_file(file_path)
|
|
||||||
|
|
||||||
txt = input('Write binary sequence: ')
|
|
||||||
|
|
||||||
while txt != 'exit':
|
|
||||||
state = 0
|
|
||||||
for c in txt:
|
|
||||||
if (c == '\n'):
|
|
||||||
break
|
|
||||||
state = automat_function(int(c), state)
|
|
||||||
print('YES' if state == accept_state else "NO")
|
|
||||||
txt = input('Write binary sequence: ')
|
|
@ -1,14 +0,0 @@
|
|||||||
YES
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
YES
|
|
||||||
NO
|
|
@ -1,14 +0,0 @@
|
|||||||
01
|
|
||||||
10
|
|
||||||
0101
|
|
||||||
1010
|
|
||||||
011101
|
|
||||||
101010
|
|
||||||
100010
|
|
||||||
0100001
|
|
||||||
|
|
||||||
00110
|
|
||||||
0000
|
|
||||||
10101
|
|
||||||
0
|
|
||||||
1
|
|
@ -1,10 +0,0 @@
|
|||||||
Use a deterministic finite-state automaton (FSA) engine from the TaskB00.
|
|
||||||
Create your own FSA description to check whether the line contains string '19DD', where D is a digit.
|
|
||||||
Save it to fsa_description.arg file.
|
|
||||||
|
|
||||||
FSA alphabet is '0123456789x'.
|
|
||||||
|
|
||||||
Read strings from the standard input.
|
|
||||||
If a string is accepted by the
|
|
||||||
automaton, write YES, otherwise- write NO.
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
|||||||
0 1 1
|
|
||||||
1 2 9
|
|
||||||
2 3 0
|
|
||||||
2 3 1
|
|
||||||
2 3 2
|
|
||||||
2 3 3
|
|
||||||
2 3 4
|
|
||||||
2 3 5
|
|
||||||
2 3 6
|
|
||||||
2 3 7
|
|
||||||
2 3 8
|
|
||||||
2 3 9
|
|
||||||
3 4 0
|
|
||||||
3 4 1
|
|
||||||
3 4 2
|
|
||||||
3 4 3
|
|
||||||
3 4 4
|
|
||||||
3 4 5
|
|
||||||
3 4 6
|
|
||||||
3 4 7
|
|
||||||
3 4 8
|
|
||||||
3 4 9
|
|
||||||
4 4 0
|
|
||||||
4 4 1
|
|
||||||
4 4 2
|
|
||||||
4 4 3
|
|
||||||
4 4 4
|
|
||||||
4 4 5
|
|
||||||
4 4 6
|
|
||||||
4 4 7
|
|
||||||
4 4 8
|
|
||||||
4 4 9
|
|
||||||
4 4 x
|
|
||||||
0 0 x
|
|
||||||
0 0 0
|
|
||||||
0 0 2
|
|
||||||
0 0 3
|
|
||||||
0 0 4
|
|
||||||
0 0 5
|
|
||||||
0 0 6
|
|
||||||
0 0 7
|
|
||||||
0 0 8
|
|
||||||
0 0 9
|
|
||||||
1 0 x
|
|
||||||
1 0 0
|
|
||||||
1 0 1
|
|
||||||
1 0 2
|
|
||||||
1 0 3
|
|
||||||
1 0 4
|
|
||||||
1 0 5
|
|
||||||
1 0 6
|
|
||||||
1 0 7
|
|
||||||
1 0 8
|
|
||||||
2 0 x
|
|
||||||
3 0 x
|
|
||||||
4
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -1,29 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import pandas as pd
|
|
||||||
import os
|
|
||||||
|
|
||||||
def automat_fun(recursive_df: pd.DataFrame):
|
|
||||||
first_row = recursive_df.iloc[0]
|
|
||||||
recursive_df = recursive_df.iloc[1:,:]
|
|
||||||
return lambda char, state: first_row[1] if state == first_row[0] and char == first_row[2] else automat_fun(recursive_df)(char, state)
|
|
||||||
|
|
||||||
def create_automat_from_file(file_path: str):
|
|
||||||
df = pd.read_csv(file_path, sep=' ', header=None)
|
|
||||||
accept_state = df.tail(1).iloc[0, 0]
|
|
||||||
df = df.iloc[:-1,:]
|
|
||||||
return accept_state, automat_fun(df)
|
|
||||||
|
|
||||||
file_path = os.path.join(os.path.dirname(__file__), 'fsa_description.arg')
|
|
||||||
accept_state, automat_function = create_automat_from_file(file_path)
|
|
||||||
|
|
||||||
txt = input('Write valid input: ')
|
|
||||||
|
|
||||||
while txt != 'exit':
|
|
||||||
state = 0
|
|
||||||
for c in txt:
|
|
||||||
if (c == '\n'):
|
|
||||||
break
|
|
||||||
state = automat_function(c, state)
|
|
||||||
print('YES' if state == accept_state else "NO")
|
|
||||||
txt = input('Write valid input: ')
|
|
@ -1,6 +0,0 @@
|
|||||||
NO
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
YES
|
|
||||||
YES
|
|
@ -1,6 +0,0 @@
|
|||||||
3214545443
|
|
||||||
1910
|
|
||||||
19
|
|
||||||
xxx2190x
|
|
||||||
xxx21905x
|
|
||||||
1905x54545
|
|
@ -1,9 +0,0 @@
|
|||||||
Use a deterministic finite-state automaton (FSA) engine from the previous task.
|
|
||||||
Create your own FSA description to check whether the word "hamlet" is in the given line.
|
|
||||||
Save it to fsa_description.arg file.
|
|
||||||
|
|
||||||
FSA alphabet is 'abcdefghijklmnopqrstuvwxyz '.
|
|
||||||
|
|
||||||
Read strings from the standard input.
|
|
||||||
If a string is accepted by the
|
|
||||||
automaton, write YES, otherwise- write NO.
|
|
@ -1,190 +0,0 @@
|
|||||||
0 0 a
|
|
||||||
1 2 a
|
|
||||||
2 0 a
|
|
||||||
3 0 a
|
|
||||||
4 0 a
|
|
||||||
5 0 a
|
|
||||||
6 6 a
|
|
||||||
0 0 b
|
|
||||||
1 0 b
|
|
||||||
2 0 b
|
|
||||||
3 0 b
|
|
||||||
4 0 b
|
|
||||||
5 0 b
|
|
||||||
6 6 b
|
|
||||||
0 0 c
|
|
||||||
1 0 c
|
|
||||||
2 0 c
|
|
||||||
3 0 c
|
|
||||||
4 0 c
|
|
||||||
5 0 c
|
|
||||||
6 6 c
|
|
||||||
0 0 d
|
|
||||||
1 0 d
|
|
||||||
2 0 d
|
|
||||||
3 0 d
|
|
||||||
4 0 d
|
|
||||||
5 0 d
|
|
||||||
6 6 d
|
|
||||||
0 0 e
|
|
||||||
1 0 e
|
|
||||||
2 0 e
|
|
||||||
3 0 e
|
|
||||||
4 5 e
|
|
||||||
5 0 e
|
|
||||||
6 6 e
|
|
||||||
0 0 f
|
|
||||||
1 0 f
|
|
||||||
2 0 f
|
|
||||||
3 0 f
|
|
||||||
4 0 f
|
|
||||||
5 0 f
|
|
||||||
6 6 f
|
|
||||||
0 0 g
|
|
||||||
1 0 g
|
|
||||||
2 0 g
|
|
||||||
3 0 g
|
|
||||||
4 0 g
|
|
||||||
5 0 g
|
|
||||||
6 6 g
|
|
||||||
0 1 h
|
|
||||||
1 0 h
|
|
||||||
2 0 h
|
|
||||||
3 0 h
|
|
||||||
4 0 h
|
|
||||||
5 0 h
|
|
||||||
6 6 h
|
|
||||||
0 0 i
|
|
||||||
1 0 i
|
|
||||||
2 0 i
|
|
||||||
3 0 i
|
|
||||||
4 0 i
|
|
||||||
5 0 i
|
|
||||||
6 6 i
|
|
||||||
0 0 j
|
|
||||||
1 0 j
|
|
||||||
2 0 j
|
|
||||||
3 0 j
|
|
||||||
4 0 j
|
|
||||||
5 0 j
|
|
||||||
6 6 j
|
|
||||||
0 0 k
|
|
||||||
1 0 k
|
|
||||||
2 0 k
|
|
||||||
3 0 k
|
|
||||||
4 0 k
|
|
||||||
5 0 k
|
|
||||||
6 6 k
|
|
||||||
0 0 l
|
|
||||||
1 0 l
|
|
||||||
2 0 l
|
|
||||||
3 4 l
|
|
||||||
4 0 l
|
|
||||||
5 0 l
|
|
||||||
6 6 l
|
|
||||||
0 0 m
|
|
||||||
1 0 m
|
|
||||||
2 3 m
|
|
||||||
3 0 m
|
|
||||||
4 0 m
|
|
||||||
5 0 m
|
|
||||||
6 6 m
|
|
||||||
0 0 n
|
|
||||||
1 0 n
|
|
||||||
2 0 n
|
|
||||||
3 0 n
|
|
||||||
4 0 n
|
|
||||||
5 0 n
|
|
||||||
6 6 n
|
|
||||||
0 0 o
|
|
||||||
1 0 o
|
|
||||||
2 0 o
|
|
||||||
3 0 o
|
|
||||||
4 0 o
|
|
||||||
5 0 o
|
|
||||||
6 6 o
|
|
||||||
0 0 p
|
|
||||||
1 0 p
|
|
||||||
2 0 p
|
|
||||||
3 0 p
|
|
||||||
4 0 p
|
|
||||||
5 0 p
|
|
||||||
6 6 p
|
|
||||||
0 0 q
|
|
||||||
1 0 q
|
|
||||||
2 0 q
|
|
||||||
3 0 q
|
|
||||||
4 0 q
|
|
||||||
5 0 q
|
|
||||||
6 6 q
|
|
||||||
0 0 r
|
|
||||||
1 0 r
|
|
||||||
2 0 r
|
|
||||||
3 0 r
|
|
||||||
4 0 r
|
|
||||||
5 0 r
|
|
||||||
6 6 r
|
|
||||||
0 0 s
|
|
||||||
1 0 s
|
|
||||||
2 0 s
|
|
||||||
3 0 s
|
|
||||||
4 0 s
|
|
||||||
5 0 s
|
|
||||||
6 6 s
|
|
||||||
0 0 t
|
|
||||||
1 0 t
|
|
||||||
2 0 t
|
|
||||||
3 0 t
|
|
||||||
4 0 t
|
|
||||||
5 6 t
|
|
||||||
6 6 t
|
|
||||||
0 0 u
|
|
||||||
1 0 u
|
|
||||||
2 0 u
|
|
||||||
3 0 u
|
|
||||||
4 0 u
|
|
||||||
5 0 u
|
|
||||||
6 6 u
|
|
||||||
0 0 v
|
|
||||||
1 0 v
|
|
||||||
2 0 v
|
|
||||||
3 0 v
|
|
||||||
4 0 v
|
|
||||||
5 0 v
|
|
||||||
6 6 v
|
|
||||||
0 0 w
|
|
||||||
1 0 w
|
|
||||||
2 0 w
|
|
||||||
3 0 w
|
|
||||||
4 0 w
|
|
||||||
5 0 w
|
|
||||||
6 6 w
|
|
||||||
0 0 x
|
|
||||||
1 0 x
|
|
||||||
2 0 x
|
|
||||||
3 0 x
|
|
||||||
4 0 x
|
|
||||||
5 0 x
|
|
||||||
6 6 x
|
|
||||||
0 0 y
|
|
||||||
1 0 y
|
|
||||||
2 0 y
|
|
||||||
3 0 y
|
|
||||||
4 0 y
|
|
||||||
5 0 y
|
|
||||||
6 6 y
|
|
||||||
0 0 z
|
|
||||||
1 0 z
|
|
||||||
2 0 z
|
|
||||||
3 0 z
|
|
||||||
4 0 z
|
|
||||||
5 0 z
|
|
||||||
6 6 z
|
|
||||||
0 0
|
|
||||||
1 0
|
|
||||||
2 0
|
|
||||||
3 0
|
|
||||||
4 0
|
|
||||||
5 0
|
|
||||||
6 6
|
|
||||||
6
|
|
@ -1,29 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import pandas as pd
|
|
||||||
import os
|
|
||||||
|
|
||||||
def automat_fun(recursive_df: pd.DataFrame):
|
|
||||||
first_row = recursive_df.iloc[0]
|
|
||||||
recursive_df = recursive_df.iloc[1:,:]
|
|
||||||
return lambda char, state: first_row[1] if state == first_row[0] and char == first_row[2] else automat_fun(recursive_df)(char, state)
|
|
||||||
|
|
||||||
def create_automat_from_file(file_path: str):
|
|
||||||
df = pd.read_csv(file_path, sep='\t', header=None)
|
|
||||||
accept_state = df.tail(1).iloc[0, 0]
|
|
||||||
df = df.iloc[:-1,:]
|
|
||||||
return accept_state, automat_fun(df)
|
|
||||||
|
|
||||||
file_path = os.path.join(os.path.dirname(__file__), 'fsa_description.arg')
|
|
||||||
accept_state, automat_function = create_automat_from_file(file_path)
|
|
||||||
|
|
||||||
txt = input('Write valid input: ')
|
|
||||||
|
|
||||||
while txt != 'exit':
|
|
||||||
state = 0
|
|
||||||
for c in txt:
|
|
||||||
if (c == '\n'):
|
|
||||||
break
|
|
||||||
state = automat_function(c, state)
|
|
||||||
print('YES' if state == accept_state else "NO")
|
|
||||||
txt = input('Write valid input: ')
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,3 +0,0 @@
|
|||||||
NO
|
|
||||||
YES
|
|
||||||
YES
|
|
@ -1,3 +0,0 @@
|
|||||||
haml
|
|
||||||
hamlet
|
|
||||||
aaahamletbbb
|
|
@ -1,10 +0,0 @@
|
|||||||
Use a deterministic finite-state automaton (FSA) engine from the previous task.
|
|
||||||
Create your own FSA description to check whether the word "ophelia" is in the given line.
|
|
||||||
Save it to fsa_description.arg file.
|
|
||||||
|
|
||||||
FSA alphabet is 'abcdefghijklmnopqrstuvwxyz '.
|
|
||||||
|
|
||||||
Read strings from the standard input.
|
|
||||||
If a string is accepted by the
|
|
||||||
automaton, write YES, otherwise- write NO.
|
|
||||||
|
|
@ -1,217 +0,0 @@
|
|||||||
0 0 a
|
|
||||||
1 0 a
|
|
||||||
2 0 a
|
|
||||||
3 0 a
|
|
||||||
4 0 a
|
|
||||||
5 0 a
|
|
||||||
6 7 a
|
|
||||||
7 7 a
|
|
||||||
0 0 b
|
|
||||||
1 0 b
|
|
||||||
2 0 b
|
|
||||||
3 0 b
|
|
||||||
4 0 b
|
|
||||||
5 0 b
|
|
||||||
6 0 b
|
|
||||||
7 7 b
|
|
||||||
0 0 c
|
|
||||||
1 0 c
|
|
||||||
2 0 c
|
|
||||||
3 0 c
|
|
||||||
4 0 c
|
|
||||||
5 0 c
|
|
||||||
6 0 c
|
|
||||||
7 7 c
|
|
||||||
0 0 d
|
|
||||||
1 0 d
|
|
||||||
2 0 d
|
|
||||||
3 0 d
|
|
||||||
4 0 d
|
|
||||||
5 0 d
|
|
||||||
6 0 d
|
|
||||||
7 7 d
|
|
||||||
0 0 e
|
|
||||||
1 0 e
|
|
||||||
2 0 e
|
|
||||||
3 4 e
|
|
||||||
4 0 e
|
|
||||||
5 0 e
|
|
||||||
6 0 e
|
|
||||||
7 7 e
|
|
||||||
0 0 f
|
|
||||||
1 0 f
|
|
||||||
2 0 f
|
|
||||||
3 0 f
|
|
||||||
4 0 f
|
|
||||||
5 0 f
|
|
||||||
6 0 f
|
|
||||||
7 7 f
|
|
||||||
0 0 g
|
|
||||||
1 0 g
|
|
||||||
2 0 g
|
|
||||||
3 0 g
|
|
||||||
4 0 g
|
|
||||||
5 0 g
|
|
||||||
6 0 g
|
|
||||||
7 7 g
|
|
||||||
0 0 h
|
|
||||||
1 0 h
|
|
||||||
2 3 h
|
|
||||||
3 0 h
|
|
||||||
4 0 h
|
|
||||||
5 0 h
|
|
||||||
6 0 h
|
|
||||||
7 7 h
|
|
||||||
0 0 i
|
|
||||||
1 0 i
|
|
||||||
2 0 i
|
|
||||||
3 0 i
|
|
||||||
4 0 i
|
|
||||||
5 6 i
|
|
||||||
6 0 i
|
|
||||||
7 7 i
|
|
||||||
0 0 j
|
|
||||||
1 0 j
|
|
||||||
2 0 j
|
|
||||||
3 0 j
|
|
||||||
4 0 j
|
|
||||||
5 0 j
|
|
||||||
6 0 j
|
|
||||||
7 7 j
|
|
||||||
0 0 k
|
|
||||||
1 0 k
|
|
||||||
2 0 k
|
|
||||||
3 0 k
|
|
||||||
4 0 k
|
|
||||||
5 0 k
|
|
||||||
6 0 k
|
|
||||||
7 7 k
|
|
||||||
0 0 l
|
|
||||||
1 0 l
|
|
||||||
2 0 l
|
|
||||||
3 0 l
|
|
||||||
4 5 l
|
|
||||||
5 0 l
|
|
||||||
6 0 l
|
|
||||||
7 7 l
|
|
||||||
0 0 m
|
|
||||||
1 0 m
|
|
||||||
2 0 m
|
|
||||||
3 0 m
|
|
||||||
4 0 m
|
|
||||||
5 0 m
|
|
||||||
6 0 m
|
|
||||||
7 7 m
|
|
||||||
0 0 n
|
|
||||||
1 0 n
|
|
||||||
2 0 n
|
|
||||||
3 0 n
|
|
||||||
4 0 n
|
|
||||||
5 0 n
|
|
||||||
6 0 n
|
|
||||||
7 7 n
|
|
||||||
0 1 o
|
|
||||||
1 0 o
|
|
||||||
2 0 o
|
|
||||||
3 0 o
|
|
||||||
4 0 o
|
|
||||||
5 0 o
|
|
||||||
6 0 o
|
|
||||||
7 7 o
|
|
||||||
0 0 p
|
|
||||||
1 2 p
|
|
||||||
2 0 p
|
|
||||||
3 0 p
|
|
||||||
4 0 p
|
|
||||||
5 0 p
|
|
||||||
6 0 p
|
|
||||||
7 7 p
|
|
||||||
0 0 q
|
|
||||||
1 0 q
|
|
||||||
2 0 q
|
|
||||||
3 0 q
|
|
||||||
4 0 q
|
|
||||||
5 0 q
|
|
||||||
6 0 q
|
|
||||||
7 7 q
|
|
||||||
0 0 r
|
|
||||||
1 0 r
|
|
||||||
2 0 r
|
|
||||||
3 0 r
|
|
||||||
4 0 r
|
|
||||||
5 0 r
|
|
||||||
6 0 r
|
|
||||||
7 7 r
|
|
||||||
0 0 s
|
|
||||||
1 0 s
|
|
||||||
2 0 s
|
|
||||||
3 0 s
|
|
||||||
4 0 s
|
|
||||||
5 0 s
|
|
||||||
6 0 s
|
|
||||||
7 7 s
|
|
||||||
0 0 t
|
|
||||||
1 0 t
|
|
||||||
2 0 t
|
|
||||||
3 0 t
|
|
||||||
4 0 t
|
|
||||||
5 0 t
|
|
||||||
6 0 t
|
|
||||||
7 7 t
|
|
||||||
0 0 u
|
|
||||||
1 0 u
|
|
||||||
2 0 u
|
|
||||||
3 0 u
|
|
||||||
4 0 u
|
|
||||||
5 0 u
|
|
||||||
6 0 u
|
|
||||||
7 7 u
|
|
||||||
0 0 v
|
|
||||||
1 0 v
|
|
||||||
2 0 v
|
|
||||||
3 0 v
|
|
||||||
4 0 v
|
|
||||||
5 0 v
|
|
||||||
6 0 v
|
|
||||||
7 7 v
|
|
||||||
0 0 w
|
|
||||||
1 0 w
|
|
||||||
2 0 w
|
|
||||||
3 0 w
|
|
||||||
4 0 w
|
|
||||||
5 0 w
|
|
||||||
6 0 w
|
|
||||||
7 7 w
|
|
||||||
0 0 x
|
|
||||||
1 0 x
|
|
||||||
2 0 x
|
|
||||||
3 0 x
|
|
||||||
4 0 x
|
|
||||||
5 0 x
|
|
||||||
6 0 x
|
|
||||||
7 7 x
|
|
||||||
0 0 y
|
|
||||||
1 0 y
|
|
||||||
2 0 y
|
|
||||||
3 0 y
|
|
||||||
4 0 y
|
|
||||||
5 0 y
|
|
||||||
6 0 y
|
|
||||||
7 7 y
|
|
||||||
0 0 z
|
|
||||||
1 0 z
|
|
||||||
2 0 z
|
|
||||||
3 0 z
|
|
||||||
4 0 z
|
|
||||||
5 0 z
|
|
||||||
6 0 z
|
|
||||||
7 7 z
|
|
||||||
0 0
|
|
||||||
1 0
|
|
||||||
2 0
|
|
||||||
3 0
|
|
||||||
4 0
|
|
||||||
5 0
|
|
||||||
6 0
|
|
||||||
7 7
|
|
||||||
7
|
|
@ -1,29 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import pandas as pd
|
|
||||||
import os
|
|
||||||
|
|
||||||
def automat_fun(recursive_df: pd.DataFrame):
|
|
||||||
first_row = recursive_df.iloc[0]
|
|
||||||
recursive_df = recursive_df.iloc[1:,:]
|
|
||||||
return lambda char, state: first_row[1] if state == first_row[0] and char == first_row[2] else automat_fun(recursive_df)(char, state)
|
|
||||||
|
|
||||||
def create_automat_from_file(file_path: str):
|
|
||||||
df = pd.read_csv(file_path, sep='\t', header=None)
|
|
||||||
accept_state = df.tail(1).iloc[0, 0]
|
|
||||||
df = df.iloc[:-1,:]
|
|
||||||
return accept_state, automat_fun(df)
|
|
||||||
|
|
||||||
file_path = os.path.join(os.path.dirname(__file__), 'fsa_description.arg')
|
|
||||||
accept_state, automat_function = create_automat_from_file(file_path)
|
|
||||||
|
|
||||||
txt = input('Write valid input: ')
|
|
||||||
|
|
||||||
while txt != 'exit':
|
|
||||||
state = 0
|
|
||||||
for c in txt:
|
|
||||||
if (c == '\n'):
|
|
||||||
break
|
|
||||||
state = automat_function(c, state)
|
|
||||||
print('YES' if state == accept_state else "NO")
|
|
||||||
txt = input('Write valid input: ')
|
|
File diff suppressed because it is too large
Load Diff
@ -1,3 +0,0 @@
|
|||||||
NO
|
|
||||||
YES
|
|
||||||
YES
|
|
@ -1,3 +0,0 @@
|
|||||||
oph
|
|
||||||
ophelia
|
|
||||||
xfdfdopheliafff
|
|
@ -1,10 +0,0 @@
|
|||||||
Use a deterministic finite-state automaton (FSA) engine from the previous task.
|
|
||||||
Create your own FSA description to check whether the word "juliet" is in the given line.
|
|
||||||
Save it to fsa_description.arg file.
|
|
||||||
|
|
||||||
FSA alphabet is 'abcdefghijklmnopqrstuvwxyz '.
|
|
||||||
|
|
||||||
Read strings from the standard input.
|
|
||||||
If a string is accepted by the
|
|
||||||
automaton, write YES, otherwise- write NO.
|
|
||||||
|
|
@ -1,190 +0,0 @@
|
|||||||
0 0 a
|
|
||||||
1 0 a
|
|
||||||
2 0 a
|
|
||||||
3 0 a
|
|
||||||
4 0 a
|
|
||||||
5 0 a
|
|
||||||
6 6 a
|
|
||||||
0 0 b
|
|
||||||
1 0 b
|
|
||||||
2 0 b
|
|
||||||
3 0 b
|
|
||||||
4 0 b
|
|
||||||
5 0 b
|
|
||||||
6 6 b
|
|
||||||
0 0 c
|
|
||||||
1 0 c
|
|
||||||
2 0 c
|
|
||||||
3 0 c
|
|
||||||
4 0 c
|
|
||||||
5 0 c
|
|
||||||
6 6 c
|
|
||||||
0 0 d
|
|
||||||
1 0 d
|
|
||||||
2 0 d
|
|
||||||
3 0 d
|
|
||||||
4 0 d
|
|
||||||
5 0 d
|
|
||||||
6 6 d
|
|
||||||
0 0 e
|
|
||||||
1 0 e
|
|
||||||
2 0 e
|
|
||||||
3 0 e
|
|
||||||
4 5 e
|
|
||||||
5 0 e
|
|
||||||
6 6 e
|
|
||||||
0 0 f
|
|
||||||
1 0 f
|
|
||||||
2 0 f
|
|
||||||
3 0 f
|
|
||||||
4 0 f
|
|
||||||
5 0 f
|
|
||||||
6 6 f
|
|
||||||
0 0 g
|
|
||||||
1 0 g
|
|
||||||
2 0 g
|
|
||||||
3 0 g
|
|
||||||
4 0 g
|
|
||||||
5 0 g
|
|
||||||
6 6 g
|
|
||||||
0 0 h
|
|
||||||
1 0 h
|
|
||||||
2 0 h
|
|
||||||
3 0 h
|
|
||||||
4 0 h
|
|
||||||
5 0 h
|
|
||||||
6 6 h
|
|
||||||
0 0 i
|
|
||||||
1 0 i
|
|
||||||
2 0 i
|
|
||||||
3 4 i
|
|
||||||
4 0 i
|
|
||||||
5 0 i
|
|
||||||
6 6 i
|
|
||||||
0 1 j
|
|
||||||
1 0 j
|
|
||||||
2 0 j
|
|
||||||
3 0 j
|
|
||||||
4 0 j
|
|
||||||
5 0 j
|
|
||||||
6 6 j
|
|
||||||
0 0 k
|
|
||||||
1 0 k
|
|
||||||
2 0 k
|
|
||||||
3 0 k
|
|
||||||
4 0 k
|
|
||||||
5 0 k
|
|
||||||
6 6 k
|
|
||||||
0 0 l
|
|
||||||
1 0 l
|
|
||||||
2 3 l
|
|
||||||
3 0 l
|
|
||||||
4 0 l
|
|
||||||
5 0 l
|
|
||||||
6 6 l
|
|
||||||
0 0 m
|
|
||||||
1 0 m
|
|
||||||
2 0 m
|
|
||||||
3 0 m
|
|
||||||
4 0 m
|
|
||||||
5 0 m
|
|
||||||
6 6 m
|
|
||||||
0 0 n
|
|
||||||
1 0 n
|
|
||||||
2 0 n
|
|
||||||
3 0 n
|
|
||||||
4 0 n
|
|
||||||
5 0 n
|
|
||||||
6 6 n
|
|
||||||
0 0 o
|
|
||||||
1 0 o
|
|
||||||
2 0 o
|
|
||||||
3 0 o
|
|
||||||
4 0 o
|
|
||||||
5 0 o
|
|
||||||
6 6 o
|
|
||||||
0 0 p
|
|
||||||
1 0 p
|
|
||||||
2 0 p
|
|
||||||
3 0 p
|
|
||||||
4 0 p
|
|
||||||
5 0 p
|
|
||||||
6 6 p
|
|
||||||
0 0 q
|
|
||||||
1 0 q
|
|
||||||
2 0 q
|
|
||||||
3 0 q
|
|
||||||
4 0 q
|
|
||||||
5 0 q
|
|
||||||
6 6 q
|
|
||||||
0 0 r
|
|
||||||
1 0 r
|
|
||||||
2 0 r
|
|
||||||
3 0 r
|
|
||||||
4 0 r
|
|
||||||
5 0 r
|
|
||||||
6 6 r
|
|
||||||
0 0 s
|
|
||||||
1 0 s
|
|
||||||
2 0 s
|
|
||||||
3 0 s
|
|
||||||
4 0 s
|
|
||||||
5 0 s
|
|
||||||
6 6 s
|
|
||||||
0 0 t
|
|
||||||
1 0 t
|
|
||||||
2 0 t
|
|
||||||
3 0 t
|
|
||||||
4 0 t
|
|
||||||
5 6 t
|
|
||||||
6 6 t
|
|
||||||
0 0 u
|
|
||||||
1 2 u
|
|
||||||
2 0 u
|
|
||||||
3 0 u
|
|
||||||
4 0 u
|
|
||||||
5 0 u
|
|
||||||
6 6 u
|
|
||||||
0 0 v
|
|
||||||
1 0 v
|
|
||||||
2 0 v
|
|
||||||
3 0 v
|
|
||||||
4 0 v
|
|
||||||
5 0 v
|
|
||||||
6 6 v
|
|
||||||
0 0 w
|
|
||||||
1 0 w
|
|
||||||
2 0 w
|
|
||||||
3 0 w
|
|
||||||
4 0 w
|
|
||||||
5 0 w
|
|
||||||
6 6 w
|
|
||||||
0 0 x
|
|
||||||
1 0 x
|
|
||||||
2 0 x
|
|
||||||
3 0 x
|
|
||||||
4 0 x
|
|
||||||
5 0 x
|
|
||||||
6 6 x
|
|
||||||
0 0 y
|
|
||||||
1 0 y
|
|
||||||
2 0 y
|
|
||||||
3 0 y
|
|
||||||
4 0 y
|
|
||||||
5 0 y
|
|
||||||
6 6 y
|
|
||||||
0 0 z
|
|
||||||
1 0 z
|
|
||||||
2 0 z
|
|
||||||
3 0 z
|
|
||||||
4 0 z
|
|
||||||
5 0 z
|
|
||||||
6 6 z
|
|
||||||
0 0
|
|
||||||
1 0
|
|
||||||
2 0
|
|
||||||
3 0
|
|
||||||
4 0
|
|
||||||
5 0
|
|
||||||
6 6
|
|
||||||
6
|
|
@ -1,29 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import pandas as pd
|
|
||||||
import os
|
|
||||||
|
|
||||||
def automat_fun(recursive_df: pd.DataFrame):
|
|
||||||
first_row = recursive_df.iloc[0]
|
|
||||||
recursive_df = recursive_df.iloc[1:,:]
|
|
||||||
return lambda char, state: first_row[1] if state == first_row[0] and char == first_row[2] else automat_fun(recursive_df)(char, state)
|
|
||||||
|
|
||||||
def create_automat_from_file(file_path: str):
|
|
||||||
df = pd.read_csv(file_path, sep='\t', header=None)
|
|
||||||
accept_state = df.tail(1).iloc[0, 0]
|
|
||||||
df = df.iloc[:-1,:]
|
|
||||||
return accept_state, automat_fun(df)
|
|
||||||
|
|
||||||
file_path = os.path.join(os.path.dirname(__file__), 'fsa_description.arg')
|
|
||||||
accept_state, automat_function = create_automat_from_file(file_path)
|
|
||||||
|
|
||||||
txt = input('Write valid input: ')
|
|
||||||
|
|
||||||
while txt != 'exit':
|
|
||||||
state = 0
|
|
||||||
for c in txt:
|
|
||||||
if (c == '\n'):
|
|
||||||
break
|
|
||||||
state = automat_function(c, state)
|
|
||||||
print('YES' if state == accept_state else "NO")
|
|
||||||
txt = input('Write valid input: ')
|
|
File diff suppressed because it is too large
Load Diff
@ -1,3 +0,0 @@
|
|||||||
NO
|
|
||||||
YES
|
|
||||||
YES
|
|
@ -1,3 +0,0 @@
|
|||||||
juli
|
|
||||||
juliet
|
|
||||||
dgfdgjulietaaa
|
|
@ -1,10 +0,0 @@
|
|||||||
Use a deterministic finite-state automaton (FSA) engine from the previous task.
|
|
||||||
Create your own FSA description to check whether the word "macbeth" is in the given line.
|
|
||||||
Save it to fsa_description.arg file.
|
|
||||||
|
|
||||||
FSA alphabet is 'abcdefghijklmnopqrstuvwxyz '.
|
|
||||||
|
|
||||||
Read strings from the standard input.
|
|
||||||
If a string is accepted by the
|
|
||||||
automaton, write YES, otherwise- write NO.
|
|
||||||
|
|
@ -1,217 +0,0 @@
|
|||||||
0 0 a
|
|
||||||
1 2 a
|
|
||||||
2 0 a
|
|
||||||
3 0 a
|
|
||||||
4 0 a
|
|
||||||
5 0 a
|
|
||||||
6 0 a
|
|
||||||
7 7 a
|
|
||||||
0 0 b
|
|
||||||
1 0 b
|
|
||||||
2 0 b
|
|
||||||
3 4 b
|
|
||||||
4 0 b
|
|
||||||
5 0 b
|
|
||||||
6 0 b
|
|
||||||
7 7 b
|
|
||||||
0 0 c
|
|
||||||
1 0 c
|
|
||||||
2 3 c
|
|
||||||
3 0 c
|
|
||||||
4 0 c
|
|
||||||
5 0 c
|
|
||||||
6 0 c
|
|
||||||
7 7 c
|
|
||||||
0 0 d
|
|
||||||
1 0 d
|
|
||||||
2 0 d
|
|
||||||
3 0 d
|
|
||||||
4 0 d
|
|
||||||
5 0 d
|
|
||||||
6 0 d
|
|
||||||
7 7 d
|
|
||||||
0 0 e
|
|
||||||
1 0 e
|
|
||||||
2 0 e
|
|
||||||
3 0 e
|
|
||||||
4 5 e
|
|
||||||
5 0 e
|
|
||||||
6 0 e
|
|
||||||
7 7 e
|
|
||||||
0 0 f
|
|
||||||
1 0 f
|
|
||||||
2 0 f
|
|
||||||
3 0 f
|
|
||||||
4 0 f
|
|
||||||
5 0 f
|
|
||||||
6 0 f
|
|
||||||
7 7 f
|
|
||||||
0 0 g
|
|
||||||
1 0 g
|
|
||||||
2 0 g
|
|
||||||
3 0 g
|
|
||||||
4 0 g
|
|
||||||
5 0 g
|
|
||||||
6 0 g
|
|
||||||
7 7 g
|
|
||||||
0 0 h
|
|
||||||
1 0 h
|
|
||||||
2 0 h
|
|
||||||
3 0 h
|
|
||||||
4 0 h
|
|
||||||
5 0 h
|
|
||||||
6 7 h
|
|
||||||
7 7 h
|
|
||||||
0 0 i
|
|
||||||
1 0 i
|
|
||||||
2 0 i
|
|
||||||
3 0 i
|
|
||||||
4 0 i
|
|
||||||
5 0 i
|
|
||||||
6 0 i
|
|
||||||
7 7 i
|
|
||||||
0 0 j
|
|
||||||
1 0 j
|
|
||||||
2 0 j
|
|
||||||
3 0 j
|
|
||||||
4 0 j
|
|
||||||
5 0 j
|
|
||||||
6 0 j
|
|
||||||
7 7 j
|
|
||||||
0 0 k
|
|
||||||
1 0 k
|
|
||||||
2 0 k
|
|
||||||
3 0 k
|
|
||||||
4 0 k
|
|
||||||
5 0 k
|
|
||||||
6 0 k
|
|
||||||
7 7 k
|
|
||||||
0 0 l
|
|
||||||
1 0 l
|
|
||||||
2 0 l
|
|
||||||
3 0 l
|
|
||||||
4 0 l
|
|
||||||
5 0 l
|
|
||||||
6 0 l
|
|
||||||
7 7 l
|
|
||||||
0 1 m
|
|
||||||
1 0 m
|
|
||||||
2 0 m
|
|
||||||
3 0 m
|
|
||||||
4 0 m
|
|
||||||
5 0 m
|
|
||||||
6 0 m
|
|
||||||
7 7 m
|
|
||||||
0 0 n
|
|
||||||
1 0 n
|
|
||||||
2 0 n
|
|
||||||
3 0 n
|
|
||||||
4 0 n
|
|
||||||
5 0 n
|
|
||||||
6 0 n
|
|
||||||
7 7 n
|
|
||||||
0 0 o
|
|
||||||
1 0 o
|
|
||||||
2 0 o
|
|
||||||
3 0 o
|
|
||||||
4 0 o
|
|
||||||
5 0 o
|
|
||||||
6 0 o
|
|
||||||
7 7 o
|
|
||||||
0 0 p
|
|
||||||
1 0 p
|
|
||||||
2 0 p
|
|
||||||
3 0 p
|
|
||||||
4 0 p
|
|
||||||
5 0 p
|
|
||||||
6 0 p
|
|
||||||
7 7 p
|
|
||||||
0 0 q
|
|
||||||
1 0 q
|
|
||||||
2 0 q
|
|
||||||
3 0 q
|
|
||||||
4 0 q
|
|
||||||
5 0 q
|
|
||||||
6 0 q
|
|
||||||
7 7 q
|
|
||||||
0 0 r
|
|
||||||
1 0 r
|
|
||||||
2 0 r
|
|
||||||
3 0 r
|
|
||||||
4 0 r
|
|
||||||
5 0 r
|
|
||||||
6 0 r
|
|
||||||
7 7 r
|
|
||||||
0 0 s
|
|
||||||
1 0 s
|
|
||||||
2 0 s
|
|
||||||
3 0 s
|
|
||||||
4 0 s
|
|
||||||
5 0 s
|
|
||||||
6 0 s
|
|
||||||
7 7 s
|
|
||||||
0 0 t
|
|
||||||
1 0 t
|
|
||||||
2 0 t
|
|
||||||
3 0 t
|
|
||||||
4 0 t
|
|
||||||
5 6 t
|
|
||||||
6 0 t
|
|
||||||
7 7 t
|
|
||||||
0 0 u
|
|
||||||
1 0 u
|
|
||||||
2 0 u
|
|
||||||
3 0 u
|
|
||||||
4 0 u
|
|
||||||
5 0 u
|
|
||||||
6 0 u
|
|
||||||
7 7 u
|
|
||||||
0 0 v
|
|
||||||
1 0 v
|
|
||||||
2 0 v
|
|
||||||
3 0 v
|
|
||||||
4 0 v
|
|
||||||
5 0 v
|
|
||||||
6 0 v
|
|
||||||
7 7 v
|
|
||||||
0 0 w
|
|
||||||
1 0 w
|
|
||||||
2 0 w
|
|
||||||
3 0 w
|
|
||||||
4 0 w
|
|
||||||
5 0 w
|
|
||||||
6 0 w
|
|
||||||
7 7 w
|
|
||||||
0 0 x
|
|
||||||
1 0 x
|
|
||||||
2 0 x
|
|
||||||
3 0 x
|
|
||||||
4 0 x
|
|
||||||
5 0 x
|
|
||||||
6 0 x
|
|
||||||
7 7 x
|
|
||||||
0 0 y
|
|
||||||
1 0 y
|
|
||||||
2 0 y
|
|
||||||
3 0 y
|
|
||||||
4 0 y
|
|
||||||
5 0 y
|
|
||||||
6 0 y
|
|
||||||
7 7 y
|
|
||||||
0 0 z
|
|
||||||
1 0 z
|
|
||||||
2 0 z
|
|
||||||
3 0 z
|
|
||||||
4 0 z
|
|
||||||
5 0 z
|
|
||||||
6 0 z
|
|
||||||
7 7 z
|
|
||||||
0 0
|
|
||||||
1 0
|
|
||||||
2 0
|
|
||||||
3 0
|
|
||||||
4 0
|
|
||||||
5 0
|
|
||||||
6 0
|
|
||||||
7 7
|
|
||||||
7
|
|
@ -1,29 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import pandas as pd
|
|
||||||
import os
|
|
||||||
|
|
||||||
def automat_fun(recursive_df: pd.DataFrame):
|
|
||||||
first_row = recursive_df.iloc[0]
|
|
||||||
recursive_df = recursive_df.iloc[1:,:]
|
|
||||||
return lambda char, state: first_row[1] if state == first_row[0] and char == first_row[2] else automat_fun(recursive_df)(char, state)
|
|
||||||
|
|
||||||
def create_automat_from_file(file_path: str):
|
|
||||||
df = pd.read_csv(file_path, sep='\t', header=None)
|
|
||||||
accept_state = df.tail(1).iloc[0, 0]
|
|
||||||
df = df.iloc[:-1,:]
|
|
||||||
return accept_state, automat_fun(df)
|
|
||||||
|
|
||||||
file_path = os.path.join(os.path.dirname(__file__), 'fsa_description.arg')
|
|
||||||
accept_state, automat_function = create_automat_from_file(file_path)
|
|
||||||
|
|
||||||
txt = input('Write valid input: ')
|
|
||||||
|
|
||||||
while txt != 'exit':
|
|
||||||
state = 0
|
|
||||||
for c in txt:
|
|
||||||
if (c == '\n'):
|
|
||||||
break
|
|
||||||
state = automat_function(c, state)
|
|
||||||
print('YES' if state == accept_state else "NO")
|
|
||||||
txt = input('Write valid input: ')
|
|
File diff suppressed because it is too large
Load Diff
@ -1,3 +0,0 @@
|
|||||||
NO
|
|
||||||
YES
|
|
||||||
YES
|
|
@ -1,3 +0,0 @@
|
|||||||
macb
|
|
||||||
macbeth
|
|
||||||
xadadamacbethrff
|
|
@ -1,12 +0,0 @@
|
|||||||
Read a description of a non-deterministic finite-state automaton in the AT&T format
|
|
||||||
(without weights) from the file in the first argument.
|
|
||||||
|
|
||||||
Read strings from the standard input.
|
|
||||||
If a string is accepted by the
|
|
||||||
automaton, write YES, otherwise- write NO.
|
|
||||||
|
|
||||||
The program is invoked like this: python run.py test1.arg test1.in test1.out
|
|
||||||
|
|
||||||
Note that not all transitions must be included in description.
|
|
||||||
If no transition is given for the given state and letter, write NO.
|
|
||||||
|
|
4040
TaskC00/long.arg
4040
TaskC00/long.arg
File diff suppressed because it is too large
Load Diff
@ -1,7 +0,0 @@
|
|||||||
NO
|
|
||||||
NO
|
|
||||||
YES
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
@ -1,7 +0,0 @@
|
|||||||
aaa
|
|
||||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
|
||||||
aaaa
|
|
||||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
|
||||||
xyz
|
|
||||||
aba
|
|
||||||
a
|
|
@ -1,56 +0,0 @@
|
|||||||
import pandas as pd
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import random
|
|
||||||
|
|
||||||
class Automat:
|
|
||||||
def __init__(self, df: pd.DataFrame, end_states: list):
|
|
||||||
self._df = df
|
|
||||||
self._end_states = end_states
|
|
||||||
|
|
||||||
def _consume_character(self, state: int, char: str):
|
|
||||||
filter = (self._df[0] == state) & (self._df[2] == char)
|
|
||||||
matching_rows = self._df[filter]
|
|
||||||
if matching_rows.empty:
|
|
||||||
return None
|
|
||||||
end_states = matching_rows.iloc[:,1].tolist()
|
|
||||||
return random.choice(end_states)
|
|
||||||
|
|
||||||
def consume_word(self, word: str):
|
|
||||||
prev_state = 0
|
|
||||||
state = 0
|
|
||||||
for char in word:
|
|
||||||
prev_state = state
|
|
||||||
state = self._consume_character(state, char)
|
|
||||||
if state is None:
|
|
||||||
return prev_state in self._end_states
|
|
||||||
return state in self._end_states
|
|
||||||
|
|
||||||
def create_automat_from_file(file_path: str):
|
|
||||||
automat_df = pd.read_csv(file_path, sep='\t', header=None)
|
|
||||||
|
|
||||||
end_states_condition = (automat_df[1].isnull()) & (automat_df[2].isnull())
|
|
||||||
end_states_df = automat_df[end_states_condition]
|
|
||||||
end_states = end_states_df.iloc[:,0].tolist()
|
|
||||||
|
|
||||||
automat_df = automat_df[~end_states_condition]
|
|
||||||
automat_df[2] = automat_df[2].astype(str)
|
|
||||||
|
|
||||||
return Automat(automat_df, end_states)
|
|
||||||
|
|
||||||
automat_path = os.path.join(os.path.dirname(__file__), 'test1.arg')
|
|
||||||
automat = create_automat_from_file(automat_path)
|
|
||||||
|
|
||||||
test_path = os.path.join(os.path.dirname(__file__), 'test1.in')
|
|
||||||
|
|
||||||
|
|
||||||
results = []
|
|
||||||
with open(test_path, 'r') as f:
|
|
||||||
for line in f:
|
|
||||||
results.append('YES' if automat.consume_word(line.strip()) else 'NO')
|
|
||||||
|
|
||||||
out_path = os.path.join(os.path.dirname(__file__), 'test1.out')
|
|
||||||
|
|
||||||
with open(out_path, 'w') as f:
|
|
||||||
for result in results:
|
|
||||||
f.write(result + '\n')
|
|
@ -1,16 +0,0 @@
|
|||||||
0 1 x
|
|
||||||
1 2 y
|
|
||||||
2 3 z
|
|
||||||
0 4 y
|
|
||||||
0 4 z
|
|
||||||
1 4 x
|
|
||||||
1 4 z
|
|
||||||
2 4 x
|
|
||||||
2 4 y
|
|
||||||
3 4 x
|
|
||||||
3 4 y
|
|
||||||
3 4 z
|
|
||||||
4 4 x
|
|
||||||
4 4 y
|
|
||||||
4 4 z
|
|
||||||
3
|
|
@ -1,9 +0,0 @@
|
|||||||
NO
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
@ -1,9 +0,0 @@
|
|||||||
xxyz
|
|
||||||
xyz
|
|
||||||
xy
|
|
||||||
zz
|
|
||||||
xxy
|
|
||||||
yzx
|
|
||||||
|
|
||||||
x
|
|
||||||
xyzz
|
|
@ -1,9 +0,0 @@
|
|||||||
NO
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
@ -1,7 +0,0 @@
|
|||||||
0 1 a
|
|
||||||
1 0 a
|
|
||||||
1 2 b
|
|
||||||
2 4 c
|
|
||||||
1 3 b
|
|
||||||
3
|
|
||||||
4
|
|
@ -1,8 +0,0 @@
|
|||||||
YES
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
YES
|
|
@ -1,8 +0,0 @@
|
|||||||
abc
|
|
||||||
ab
|
|
||||||
abcd
|
|
||||||
aaaabc
|
|
||||||
aaaaaaaabc
|
|
||||||
aaaaaaabc
|
|
||||||
zzz
|
|
||||||
aaaaaaabc
|
|
@ -1,11 +0,0 @@
|
|||||||
Use a non deterministic finite-state automaton (FSA) engine from the TaskC00.
|
|
||||||
Create your own non deterministic FSA description to check whether the string second letter
|
|
||||||
from right is 'b'.
|
|
||||||
Don't use external files like in TaskF00 (description should be included in run file).
|
|
||||||
|
|
||||||
The alphabet is "a", "b", "C"
|
|
||||||
|
|
||||||
Read strings from the standard input.
|
|
||||||
If a string is accepted by the
|
|
||||||
automaton, write YES, otherwise- write NO.
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
|||||||
import pandas as pd
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import random
|
|
||||||
|
|
||||||
class Automat:
|
|
||||||
def __init__(self, df: pd.DataFrame, end_states: list):
|
|
||||||
self._df = df
|
|
||||||
self._end_states = end_states
|
|
||||||
|
|
||||||
def _consume_character(self, state: int, char: str):
|
|
||||||
filter = (self._df[0] == state) & (self._df[2] == char)
|
|
||||||
matching_rows = self._df[filter]
|
|
||||||
if matching_rows.empty:
|
|
||||||
return None
|
|
||||||
end_states = matching_rows.iloc[:,1].tolist()
|
|
||||||
return random.choice(end_states)
|
|
||||||
|
|
||||||
def consume_word(self, word: str):
|
|
||||||
prev_state = 0
|
|
||||||
state = 0
|
|
||||||
for char in word:
|
|
||||||
prev_state = state
|
|
||||||
state = self._consume_character(state, char)
|
|
||||||
if state is None:
|
|
||||||
return prev_state in self._end_states
|
|
||||||
return state in self._end_states
|
|
||||||
|
|
||||||
def create_automat_from_file(file_path: str):
|
|
||||||
automat_df = pd.read_csv(file_path, sep=' ', header=None)
|
|
||||||
end_states_condition = (automat_df[1].isnull()) & (automat_df[2].isnull())
|
|
||||||
end_states_df = automat_df[end_states_condition]
|
|
||||||
end_states = end_states_df.iloc[:,0].tolist()
|
|
||||||
|
|
||||||
automat_df = automat_df[~end_states_condition]
|
|
||||||
automat_df[2] = automat_df[2].astype(str)
|
|
||||||
|
|
||||||
return Automat(automat_df, end_states)
|
|
||||||
|
|
||||||
automat_path = os.path.join(os.path.dirname(__file__), 'test.arg')
|
|
||||||
automat = create_automat_from_file(automat_path)
|
|
||||||
|
|
||||||
test_path = os.path.join(os.path.dirname(__file__), 'test.in')
|
|
||||||
|
|
||||||
txt = input('Write valid input: ')
|
|
||||||
while txt != 'exit':
|
|
||||||
print('YES' if automat.consume_word(txt) else 'NO')
|
|
||||||
txt = input('Write valid input: ')
|
|
@ -1,5 +0,0 @@
|
|||||||
0 1 a
|
|
||||||
0 1 b
|
|
||||||
0 1 c
|
|
||||||
1 2 b
|
|
||||||
2
|
|
@ -1,6 +0,0 @@
|
|||||||
YES
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
YES
|
|
@ -1,6 +0,0 @@
|
|||||||
abc
|
|
||||||
abbc
|
|
||||||
bca
|
|
||||||
b
|
|
||||||
abaa
|
|
||||||
aaacbb
|
|
@ -1,6 +0,0 @@
|
|||||||
YES
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
YES
|
|
||||||
NO
|
|
@ -1,11 +0,0 @@
|
|||||||
Use a non deterministic finite-state automaton (FSA) engine from the TaskC00.
|
|
||||||
Create your own non deterministic FSA description to check whether the string
|
|
||||||
ends with "ab"
|
|
||||||
Don't use external files like in TaskF00 (description should be included in run file).
|
|
||||||
|
|
||||||
The alphabet is "a", "b", "C"
|
|
||||||
|
|
||||||
Read strings from the standard input.
|
|
||||||
If a string is accepted by the
|
|
||||||
automaton, write YES, otherwise- write NO.
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
|||||||
import pandas as pd
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import random
|
|
||||||
|
|
||||||
class Automat:
|
|
||||||
def __init__(self, df: pd.DataFrame, end_states: list):
|
|
||||||
self._df = df
|
|
||||||
self._end_states = end_states
|
|
||||||
|
|
||||||
def _consume_character(self, state: int, char: str):
|
|
||||||
filter = (self._df[0] == state) & (self._df[2] == char)
|
|
||||||
matching_rows = self._df[filter]
|
|
||||||
if matching_rows.empty:
|
|
||||||
return None
|
|
||||||
end_states = matching_rows.iloc[:,1].tolist()
|
|
||||||
return random.choice(end_states)
|
|
||||||
|
|
||||||
def consume_word(self, word: str):
|
|
||||||
prev_state = 0
|
|
||||||
state = 0
|
|
||||||
for char in word:
|
|
||||||
prev_state = state
|
|
||||||
state = self._consume_character(state, char)
|
|
||||||
if state is None:
|
|
||||||
return prev_state in self._end_states
|
|
||||||
return state in self._end_states
|
|
||||||
|
|
||||||
def create_automat_from_file(file_path: str):
|
|
||||||
automat_df = pd.read_csv(file_path, sep=' ', header=None)
|
|
||||||
end_states_condition = (automat_df[1].isnull()) & (automat_df[2].isnull())
|
|
||||||
end_states_df = automat_df[end_states_condition]
|
|
||||||
end_states = end_states_df.iloc[:,0].tolist()
|
|
||||||
|
|
||||||
automat_df = automat_df[~end_states_condition]
|
|
||||||
automat_df[2] = automat_df[2].astype(str)
|
|
||||||
|
|
||||||
return Automat(automat_df, end_states)
|
|
||||||
|
|
||||||
automat_path = os.path.join(os.path.dirname(__file__), 'test.arg')
|
|
||||||
automat = create_automat_from_file(automat_path)
|
|
||||||
|
|
||||||
txt = input('Write valid input: ')
|
|
||||||
while txt != 'exit':
|
|
||||||
print('YES' if automat.consume_word(txt) else 'NO')
|
|
||||||
txt = input('Write valid input: ')
|
|
@ -1,6 +0,0 @@
|
|||||||
0 0 a
|
|
||||||
0 0 b
|
|
||||||
0 0 c
|
|
||||||
0 1 a
|
|
||||||
1 2 b
|
|
||||||
2
|
|
@ -1,6 +0,0 @@
|
|||||||
YES
|
|
||||||
NO
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
YES
|
|
||||||
NO
|
|
@ -1,6 +0,0 @@
|
|||||||
ab
|
|
||||||
a
|
|
||||||
abbab
|
|
||||||
bbbbb
|
|
||||||
ababaab
|
|
||||||
b
|
|
@ -1,6 +0,0 @@
|
|||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
YES
|
|
||||||
NO
|
|
@ -1,10 +0,0 @@
|
|||||||
Use a non deterministic finite-state automaton (FSA) engine from the TaskC00.
|
|
||||||
Create your own non deterministic FSA description to check whether the string
|
|
||||||
contains "abc"
|
|
||||||
Don't use external files like in TaskF00 (description should be included in run file).
|
|
||||||
|
|
||||||
The alphabet is "a", "b", "c"
|
|
||||||
|
|
||||||
Read strings from the standard input.
|
|
||||||
If a string is accepted by the
|
|
||||||
automaton, write YES, otherwise- write NO.
|
|
@ -1,46 +0,0 @@
|
|||||||
import pandas as pd
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import random
|
|
||||||
|
|
||||||
class Automat:
|
|
||||||
def __init__(self, df: pd.DataFrame, end_states: list):
|
|
||||||
self._df = df
|
|
||||||
self._end_states = end_states
|
|
||||||
|
|
||||||
def _consume_character(self, state: int, char: str):
|
|
||||||
filter = (self._df[0] == state) & (self._df[2] == char)
|
|
||||||
matching_rows = self._df[filter]
|
|
||||||
if matching_rows.empty:
|
|
||||||
return None
|
|
||||||
end_states = matching_rows.iloc[:,1].tolist()
|
|
||||||
return random.choice(end_states)
|
|
||||||
|
|
||||||
def consume_word(self, word: str):
|
|
||||||
prev_state = 0
|
|
||||||
state = 0
|
|
||||||
for char in word:
|
|
||||||
prev_state = state
|
|
||||||
state = self._consume_character(state, char)
|
|
||||||
if state is None:
|
|
||||||
return prev_state in self._end_states
|
|
||||||
return state in self._end_states
|
|
||||||
|
|
||||||
def create_automat_from_file(file_path: str):
|
|
||||||
automat_df = pd.read_csv(file_path, sep=' ', header=None)
|
|
||||||
end_states_condition = (automat_df[1].isnull()) & (automat_df[2].isnull())
|
|
||||||
end_states_df = automat_df[end_states_condition]
|
|
||||||
end_states = end_states_df.iloc[:,0].tolist()
|
|
||||||
|
|
||||||
automat_df = automat_df[~end_states_condition]
|
|
||||||
automat_df[2] = automat_df[2].astype(str)
|
|
||||||
|
|
||||||
return Automat(automat_df, end_states)
|
|
||||||
|
|
||||||
automat_path = os.path.join(os.path.dirname(__file__), 'test.arg')
|
|
||||||
automat = create_automat_from_file(automat_path)
|
|
||||||
|
|
||||||
txt = input('Write valid input: ')
|
|
||||||
while txt != 'exit':
|
|
||||||
print('YES' if automat.consume_word(txt) else 'NO')
|
|
||||||
txt = input('Write valid input: ')
|
|
@ -1,13 +0,0 @@
|
|||||||
0 0 a
|
|
||||||
0 0 b
|
|
||||||
0 0 c
|
|
||||||
0 1 a
|
|
||||||
1 1 a
|
|
||||||
1 1 b
|
|
||||||
1 1 c
|
|
||||||
1 2 b
|
|
||||||
2 2 a
|
|
||||||
2 2 b
|
|
||||||
2 2 c
|
|
||||||
2 3 c
|
|
||||||
3
|
|
@ -1,7 +0,0 @@
|
|||||||
YES
|
|
||||||
YES
|
|
||||||
YES
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
||||||
NO
|
|
@ -1,7 +0,0 @@
|
|||||||
abc
|
|
||||||
acabc
|
|
||||||
acabccb
|
|
||||||
abbab
|
|
||||||
bbbbb
|
|
||||||
ababaab
|
|
||||||
bc
|
|
@ -1,22 +0,0 @@
|
|||||||
Deterministic automaton III
|
|
||||||
===========================
|
|
||||||
|
|
||||||
Read a description of a finite-state automaton in the AT&T format
|
|
||||||
(without weights) from the file in the first argument. Then, read strings from the
|
|
||||||
standard input. If a string is
|
|
||||||
accepted by the automated, write YES, a space and the string on the
|
|
||||||
standard output, otherwise — write NO, a space and the string.
|
|
||||||
|
|
||||||
If there is a non-determinism in the automaton, the first transition should be chosen.
|
|
||||||
|
|
||||||
The automaton can contain epsilon transitions ("<eps>" instead of a
|
|
||||||
character). They should be interpreted as follows: an epsilon
|
|
||||||
transition can be used (without "eating" a character from the input),
|
|
||||||
if there is no other transition applicable. You can assume that there
|
|
||||||
is at most one epsilon transition from a given state and that there
|
|
||||||
are no cycles with epsilon transition.
|
|
||||||
|
|
||||||
Your program does not have to check whether the description is correct
|
|
||||||
and whether the automaton is deterministic. You can assume that the
|
|
||||||
automaton does not contain epsilon transitions.
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
|||||||
0 1 a
|
|
||||||
1 0 a
|
|
||||||
1 2 b
|
|
||||||
2 4 c
|
|
||||||
1 3 <eps>
|
|
||||||
3 4 d
|
|
||||||
3
|
|
||||||
4
|
|
@ -1,10 +0,0 @@
|
|||||||
TRUE a
|
|
||||||
FALSE aa
|
|
||||||
TRUE aaa
|
|
||||||
TRUE abc
|
|
||||||
TRUE aaabc
|
|
||||||
FALSE aaabcd
|
|
||||||
FALSE aabc
|
|
||||||
FALSE abd
|
|
||||||
TRUE ad
|
|
||||||
FALSE aad
|
|
@ -1,10 +0,0 @@
|
|||||||
a
|
|
||||||
aa
|
|
||||||
aaa
|
|
||||||
abc
|
|
||||||
aaabc
|
|
||||||
aaabcd
|
|
||||||
aabc
|
|
||||||
abd
|
|
||||||
ad
|
|
||||||
aad
|
|
4041
TaskC04/long.arg
4041
TaskC04/long.arg
File diff suppressed because it is too large
Load Diff
@ -1,7 +0,0 @@
|
|||||||
FALSE aaa
|
|
||||||
FALSE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
|
||||||
TRUE aaaa
|
|
||||||
TRUE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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||||
2 3 c
|
|
||||||
3
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user