Skip to content

Commit

Permalink
Apply ruff import fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rlskoeser committed Aug 27, 2024
1 parent c28798b commit a327759
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 30 deletions.
10 changes: 5 additions & 5 deletions scripts/evaluate_ocr.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import csv
import os
import sys
import spacy
import csv
import orjsonl

from xopen import xopen
from tqdm import tqdm
import orjsonl
import spacy
from lingua import LanguageDetectorBuilder
from ocr_helper import clean_chars
from tqdm import tqdm
from xopen import xopen


class OCREvaluator:
Expand Down
11 changes: 5 additions & 6 deletions scripts/get_character_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@
env: ppa-ocr
"""

import sys
import os.path
import csv
import os.path
import sys
import unicodedata
from collections import Counter

import orjsonl
from collections import Counter
from xopen import xopen
from tqdm import tqdm
from ocr_helper import clean_chars

from tqdm import tqdm
from xopen import xopen

__cc_names = {
"\n": "Cc: LINE FEED",
Expand Down
1 change: 0 additions & 1 deletion scripts/ocr_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import ftfy


_char_conversion_map = {"ſ": "s"}
_char_translation_table = str.maketrans(_char_conversion_map)

Expand Down
8 changes: 4 additions & 4 deletions src/corppa/ocr/gvision_ocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
This script OCRs images using the Google Vision API.
"""

import os
import sys
import argparse
import io
import os
import pathlib
import argparse
import sys

from corppa.utils.path_utils import get_ppa_source, get_vol_dir
from tqdm import tqdm
from corppa.utils.path_utils import get_vol_dir, get_ppa_source

# Attempt to import Google Cloud Vision Python Client
try:
Expand Down
2 changes: 1 addition & 1 deletion src/corppa/poetry_detection/annotation/add_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import sys
from typing import Iterator

from tqdm import tqdm
import orjsonl
from tqdm import tqdm


def combine_data(
Expand Down
6 changes: 3 additions & 3 deletions src/corppa/poetry_detection/annotation/create_pageset.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"""

import csv
import os.path
import json
import os.path
import re
import sys

import orjsonl
from xopen import xopen
from tqdm import tqdm
from helper import encode_htid, get_stub_dir
from tqdm import tqdm
from xopen import xopen


def extract_page_numbers(page_url_list):
Expand Down
8 changes: 4 additions & 4 deletions src/corppa/poetry_detection/annotation/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
prodigy annotate_text_and_image poetry_text_image poetry_pages.jsonl --label POETRY -F ../corppa/poetry_detection/annotation/recipe.py --image-prefix http://localhost:8000/
"""

from prodigy.core import Arg, recipe
from prodigy.components.loaders import JSONL
import spacy

from pathlib import Path

import spacy
from prodigy.components.loaders import JSONL
from prodigy.core import Arg, recipe

#: reference to current directory, for use as Prodigy CSS directory
CURRENT_DIR = Path(__file__).parent.absolute()

Expand Down
2 changes: 1 addition & 1 deletion src/corppa/utils/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

import argparse
import os.path
from typing import Iterator
import sys
from typing import Iterator

import orjsonl
from orjson import JSONDecodeError
Expand Down
3 changes: 1 addition & 2 deletions test/test_utils/test_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
from unittest.mock import patch

import pytest

from corppa.utils.filter import filter_pages, save_filtered_corpus, main
from corppa.utils.filter import filter_pages, main, save_filtered_corpus

# minimal/mock page data fixture for testing
fixture_page_data = [
Expand Down
6 changes: 3 additions & 3 deletions test/test_utils/test_path_utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import pathlib
import pytest

from unittest.mock import patch

import pytest
from corppa.utils.path_utils import (
encode_htid,
decode_htid,
encode_htid,
get_ppa_source,
get_stub_dir,
get_vol_dir,
Expand Down

0 comments on commit a327759

Please sign in to comment.