├── README.md └── scanner.py /README.md: -------------------------------------------------------------------------------- 1 | Text Scanner 2 | The text scanner tool is a Python script that allows you to search for a specific line within a text document. It provides a simple and efficient way to find matches and extract relevant information from large files. 3 | 4 | 5 | 6 | Features 7 | 8 | • Searches for a specific line within a text document 9 | • Ignores punctuation and capitalization for more accurate matching 10 | • Provides the matched line(s) as output 11 | 12 | 13 | 14 | Usage 15 | 1. Ensure that you have Python 3 installed on your system. 16 | 17 | 2. Clone this repository or download the scanner.py file. 18 | 3. Open a terminal and navigate to the directory where the scanner.py file is located. 19 | 20 | 4. Run the script using the following command: 21 | python3 scanner.py 22 | Replace with the line you want to search for, and with the path to the text document you want to scan. The script will search for the provided line in the text document and display any matching lines found. 23 | 24 | If you encounter any errors related to missing dependencies, make sure to install them using the pip package manager: 25 | 26 | pip3 install argparse 27 | 28 | pip3 install regex 29 | 30 | Please note that the script assumes the input text document is in plain text format. 31 | Feel free to customize and modify the code as needed for your specific use case. 32 | -------------------------------------------------------------------------------- /scanner.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import re 3 | 4 | def normalize_line(line): 5 | line = re.sub(r'[^\w\s]', '', line).lower() 6 | line = re.sub(r'\s+', '', line) 7 | return line 8 | 9 | def scan_text_document(input_line, text_document): 10 | with open(text_document, 'r') as file: 11 | lines = file.readlines() 12 | 13 | normalized_input_line = normalize_line(input_line) 14 | 15 | for line in lines: 16 | normalized_line = normalize_line(line) 17 | 18 | if normalized_input_line in normalized_line: 19 | print(f"Match found: {line.strip()}") 20 | 21 | if __name__ == '__main__': 22 | parser = argparse.ArgumentParser(description='Line Scanner Tool') 23 | parser.add_argument('line', help='line to search for') 24 | parser.add_argument('text_document', help='path to the text document') 25 | 26 | args = parser.parse_args() 27 | 28 | scan_text_document(args.line, args.text_document) 29 | --------------------------------------------------------------------------------