I have some problems to relate some sentences to each other, specially when they get long. I observed "to" and "for" could be used for such relations, but don't know their proper usage and their differences.
For example I am writing a sentence
In this paper, we propose a formalism to construct a wrapper for extracting [or to extract?] structured data from a Web page.
In this paper, we propose a formalism for constructing a wrapper to extract [or for extracting?] structured data from a Web page.
To avoid repetition of "for" or "to", in each sentence, for the second clause I used the other alternative.
What is the general rule? Are all the four combination of "to" and "for" in my sentence, correct?
By the way, how can I get mastered with sentences combination.