12345678910111213141516171819202122 |
- #!/usr/bin/env python
- #-*- coding: utf-8 -*-
- # this programme compare a text in french and its translation in englishe and liste the common words .
- textFr ="L'année 1866 fut marquée par un événement bizarre, un phénomène inexpliqué et inexplicable que personne n'a sans doute oublié. Sans parler des rumeurs qui agitaient les populations des ports et surexcitaient l'esprit public à l'intérieur des continents les gens de mer furent particulièrement émus. Les négociants, armateurs, capitaines de navires, skippers et masters de l'Europe et de l'Amérique, officiers des marines militaires de tous pays, et, après eux, les gouvernements des divers États des deux continents, se préoccupèrent de ce fait au plus haut point. "
- textEn = "THE YEAR 1866 was marked by a bizarre development, an unexplained and downright inexplicable phenomenon that surely no one has forgotten. Without getting into those rumors that upset civilians in the seaports and deranged the public mind even far inland, it must be said that professional seamen were especially alarmed. Traders, shipowners, captains of vessels, skippers, and master mariners from Europe and America, naval officers from every country, and at their heels the various national governments on these two continents, were all extremely disturbed by the business. "
- mots=textFr.split()
- words=textEn.split()
- # for each word in the line:
- #for mot in mots:
- # print the "mot"
- #print(mot)
- #for word in words:
- # print the "word"
- #print(word)
- nb = 0
- for word in words:
- for mot in mots:
- if word == mot :
- nb=nb+1
- print(word)
- print("mots commons =" , nb)
|