29 lines
1.0 KiB
Python
29 lines
1.0 KiB
Python
|
import re
|
||
|
import sys
|
||
|
|
||
|
inFile = sys.argv[1]
|
||
|
outFile = sys.argv[2]
|
||
|
|
||
|
def analyze_line(line):
|
||
|
lower_case_count = len(re.findall(r'[a-ząćęłńóśźż]', line))
|
||
|
upper_case_count = len(re.findall(r'[A-ZĄĆĘŁŃÓŚŹŻ]', line))
|
||
|
digit_count = len(re.findall(r'\d', line))
|
||
|
other_count = len(re.findall(r'[^a-zą-żA-ZĄ-Ż\d\n]', line))
|
||
|
# print(re.findall(r'[^a-zą-żA-ZĄ-Ż\d\n]', line))
|
||
|
|
||
|
return(lower_case_count, upper_case_count, digit_count, other_count)
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
try:
|
||
|
with open(inFile, 'r', encoding='utf-8') as inputFile, open(outFile, 'w', encoding='utf-8') as outputFile:
|
||
|
for line in inputFile:
|
||
|
line = line.rstrip()
|
||
|
|
||
|
|
||
|
lower_case_count, upper_case_count, digit_count, other_count = analyze_line(line)
|
||
|
outputFile.write(f'{lower_case_count} {upper_case_count} {digit_count} {other_count}' + '\n')
|
||
|
print(f'{lower_case_count} {upper_case_count} {digit_count} {other_count}')
|
||
|
|
||
|
except EOFError:
|
||
|
pass
|