pyt9a.py 840 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # this programme compare a text in french and its translation in englishe and liste the common words .
  4. nm =0
  5. with open("JVFR.txt", "r") as textFr:
  6. for line in textFr:
  7. line=line.strip()
  8. mots=line.split()
  9. for mot in mots :
  10. mot=mot.strip(" ;''?:,()!.\").”-")
  11. nm=nm+1
  12. print(mot)
  13. print(nm)
  14. nw=0
  15. with open("JVEN.txt", "r") as textEn:
  16. for line in textEn:
  17. line=line.strip()
  18. words=line.split()
  19. for word in words :
  20. nw=nw+1
  21. #print(word)
  22. print(nw)
  23. #for mot in mots :
  24. #print(mot)
  25. nb=0
  26. for word in words:
  27. #print(word)
  28. word = word.strip(" ;''?:,()!.\").”-")
  29. for mot in mots:
  30. #print(mot)
  31. #mot = mot.strip(" ;''?:,()!.\").”-")
  32. if word == mot :
  33. nb= nb+1
  34. print(word)
  35. print("nombres des mots anglais identiques =" , nb)