string_list_sentencewords.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env python
  2. # encoding=utf8
  3. # Copyright (C) 2016 Constant, Algolit
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details: <http://www.gnu.org/licenses/>.
  12. # Reduction of letters
  13. # From string to list & back
  14. # A string: a list of characters, unchangeable, but treatable
  15. # See: https://www.tutorialspoint.com/python3/python_strings.htm
  16. # Write sentence as string
  17. sentence = "Je vois La vie en vie rose..."
  18. # Print sentence
  19. print(sentence)
  20. tri=sentence.count("vie")
  21. print(tri)
  22. # # define new word as list
  23. # new_word = []
  24. # Convert sentence in list of words
  25. #words = sentence.split(separateur)
  26. # print(words)
  27. # # For each word in word list
  28. # for word in words:
  29. # # remove capital letters (string operation)
  30. # word = word.lower()
  31. # # Clean punctuation (string operation)
  32. # word = word.strip(" ;''?:,()!.\").”-")
  33. # # add word to new word list
  34. # new_word.append(word)
  35. # Write words as one, without punctuation
  36. #print("phrase mise en mots:", ''.join(new_word))