TAILIEUCHUNG - Natural Language Processing with Python Phần 6

Ở đây, thẻ là một danh sách sáp nhập của các thẻ từ các câu cá nhân, và ranh giới là một tập hợp bao gồm các chỉ số của tất cả các thẻ câu biên giới. | The first step is to obtain some data that has already been segmented into sentences and convert it into a form that is suitable for extracting features sents tokens boundaries set offset 0 for sent in . sent . offset len sent . offset-1 Here tokens is a merged list of tokens from the individual sentences and boundaries is a set containing the indexes of all sentence-boundary tokens. Next we need to specify the features of the data that will be used in order to decide whether punctuation indicates a sentence boundary def punct_features tokens i . return next-word-capitalized tokens i 1 0 .isupper . prevword tokens i-1 .lower . punct tokens i . prev-word-is-one-char len tokens i-1 1 Based on this feature extractor we can create a list of labeled featuresets by selecting all the punctuation tokens and tagging whether they are boundary tokens or not featuresets punct_features tokens i i in boundaries . for i in range 1 len tokens -1 . if tokens i in . Using these featuresets we can train and evaluate a punctuation classifier size int len featuresets train_set test_set featuresets size featuresets size classifier train_set classifier test_set To use this classifier to perform sentence segmentation we simply check each punctuation mark to see whether it s labeled as a boundary and divide the list of words at the boundary marks. The listing in Example 6-6 shows how this can be done. Example 6-6. Classification-based sentence segmenter. def segment_sentences words start 0 sents for i word in words if word in . and words i True words start i 1 start i 1 if start len words words start 234 Chapter 6 Learning to Classify Text Identifying Dialogue Act Types When processing dialogue it can be useful to think of utterances as a type of action performed by the .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.