initial
This commit is contained in:
5
README.md
Normal file
5
README.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# di
|
||||||
|
|
||||||
|
*From little fig, while groves halfway.*
|
||||||
|
|
||||||
|
An implementation of the Diastic technique.
|
20
di.py
Normal file
20
di.py
Normal 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))
|
Reference in New Issue
Block a user