Skip to content

Instantly share code, notes, and snippets.

@wolfmanstout
wolfmanstout / test_winrt_ocr.py
Created July 29, 2020 06:40
Demonstrates using Python winrt to run OCR. Requires Python 3.7+.
import asyncio
import os
import winrt
from PIL import Image
from winrt.windows.graphics.imaging import BitmapDecoder, BitmapPixelFormat, SoftwareBitmap
from winrt.windows.media.ocr import OcrEngine
from winrt.windows.storage import StorageFile, FileAccessMode
import winrt.windows.storage.streams as streams
@wolfmanstout
wolfmanstout / extract_sentences.py
Created July 30, 2017 22:46
Extracts all sentences from posts and pages in exported WordPress XML.
#!/usr/bin/env python
import sys
from bs4 import BeautifulSoup
from bs4 import SoupStrainer
from nltk import tokenize
from xml.etree import ElementTree
NAMESPACES = {
'content': 'http://purl.org/rss/1.0/modules/content/',