1- use std:: path:: Path ;
2- use docx_parser:: MarkdownDocument ;
3- use text_splitter:: ChunkConfigError ;
41use crate :: markdown_processor:: MarkdownProcessor ;
52use crate :: processor:: { Document , DocumentProcessor , FileProcessor } ;
3+ use docx_parser:: MarkdownDocument ;
4+ use std:: path:: Path ;
5+ use text_splitter:: ChunkConfigError ;
66
77/// A struct for processing PDF files.
88pub struct DocxProcessor {
@@ -12,9 +12,7 @@ pub struct DocxProcessor {
1212impl DocxProcessor {
1313 pub fn new ( chunk_size : usize , overlap : usize ) -> Result < DocxProcessor , ChunkConfigError > {
1414 let markdown_processor = MarkdownProcessor :: new ( chunk_size, overlap) ?;
15- Ok ( DocxProcessor {
16- markdown_processor,
17- } )
15+ Ok ( DocxProcessor { markdown_processor } )
1816 }
1917}
2018
@@ -34,16 +32,20 @@ mod tests {
3432 let txt_file = "../test_files/test.docx" ;
3533 let processor = DocxProcessor :: new ( 128 , 0 ) . unwrap ( ) ;
3634
37- let text = processor. process_file ( & txt_file) . unwrap ( ) ;
38- assert ! ( text. chunks. contains( & "This is a docx file test" . to_string( ) ) ) ;
35+ let text = processor. process_file ( txt_file) . unwrap ( ) ;
36+ assert ! ( text
37+ . chunks
38+ . contains( & "This is a docx file test" . to_string( ) ) ) ;
3939 }
4040
4141 // Returns an error if the file path is invalid.
4242 #[ test]
43- #[ should_panic( expected = "Error processing file: IO(Os { code: 2, kind: NotFound, message: \" No such file or directory\" })" ) ]
43+ #[ should_panic(
44+ expected = "Error processing file: IO(Os { code: 2, kind: NotFound, message: \" No such file or directory\" })"
45+ ) ]
4446 fn test_extract_text_invalid_file_path ( ) {
4547 let invalid_file_path = "this_file_definitely_does_not_exist.docx" ;
4648 let processor = DocxProcessor :: new ( 128 , 0 ) . unwrap ( ) ;
47- processor. process_file ( & invalid_file_path) . unwrap ( ) ;
49+ processor. process_file ( invalid_file_path) . unwrap ( ) ;
4850 }
4951}
0 commit comments