On Thu, May 21, 2009 at 4:26 PM, Eduardo Vieira <eduardo.su...@gmail.com>wrote:
> Hello, I'm planning to create a script to read a certain file, find > the line that contains Bible references and then use that to query a > bible database in order to print the verses in another file. > I will be looking for lines like these: > Lesson Text: Acts 5:15-20, 25; 10:12; John 3:16; Psalm 23 > > So, references in different chapters are separated by a semicolon. My > main challenge would be make the program guess that 10:12 refers to > the previous book. 15-20 means verses 15 thru 20 inclusive. I'm afraid > that will take more than Regex and I never studied anything about > parser tools, really. > > Any suggestion how I should approach this? > Actually, a regex probably wouldn't be too far off. If you're comfortable working with them it may even be a good thing... Will the line always begin with "Lesson text:"? If so, that makes it a lot easier. Something like: for line in file: if line starts with "Lesson text": skip "lesson text" book = first word(s) verse[book] = list of references that's a really basic flow of logic, but it's probably how I'd do it. HTH, Wayne -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every vice, has found its defenders, its rhetoric, its ennoblement and exaltation, but stupidity hasn’t. - Primo Levi
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor