1. A non-transitory computer-readable recording medium having stored therein an encoding program that causes a computer to execute a process comprising: detecting a duplicating part in an encoding target and a first plurality of words in an encoded output, by comparing a particular unit in the encoding target and the first plurality of words that are encoded in the encoded output, the particular unit including a second plurality of words, when encoding the encoding target from an input text; encoding the duplicating part in the encoding target to an first dynamic code by a dynamic encoding; and replacing a first encoded part including the duplicating part in the encoded output to the first dynamic code.