Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 494: Add normalization to shrink consecutive whitespace to a single space #550

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions silnlp/common/normalize_extracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import argparse
import logging
import os
import re

from dataclasses import dataclass

Expand Down Expand Up @@ -89,12 +90,12 @@ def normalized_path(output_dir: Path, input_path: Path) -> Path:
return output_dir / output_filename


consecutive_spaces = re.compile("\\s+")
def normalize(extract_sentence: str) -> str:
"""
Returns a normalized version of the input string.
"""
# TODO
return extract_sentence
return re.sub(consecutive_spaces, " ", extract_sentence)


def load_extract_file(path: Path) -> List[str]:
Expand Down