Skip to content

Commit

Permalink
[#82] functional stylers with proper tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eubinecto committed Jun 21, 2022
1 parent 3ce6b16 commit 2081a37
Show file tree
Hide file tree
Showing 8 changed files with 364 additions and 357 deletions.
5 changes: 5 additions & 0 deletions explore/explore_fetch_environs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from politely import ENVIRONS
from politely import LISTENERS

print(ENVIRONS)
print(LISTENERS)
3 changes: 2 additions & 1 deletion explore/explore_khaiii.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ def main():
print(token)

for sent in sents:
for token in analyser.analyze(sent):
for token in analyser._analyze(sent):
print("=====")
print(token)


"""
# 굉장히 빠르고 정확하다! 띄어쓰기를 훼손하지도 않고... 심플하고... 정확히 내가 바라던 것인 것 같다.
konlpy, kiwi에 걸쳐... 여기에 종착하게 되는 것인가?
Expand Down
2 changes: 1 addition & 1 deletion explore/explore_politely_multiple_stylers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ def main():
styler("hi", 1)


if __name__ == '__main__':
if __name__ == "__main__":
main()
38 changes: 14 additions & 24 deletions main_demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from politely import Styler
from politely import style

SENTS = [
# ㅂ 불규칙
Expand Down Expand Up @@ -27,27 +27,17 @@
"그는 전설이에요",
]

styler = Styler()


def main():
# first way of using it - politeness is not determined
for sent in SENTS:
listener = "friends and junior"
environ = "formal"
styled = styler(sent, listener, environ)
print(sent, "->", styled)
print(styler.logs.honorifics)
print(styler.logs.conjugations)

# the other way of using it - politeness is determined
print("--------")
for sent in SENTS:
ban = styler(sent, 1)
jon = styler(sent, 2)
formal = styler(sent, 3)
print(sent, "->", ban, "|", jon, "|", formal)


if __name__ == "__main__":
main()
# first way of using it - politeness is not determined
for sent in SENTS:
listener = "friends and junior"
environ = "formal"
styled = style(sent, listener, environ)
print(sent, "->", styled)
# the other way of using it - politeness is determined
print("----------------------------------------------")
for sent in SENTS:
ban = style(sent, 1)
jon = style(sent, 2)
formal = style(sent, 3)
print(sent, "->", ban, "|", jon, "|", formal)
Loading

0 comments on commit 2081a37

Please sign in to comment.