Skip to content
Discussion options

You must be logged in to vote

Alright sounds good, I have made:

import json
import multiprocessing
import subprocess
from collections.abc import Collection, Mapping
from enum import IntEnum

from tqdm import tqdm


class TyposReturnCodes(IntEnum):
    """Return codes for the `typos` spellchecker."""

    NO_TYPOS_FOUND = 0
    TYPOS_FOUND = 2


def invoke_typos(text: str) -> Mapping[str, Collection[str]]:
    """Invoke the spellchecker `typos` as a subprocess on the input paragraphs.

    Returns:
        Mapping of typos to their suggested fixes.
    """
    try:
        result = subprocess.run(
            ("typos", "-", "--format", "json"),
            input=text,
            text=True,
            capture_output=True

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jamesbraza
Comment options

Answer selected by jamesbraza
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants