What is the difference between the two and and should I say "a part of the text" or "a segment of the text"?
Some objects are naturally segmented, they have marks or narrowings between segments. These are places where the object can be easily and naturally separated. The segments are usually all alike in form. Think of an orange.
Some objects are compound objects that consist of an assembly of smaller dissimilar objects. We can separate these compound objects these into their constituent parts. Think of an internal combustion engine.
Some objects don't have obvious segments but can still be divided into pieces at arbitrary points. The pieces need not be even in size and there is an undertone of destructive or irreversible breaking. Think of a (stereotypical circular uniform) cake.
Some objects, when subjected to some sufficiently violent force, can shatter into multiple fragments of mostly random size and shape. If the other fragments are lost, you may find only one fragment and have no other knowledge of the form of the whole object. Think of a dropped Ming vase.
Some objects are designed to be cut apart or are commonly cut apart. The word section is derived from the Latin word for cutting and may be appropriate for a deliberate and careful cutting of some extract from a larger source. There is, to me, an implication that the cutting points are not accidental. Think of plumbing pipes
Written English language text is usually written in sentences, paragraphs and perhaps chapters. These form obvious segmentation points, so when your extract is made at a balanced pair of such boundaries, the term segment is more appropriate. However, why not just use sentence or paragraph as appropriate?
If you spilled ink onto a page of text, it might be better to say that a part of the text was obscured - since (unless by unlikely coincidence) the obscured part is not an exact sentence or paragraph.
If a page of text is burnt or torn and scattered, you might consider any remainder to be a fragment.
As HorusKul commented, since successive English sentences are not often very similar, they are not very much like segments and the word section is more likely to be appropriate.
Updated to clarify segments, pieces, parts and sections. Updated: fragments.