I would like a function that finds repeating sequences of text sections. Would start with defining a number N
. Let I have (setq N 5)
say. I would take the first five text sections, then look for matches of the five text sections, by taking the next five text sections (a shift by one text section) as input. Shifting by one text section each time. Then start again, taking the next five text sections from the beginning, this time shifted by one text section, and repeat again.
Here is an example text
Joseph Rudyard Kipling (30 December 1865 - 18 January 1936)
was an English novelist, short-story writer, poet, and
journalist. He was born in British India, which inspired
much of his work. English novelist, short-story writer,
poet, and journalist.
Kipling's works of fiction include the Jungle Book duology
(The Jungle Book, 1894; The Second Jungle Book, 1895), Kim
(1901), the Just So Stories (1902) and many short stories,
including "The Man Who Would Be King" (1888). His poems
include "Mandalay" (1890), "Gunga Din" (1890), "The Gods of
the Copybook Headings" (1919), "The White Man's Burden"
(1899), and "If-" (1910). He is seen as an innovator in
the art of the short story. His children's books are
classics.
Illustration
Let N = 5
, the function would take the first five text collections as the Search Sequence
.
Joseph Rudyard Kipling (30 December
A search for a match is performed on the rest of the text by getting text shifted by one text section at a time to obtain the Text Extract
.
Joseph Rudyard Kipling (30 December
Rudyard Kipling (30 December 1865
Kipling (30 December 1865 -
and so on, until reaching the end of the buffer.
Then the Search Sequence is updated to
Rudyard Kipling (30 December 1865
and the process is repeated.
Illustration
Let us now arrive at the Search Sequence
novelist, short-story writer, poet, and
we take the Text Extracts
Joseph Rudyard Kipling (30 December
Rudyard Kipling (30 December 1865
Kipling (30 December 1865 -
(30 December 1865 - 18
December 1865 - 18 January
eventually reaching the match with
novelist, short-story writer, poet, and
And we continue to the end of the buffer.
Output
The output would be the line number where the match starts followed by the Search Sequence
4- novelist, short-story writer, poet, and