63 lines
1.6 KiB
Python
63 lines
1.6 KiB
Python
#!/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
|
||
nbs=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 :
|
||
word=word.strip(" ;''?:,()!.\").”-")
|
||
nb=nb+1
|
||
#print(word)
|
||
for mot in mots:
|
||
if word == mot :
|
||
nbs=nbs+1
|
||
print(word)
|
||
#print(word)
|
||
print("nombres de mots en text anglais = ", nb)
|
||
print("nombres des mots commun =" ,nbs)
|
||
|
||
S = codecs.open("JVES.txt", encoding='utf-8') # on précise l’encodage à l’ouverture
|
||
textES = S.read() # txt est une unicode
|
||
|
||
nmb =0
|
||
nmbs=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
|
||
if parabl== mot :
|
||
nmbs=nmbs+1
|
||
print(parabl)
|
||
|
||
#print(mot)
|
||
print("nombres de mots en text espagnol = ", nmb)
|
||
print("nombres des mots commun =" ,nbs) |