26 lines
768 B
Python
26 lines
768 B
Python
|
import re
|
||
|
import sys
|
||
|
|
||
|
inFile = sys.argv[1]
|
||
|
outFile = sys.argv[2]
|
||
|
|
||
|
def analyze_line(line):
|
||
|
lowercase_count = len(re.findall(r'\b[a-ząćęłńóśźż]\w*\b', line))
|
||
|
uppercase_count = len(re.findall(r'\b[A-ZĄĆĘŁŃÓŚŹŻ]\w*\b', line))
|
||
|
|
||
|
return (lowercase_count, uppercase_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()
|
||
|
|
||
|
lowercase_count, uppercase_count = analyze_line(line)
|
||
|
outputFile.write(f'{lowercase_count} {uppercase_count}' + '\n')
|
||
|
print(f'{lowercase_count} {uppercase_count}')
|
||
|
|
||
|
|
||
|
except EOFError:
|
||
|
pass
|