Menyebalkan. Saya salah memahami pertanyaan!
Bagaimanapun, jika Anda kebetulan ingin menghitung catatan kaki, dan menggunakan sesuatu dengan alat baris perintah unix yang tersedia (misalnya linux / mac / unix-tools untuk windows), maka Anda dapat melakukan sesuatu seperti ini:
cat FILENAME | tr '\\' '\n' | awk '/^f /{footnote++;}/^x /{xref++;}/^c /{print chapter, footnote, xref ; chapter=0+$2; footnote=0;xref=0;}END{print chapter, footnote, xref; }'
Yang dilakukan adalah memastikan bahwa setiap SFM baru memulai baris baru, dan kemudian menghitung catatan kaki, xref, dan ketika ada nomor pasal (atau akhir) ia mencetak jumlah tersebut. Saya tidak berbicara python, dan catatan ada dalam file XML yang cukup sulit untuk didekodekan dengan awk.
Bother. I misunderstood the question!
Anyway, if you happened to want to count footnotes, and are using something with unix command-line tools available (e.g. linux / mac / unix-tools for windows), then you can do something like this:
cat FILENAME | tr '\\' '\n' | awk '/^f /{footnote++;}/^x /{xref++;}/^c /{print chapter, footnote, xref ; chapter=0+$2; footnote=0;xref=0;}END{print chapter, footnote, xref; }'
What it does is make sure that every new SFM starts a new line, and then counts the footnotes, xrefs and when there’s a chapter number (or the end) it prints the counts. I don’t speak python though, and notes are in an XML file which is quite a bit too nasty to decode with awk.
Diterjemahkan secara otomatis dari English