Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
reading in a doc
#1
Hi i come back with a problem. Again. I code the second module of my program, this one have to match two docs, one containing a novel's list and the second one a keywords list. If there is a match the word corresponding is placed between two tags.

here is the code :


def baliseAnimaux(mot,motClef,dossierEcrire):
	
	nbLine=0 #number of lines of first document, a list of novel's titles
	nbLine2=0 #numbre of line of second document, in wich is the keywords the program have #match
	keyword=False
	r=0
#searching how many lines contain each document 	
	for a in mot:
		nbLine += 1
		
	for e in motClef:
        	nbLine2 += 1
	mot.seek(0)
	motClef.seek(0)
	
	for b in range(nbLine):		#for each line of doc to compare
		motA=str(mot.readline()) 
		phrase=motA.split(" ")   
		for i in range(len(phrase)): # for each word in each sentences			
			for j in range(nbLine2): # i read each lines of the keywords doc
				motD=str(motClef.readline()) 
				#motC=motD.split("\n") #isoler la ligne
				print(motD)# here it's just a test
				for h in range(nbLine2):	#					
					if phrase[i] == motD or phrase[i] == "l'"+motD :
						keyword=True					
						break				
					elif phrase[i]!=motD or phrase[i]!="l'"+motD:	
						keyword=False
							
					
								
			
			if keyword == True :			
				dossierEcrire.write("<persname>")
				dossierEcrire.write(phrase[i])
				dossierEcrire.write("<persname>")
				dossierEcrire.write(" ")
			else :
				dossierEcrire.write(phrase[i])
				dossierEcrire.write(" ")
						
i have no error, the final document is filled as expected, but idk when i print(motD), there is nothing written. someone could help me ?

thanks At
Reply


Messages In This Thread
reading in a doc - by IOHANNES - Oct-27-2022, 10:53 AM
RE: reading in a doc - by wavic - Oct-27-2022, 11:17 AM
RE: reading in a doc - by IOHANNES - Oct-27-2022, 12:16 PM
RE: reading in a doc - by wavic - Oct-27-2022, 01:36 PM
RE: reading in a doc - by Pedroski55 - Oct-29-2022, 02:23 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020