37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# Copyright (C) 2017 Constant, Algolit
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details: <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
'''
|
|
Input texts are checked against a dictionary that assigns weights to different vowels.
|
|
The script gives a score for a specific sentence.
|
|
'''
|
|
|
|
# create a dictionary
|
|
scrabble = {'au': 'o', 'ie': 'y', 'eau': 'o', 'ai': 'e'}
|
|
|
|
# find a sentence / string
|
|
sentence = "J'ai la vie qui est un beau mystère qu'il faut vivre, et non un problème à résoudre."
|
|
|
|
# split sentence in list of words
|
|
words = sentence.split()
|
|
|
|
# for each word
|
|
for word in words:
|
|
# iterate over dictionary
|
|
for k in scrabble:
|
|
if k in word:
|
|
word = word.replace(k,scrabble[k])
|
|
print(word)
|