slm / tests /test_extractive.py
primenumbersam's picture
feat: implement Frontier SLM Comparison & Text Summarizers
97d08f3
Raw History Blame Contribute Delete
1.6 kB
import pytest
from extractive import is_korean_text, split_sentences, lexrank_summary
KO_TEXT = """
한국은행 금융통화위원회는 다음 통화정책방향 결정시까지 기준금리를 현 수준에서 유지하기로 하였다.
국내 경제는 완만한 성장세를 이어가고 있으나 가계부채와 부동산 시장 상황을 유의할 필요가 있다.
물가상승률은 둔화 흐름을 지속하고 있으며 환율 변동성 확대에 유의해야 한다.
금융안정 측면의 리스크를 면밀히 점검하면서 향후 금리 인하 시기를 신중하게 판단해 나갈 것이다.
"""
EN_TEXT = """
The Federal Reserve is committed to using its full range of tools to support the U.S. economy.
Inflation has eased over the past year but remains elevated above our target.
The Committee does not expect it will be appropriate to reduce the target range until it has gained greater confidence.
Recent economic indicators show continued solid job gains and low unemployment.
"""
def test_is_korean_text():
assert is_korean_text(KO_TEXT) is True
assert is_korean_text(EN_TEXT) is False
def test_split_sentences():
ko_sents = split_sentences(KO_TEXT, is_korean=True)
assert len(ko_sents) >= 4
en_sents = split_sentences(EN_TEXT, is_korean=False)
assert len(en_sents) >= 4
def test_lexrank_summary():
summary_ko, t_ko = lexrank_summary(KO_TEXT, sentence_count=2)
assert len(summary_ko) > 0
assert t_ko >= 0
summary_en, t_en = lexrank_summary(EN_TEXT, sentence_count=2)
assert len(summary_en) > 0
assert t_en >= 0