本文整理汇总了Python中book.Book.read_book方法的典型用法代码示例。如果您正苦于以下问题:Python Book.read_book方法的具体用法?Python Book.read_book怎么用?Python Book.read_book使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类book.Book
的用法示例。
在下文中一共展示了Book.read_book方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_read_book
# 需要导入模块: from book import Book [as 别名]
# 或者: from book.Book import read_book [as 别名]
def test_read_book():
book = Book('test/test_text_file.txt')
book.read_book()
chapters = book.get_chapters
assert len(chapters) == 2
assert chapters[0].get('title') == 'Chapter 1'
sentences = chapters[0].get('sentences')
assert len(sentences) == 4
示例2: parse_all_books
# 需要导入模块: from book import Book [as 别名]
# 或者: from book.Book import read_book [as 别名]
def parse_all_books():
for file in glob.glob("{}/*.txt".format(book_dir)):
print("Parsing... {}".format(file))
book = Book(file)
book.read_book()
book.count_distinct_words()
print(book)
all_books.append(book)