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
| from flask import Flask, request, jsonify | |
| import spacy | |
| app = Flask(__name__) | |
| nlp = spacy.load("en_core_web_sm") | |
| def extract_people(text: str): | |
| entities = nlp(text) | |
| full_names = set() |
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
| [ | |
| { | |
| "text": "Lisa Turner", | |
| "person": { | |
| "firstName": "lisa", | |
| "lastName": "turner", | |
| "honorific": "", | |
| "presumed_gender": "female" | |
| } | |
| }, |
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
| import nlp from 'compromise' | |
| let doc = nlp(` | |
| Lisa Turner and Mark Davis went to the park together. They enjoyed a picnic and played frisbee under the warm sun. Lisa brought sandwiches, while Mark brought refreshing drinks. They laughed, shared stories, and had a great time in each other's company. As the day unfolded, Lisa Turner and Mark Davis realized how much they cherished these simple moments together. | |
| `) | |
| doc.people().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
| ocr_notebook_map = { | |
| "easyocr": "easyocr.ipynb", | |
| "pytesseract": "pytesseract.ipynb", | |
| "kerasocr": "kerasocr.ipynb", | |
| "paddle": "paddle.ipynb", | |
| "tensorflow": "tensorflow.ipynb" | |
| } | |
| def run_ocr(CONFIG): | |
| if CONFIG.get("skip_ocr_processing", False): |
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
| config = { | |
| "directory": "OCR/Invoices1", | |
| "ocr_library": "pytesseract", | |
| "output_file": "results-bc-without.txt", | |
| "statistics_file": "statistics-bc-without.txt", | |
| "apply_cropping": False, | |
| "resize_to_fhd": True, | |
| "deskew_image": True, | |
| "threshold_method": "niblack", | |
| "skip_ocr_processing": False, |
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
| <?php | |
| // 1. | |
| $isUserModerator = $user->isType(‘moderator’); | |
| class User { | |
| // . . . | |
| public function isType(string $type): bool | |
| { |
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
| <?php | |
| $type = $user->type(‘moderator’); |
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
| <?php | |
| class Generator { | |
| public function generateJsonFile(array $data): void; | |
| { | |
| $content = json_encode($data); | |
| header(‘Content-Type: application/json`); | |
| header(‘Content-Disposition: attachment; filename="data.json”`); | |
| ob_start(); |
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
| <?php | |
| class Generator { | |
| private const JSON_TYPE = ‘application/json’; | |
| private const CSV_TYPE = ‘text/csv’; | |
| private const JSON_EXT = ‘json’; | |
| private const CSV_EXT = ‘csv’; | |
| private function disposition( | |
| string $filename, |
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
| <?php | |
| class Generator { | |
| // . . . | |
| public function generate(string $filename, array $data, string $fileType): void { | |
| $content = $this->generateContent($data, $fileType); | |
| $this->disposition($filename, $content, $fileType); | |
| } | |
| } |