Code to filter out repeated words

Please, can someone help me write this code or teach me how to write it. Thank you.
I have a Word file that has repeated words. Here is the explanation below:
Examples of a verse:
  1. Mat 6:27
  2. Luk 2:52
Example of a version:
  1. ABP+
  2. AMP
Example of a sentence:
  1. Mat 6:27 (ABP+) And whoG5100 G1161 ofG1537 youG1473 being anxiousG3309 is ableG1410 to addG4369 untoG1909 G3588 his statureG2244 G1473 [2cubitG4083 1one]?G1520
  2. Luk 2:52 (AMP) And Jesus kept increasing in wisdom and in stature, and in favor with God and men. [1Sa 2:26]
There are repetition of verses in the file, but in some cases, there are no repetitions.
For example, Mat 6:27 occurs two times, but Col 2:10 occurs only once.
The Code I want to write:
I want to write a code that will check through various sentences containing a verse and write out just one verse, in the order of version priority and put the remaining version in square bracket.
I want to write a code that will do the following:
  1. Create a new word doc and name it “processed_stature.txt” to write the result
  2. Search for all sentences containing the first verse (In this case, "Mat 6:27") in the file “stature.txt” (attached)
  3. Then search for sentence containing “NIV”
  4. If there is a sentence for “Mat 6:27” containing “NIV”, then write that sentence in the file “processed_stature.txt”
  5. Then on the next row after the sentence, write other versions that have the first verse (In this case “Mat 6:27”), separating each with comma, and putting them in a square bracket.
  6. Then move to the next verse (In this case “Luk 2:52”) and repeat the process.
  7. But if there is no sentence containing “NIV”, then search for “NKJV”
  8. If there is a sentence for “Mat 6:27” containing “NKJV”, then write that sentence in the file “processed_stature.txt”
  9. Then on the next row after that sentence, write other versions that have the first verse (In this case “Mat 6:27”), separating each with comma, and putting them in a square bracket.
  10. Then move to the next verse (In this case “Luk 2:52”) and repeat the process
  11. But if there is no “NKJV” then write the entire sentence of the first available version in the file “processed_stature.txt”
  12. Then on the next row, write other versions that have the first verse (In this case “Mat 6:27”), separating each with comma, and putting them in a square bracket.
  13. Then move to the next verse (In this case “Luk 2:52”) and repeat the process.
  14. Repeat this process until we get to the end of the document.
Result
The outcome of first iteration in the file "processed_stature.txt" will be this:
Mat 6:27 (NKJV) Which of you by worrying can add one cubit to his stature?
[ABP+]
The outcome of second iteration in the file "processed_stature.txt" will look like this:
Mat 6:27 (NKJV) Which of you by worrying can add one cubit to his stature?
[ABP+]
Luk 2:52 (NIV) And Jesus grew in wisdom and stature, and in favor with God and man.
[ABP+, AMP, NKJV]
.................................
stature.txt
Mat 6:27 (ABP+) And whoG5100 G1161 ofG1537 youG1473 being anxiousG3309 is ableG1410 to addG4369 untoG1909 G3588 his statureG2244 G1473 [2cubitG4083 1one]?G1520
Luk 2:52 (ABP+) AndG2532 JesusG* progressedG4298 in wisdomG4678 andG2532 stature,G2244 andG2532 in favorG5484 withG3844 GodG2316 andG2532 men.G444
Luk 12:25 (ABP+) But whoG5100 G1161 ofG1537 youG1473 being anxiousG3309 is ableG1410 to addG4369 untoG1909 G3588 his statureG2244 G1473 [2cubitG4083 1one]?G1520
Luk 19:3 (ABP+) AndG2532 he was seekingG2212 to seeG1492 G3588 Jesus,G* whoG5100 he is.G1510.2.3 AndG2532 he was not ableG3756 G1410 becauseG575 of theG3588 multitude,G3793 forG3754 his G3588 statureG2244 was small.G3397 G1510.7.3
Eph 4:13 (ABP+) untilG3360 we should [2arriveG2658 G3588 1all]G3956 inG1519 theG3588 unityG1775 of theG3588 belief,G4102 andG2532 of theG3588 full knowledgeG1922 of theG3588 sonG5207 G3588 of God,G2316 inG1519 [2manG435 1a perfect],G5046 inG1519 the measureG3358 of the statureG2244 of theG3588 fullnessG4138 of theG3588 Christ;G5547
Jas 1:9 (ABP+) [2let 6boastG2744 1ButG1161 3theG3588 5brotherG80 G3588 4humble]G5011 inG1722 G3588 his stature,G5311 G1473
Luk 2:52 (AMP) And Jesus kept increasing in wisdom and in stature, and in favor with God and men. [1Sa 2:26]
Luk 19:3 (AMP) Zaccheus was trying to see who Jesus was, but he could not see because of the crowd, for he was short in stature.
Col 2:10 (AMP) And in Him you have been made complete [achieving spiritual stature through Christ], and He is the head over all rule and authority [of every angelic and earthly power].
Luk 2:52 (NIV) And Jesus grew in wisdom and stature, and in favor with God and man.
Mat 6:27 (NKJV) Which of you by worrying can add one cubit to his stature?
Luk 2:52 (NKJV) And Jesus increased in wisdom and stature, and in favor with God and men.
Luk 12:25 (NKJV) And which of you by worrying can add one cubit to his stature?
Luk 19:3 (NKJV) And he sought to see who Jesus was, but could not because of the crowd, for he was of short stature.
Eph 4:13 (NKJV) till we all come to the unity of the faith and of the knowledge of the Son of God, to a perfect man, to the measure of the stature of the fullness of Christ;

5 Commenti

Please, I will appreciate your help asap
dpb
dpb il 1 Ago 2023
Don't want a lot, do you...what have you done so far?
Answers is a VOLUNTEER forum for specific MATLAB related questions, it is not a free general consulting service; your question as formulated is not appropriate.
Thank you. I have the pseudo code in my head, but I don't know how to convert it to a code in matlab. That is why I am asking for help. I will appreciate any help I can get to put me through. I have a bigger file with more information to solve, but if I can get help with this sample problem, I will be able to attempt the bigger file. It would be messy if I start asking multiple questions; that is the reason I formulated my question like that. Thank you for your comment.
Yes. But as you are asking the question, you are asking someone to write the entire code for you, with no thought invested on your part. In the end, you get your homework done for you, and go away happy, to then ask another question for someone else to do your next project. But that is not how Answers can work, and it is not how you will learn. You need to start writing, even if it is complete crap to start. All of us wrote crap code at first. (Well except for me, and my code started out completely perfect. NOT.)
I recommend that at least you show us the pseudocode you've devised and your attempt to start implementing it. Once we see how far you've gotten, if you ask a specific question about where you're having difficulty we may be able to provide some guidance about how you can proceed further.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the free MATLAB Onramp tutorial to quickly learn the essentials of MATLAB.

Risposte (0)

Questa domanda è chiusa.

Prodotti

Release

R2023a

Richiesto:

il 1 Ago 2023

Chiuso:

dpb
il 1 Ago 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by