Delete all identical words after a character/command

Hi, I’m super new to Python and I’m using the program for data analysis so I would really appreciate some help.

Basically, the program runs a PDF to count the number of times an “X” word appears in the document. After finding the number, the program lists the context in which those words appeared. However, it counts ALL the words "X"s and I would like that after the word “References”, also present in the document, it stops counting. How can I do this?

Your question doesn’t seem to have anything to do with the subject line, “Delete all identical words after a character/command”.

What is “the program”?

Do you have access to the source code of this program so you can modify it? Or are you looking for additional tools to run on the output?

Do you mean it literally only counts the word “X” (one letter word, the letter after W and before Y) or is X just a stand-in for something else?

What happens if the PDF document happens to have the word “References” somewhere in the middle of a paragraph?

And how are you reading the PDF?