12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # this programme compare a text in french and its translation in englishe and liste the common words .import codecs
- import codecs
- f = codecs.open("JVFR.txt", encoding='utf-8') # on précise l’encodage à l’ouverture
- textFr = f.read() # txt est une unicode
- nm =0
- #with open("JVFR.txt", encoding='utf-8', "r") as textFr:
- for line in textFr:
- line=line.strip()
- mots=line.split()
-
- for mot in mots :
- #mot=mot.strip(" ;''?:,()!.\").”-")
- nm=nm+1
- #print(mot)
- print("nombres de mots en text francais = ", nm)
- #
- E = codecs.open("JVEN.txt", encoding='utf-8') # on précise l’encodage à l’ouverture
- textEN = E.read() # txt est une unicode
- nb =0
- #with open("JVFR.txt", encoding='utf-8', "r") as textFr:
- for line in textEN:
- line=line.strip()
- words=line.split()
-
- for word in words :
- #mot=mot.strip(" ;''?:,()!.\").”-")
- nb=nb+1
- #print(mot)
- print("nombres de mots en text anglais = ", nb)
- S = codecs.open("JVES.txt", encoding='utf-8') # on précise l’encodage à l’ouverture
- textES = S.read() # txt est une unicode
- nmb =0
- #with open("JVFR.txt", encoding='utf-8', "r") as textFr:
- for line in textES:
- line=line.strip()
- parabls=line.split()
-
- for parabl in parabls:
- #mot=mot.strip(" ;''?:,()!.\").”-")
- nmb=nmb+1
- #print(mot)
- print("nombres de mots en text espagnol = ", nmb)
|