-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f5ab4a
commit 596582e
Showing
5 changed files
with
88 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from datrie._datrie_impl import DoubleArrayTrie | ||
|
||
if __name__ == "__main__": | ||
trie = DoubleArrayTrie( | ||
{ | ||
"아버지": "NNG", | ||
"가": "JKS", | ||
"방": "NNG", | ||
"에": "JKB", | ||
"들어오": "VV", | ||
"신다": "EP+EF", | ||
".": "SP", | ||
} | ||
) | ||
|
||
print(trie["아버지"]) # NNG | ||
print(trie["신다"]) # EP+EF | ||
|
||
filename = "file.dat" | ||
trie.save(filename) | ||
|
||
trie2 = DoubleArrayTrie.load(filename) | ||
print(trie2["아버지"]) # NNG | ||
print(trie2["신다"]) # EP+EF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from datrie._datrie_simple import SimpleDoubleArrayTrie | ||
|
||
if __name__ == "__main__": | ||
trie = SimpleDoubleArrayTrie() | ||
trie.put("ABC") | ||
trie.put("DEF") | ||
|
||
print(f"AB: {trie.find('AB')}") # PARTIAL_MATCH | ||
print(f"ABC: {trie.find('ABC')}") # PERFECT_MATCH | ||
print(f"DE: {trie.find('DE')}") # PARTIAL_MATCH | ||
print(f"DEF: {trie.find('DEF')}") # PERFECT_MATCH | ||
print(f"EF: {trie.find('EF')}") # NOT_FOUND | ||
|
||
trie.remove("ABC") | ||
print(f"ABC: {trie.find('ABC')}") # NOT_FOUND |