Created
August 10, 2014 15:42
-
-
Save kyu999/dc1576ce8c7e41831213 to your computer and use it in GitHub Desktop.
改行からのjson化
This file contains hidden or 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
def json_articles(self): | |
""" | |
複数動作確認用 | |
""" | |
f = open("sample_title.txt", "r") | |
lines = f.readlines() | |
cleaner = title_cleaner.TitleCleaner() | |
articles = [] | |
for line in lines: | |
unicoded_line = cleaner.normalize(unicode(line, "utf-8")) | |
breaks = self.get_break_points(unicoded_line) | |
json_data = {"title": unicoded_line, "title_break_position": breaks} | |
articles.append(json_data) | |
f.close() | |
return {"response": {"article": articles}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment