This may be determined by the location of changes in the chord outlined in the melody. Leaps in melodies outline chords. So, leaps are important clues for chords. The notes outlining leaps are often members of the same chord. This is a good place to start with sight harmonization.
Form is a very important consideration.
Compare the four phrases. Phrase 2 is identical to phrase 4. Phrase 1 is a question compared to phrase 2. The two form an antecedent and consequent, a period consisting of parallel phrases. In fact, phrase 2 is very similar to phrase 1.