Skip to content

Latest commit

 

History

History
31 lines (18 loc) · 1.4 KB

README.md

File metadata and controls

31 lines (18 loc) · 1.4 KB

Expand

The reverse of abbreviation.

Origin

Some friends asked me what clanchun means, I usually told them that it means the bright Spring, cause I got 灿烂春 when I first time typed clanchun using a Chinese pinyin input method :) But, can it be the abbreviation of any phrase? Just like imho could be in my humble opinion.

Algorithm

The key algorithm is Markov Chain. Given a training text, build all possible Markov States where the state is a two-word prefix and a suffix which is a set of words that follows this prefix in the training text. Then, if start with any state and randomly choose one word from the suffix, a reasonably meaningful text will be generated. But, except choosing a random word, here, the next word is choosed according to the next character in the given abbreviation. Hopefully, some phrases could be generated.

Usage

clang++(g++) expand.cpp -o expand

cat input.txt | ./expand any_abbr

Result

After trying several novels downloaded from Project Gutenberg and even putting them all together, not one phrase of clanchun was generated. Cause the generation mostly stopped at clanch, I splited clanchun into clanc and hun, finally, I got a phrase:

came like a noble child, his unfinished novel.

Unfortunately, this phrase still doesn't make too much sense. so I insist that clanchun means:

the bright Spring.