Skip to content

Commit

Permalink
fix: use relative path to import to fix ImportError
Browse files Browse the repository at this point in the history
  • Loading branch information
DoodleBears committed Jun 30, 2024
1 parent 4a960e3 commit f9ed172
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions langsplit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .split.splitter import split, split_by_lang, TextSplitter
from .detect_lang.detector import DEFAULT_LANG, LANG_MAP
from .split.model import SubString, SubStringSection
from .detect_lang.detector import LANG_MAP, DEFAULT_LANG
from .split.splitter import TextSplitter, split, split_by_lang
1 change: 1 addition & 0 deletions langsplit/detect_lang/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .detector import LANG_MAP, DEFAULT_LANG, detect_lang, fast_detect_lang
4 changes: 2 additions & 2 deletions langsplit/detect_lang/detector.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from langdetect import detect
import langdetect
import fast_langdetect

LANG_MAP = {
Expand All @@ -15,7 +15,7 @@


def detect_lang(text: str) -> str:
result = str(detect(text))
result = str(langdetect.detect(text))
result = result.lower()
return result

Expand Down
1 change: 1 addition & 0 deletions langsplit/split/model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import List

from pydantic import BaseModel


Expand Down
15 changes: 6 additions & 9 deletions langsplit/split/splitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@
from langdetect.lang_detect_exception import LangDetectException
from wtpsplit import SaT, WtP

from langsplit.detect_lang.detector import (
DEFAULT_LANG,
LANG_MAP,
detect_lang,
fast_detect_lang,
)
from langsplit.split.utils import contains_zh_ja_ko, PUNCTUATION, DEFAULT_THRESHOLD
from langsplit.split.model import SubString, SubStringSection
from ..detect_lang.detector import DEFAULT_LANG, LANG_MAP, detect_lang, fast_detect_lang
from .model import SubString, SubStringSection
from .utils import DEFAULT_THRESHOLD, PUNCTUATION, contains_zh_ja_ko

logging.basicConfig(
level=logging.DEBUG,
Expand All @@ -34,7 +29,9 @@ class TextSplitter:
def __init__(self, wtp_split_model: WtP | SaT = WtP("wtp-bert-mini")):
self.wtp_split_model = wtp_split_model

def split(self, text: str, threshold: float = DEFAULT_THRESHOLD, verbose=False) -> List[str]:
def split(
self, text: str, threshold: float = DEFAULT_THRESHOLD, verbose=False
) -> List[str]:
"""
Split the given text into substrings.
Expand Down

0 comments on commit f9ed172

Please sign in to comment.