3

I am currently using the Python-docx package and have processed the text and the comments. However, in the .docx file, every comment is on a particular sentence or paragraph. I wonder how to read such links between comments and sentences by Python-docx. Or should I use another package?

Thanks!

Update Sorry for not being clear. Here is an example. Each comment is linked to a sentence. I aim to extract the pairing information between comments and sentences. dialogue example

SOLVED. I followed the procedure of https://stackoverflow.com/a/51370245/11064152

aiaiai
  • 31
  • 5

1 Answers1

1

Your question is a bit vague, but from what I can gather, you want to pair the comment assigned to a sentence or paragraph (presumably commenting on it) with one another?

You could do this many ways, but to name a few off the top of my head, if the sentence/paragraph only has one comment then you could pair the comment with its sentence in a dictionary. Then you could easily print all of the pairs, or loop through and print each seperately.

You could also use a module such as openpyxl to assign the comments and sentences to an excel document, having the sentences in one column and the comments in another.

You can also simply write the comments and their responding sentences/paragraphs to another word document with the Python-docx package you are using.

I highly suggest at least reading chapter 13 of automate the boring stuff - it is available online for free - and does a brilliant job answering your question with very clear examples. I would provide the link, but the mods don't like links around here.

to240
  • 381
  • 3
  • 5