Hi
I'm creating an html file to record the first and last entry of each page of my greek dictionnary. To find the page number of a given word, for instance «ἔπος», I have to find out the page such that its first entry is less or equal to «ἔπος» and last entry is greater or equal to «ἔπος».
Among the BeautifulSoup options to filter an xml tree with the «.find_all» method, there is a one-parameter-only function, this parameter being, as long as I've been to understand, each xml element the «.find_all» is processing.
To be able to compare the entries to the looked for word, I have to record it either in :
-a nonlocal or global variable
-an element of the tree, for example the parent node of the inspected element
I have tested this second way with:
How would you solve this issue ?
Arbiel
P.S : I actually found here another supposedly better solution
I'm creating an html file to record the first and last entry of each page of my greek dictionnary. To find the page number of a given word, for instance «ἔπος», I have to find out the page such that its first entry is less or equal to «ἔπος» and last entry is greater or equal to «ἔπος».
Among the BeautifulSoup options to filter an xml tree with the «.find_all» method, there is a one-parameter-only function, this parameter being, as long as I've been to understand, each xml element the «.find_all» is processing.
To be able to compare the entries to the looked for word, I have to record it either in :
-a nonlocal or global variable
-an element of the tree, for example the parent node of the inspected element
I have tested this second way with:
def sel_laPage(article): # article['α'] is the first entry of the page # article['ω'], the last one return article.has_attr('α') and article.parent['ἔπος'] >= article['α'] and article.parent['ἔπος'] <= article['ω']What do you think of the way I'm processing ?
How would you solve this issue ?
Arbiel
P.S : I actually found here another supposedly better solution