Tag: 词典

Word解析器脚本和实现memoization

描述 给定一个字典,我的程序生成两个输出文件,’sequences.txt’和’words.txt’。 ‘sequences’包含四个字母(Az)的每个序列,它们恰好出现在字典的一个单词中,每行一个序列。 ‘words’将包含包含序列的相应单词,顺序相同,每行一次。 例如,给定spec/fixtures/sample_words.txt字典仅包含 arrows carrots give me 产出应该是: ‘sequences’ ‘words’ carr carrots give give rots carrots rows arrows rrot carrots rrow arrows 当然,’arro’不会出现在输出中,因为它出现在多个单词中。 到目前为止我想出了什么 项目结构: ├── Gemfile ├── Gemfile.lock ├── examples │ └── dictionary.txt ├── lib │ └── word_sequence_parser.rb ├── main.rb ├── output ├── readme.md └── spec ├── fixtures │ └── sample_words.txt └── […]