This commit is contained in:
2017-09-27 16:15:57 +02:00
commit 5658e0ac46
2 changed files with 25 additions and 0 deletions

5
README.md Normal file
View File

@@ -0,0 +1,5 @@
# di
*From little fig, while groves halfway.*
An implementation of the Diastic technique.

20
di.py Normal file
View File

@@ -0,0 +1,20 @@
import sys
def diastic(word, phrases):
words = []
cur = 0
for idx, c in enumerate(word):
for nxt, phrase in enumerate(phrases[cur:]):
if len(phrase) > idx and phrase[idx] == c:
words.append(phrase)
cur = idx + 1
break
return " ".join(words)
if __name__ == "__main__":
with open(sys.argv[2]) as f:
words = f.read().split()
print(diastic(sys.argv[1], words))