#Language processors

1 messages · Page 1 of 1 (latest)

swift crater
#

Need only 1 task solved, only 1.

nocturne torrent
#

Ok

#

damn two hours ago

#

@swift crater

#

I couldn't read what you wrote down well

#

import re

def recognize_language(word):
pattern1 = re.compile("^(01)+$")
pattern2 = re.compile("^((aba)+)((bab)+)$")
match1 = pattern1.match(word)
match2 = pattern2.match(word)
if match1:
print("The word is in language L1")
elif match2:
print("The word is in language L2")
else:
print("The word is not in the language")

input_word = input("Enter the word to be checked: ")
recognize_language(input_word)

#

This program is using regular expressions to check if the input matches the patterns of the language L1 and L2. The funtion 'recognize_language()' takes an input word and checks if it matches the patterns using the 're.match()' function.

#

If the word matches either pattern, the program prints that the word is in the language.If the word does not match either pattern, the program prints that the word is not in the language.

#

@swift crater

#

g o l d e n m o a i

swift crater
#

Jeez is this actually working out ?

#

First of all thank you for your help ! Please can I add you, I will need help on 24 Jan Tuesday really similar (may be identical) tasks to these 4 ones

swift crater
#

@nocturne torrent mr. are you here please respond