Browse Source

[MNT] format code by black

tags/v0.3.2
Gene 2 years ago
parent
commit
e029674ca8
3 changed files with 11 additions and 4 deletions
  1. +2
    -2
      learnware/market/easy2/checker.py
  2. +7
    -1
      learnware/specification/__init__.py
  3. +2
    -1
      learnware/specification/regular/text/rkme.py

+ 2
- 2
learnware/market/easy2/checker.py View File

@@ -91,7 +91,7 @@ class EasyStatisticalChecker(BaseChecker):
if stat_spec.get_z().shape[1:] != input_shape:
logger.warning(f"The learnware [{learnware.id}] input dimension mismatch with stat specification.")
return self.INVALID_LEARNWARE
def generate_random_text_list(num, text_type="en", min_len=10, max_len=1000):
text_list = []
for i in range(num):
@@ -106,7 +106,7 @@ class EasyStatisticalChecker(BaseChecker):
else:
raise ValueError("Type should be en or zh")
return text_list
if is_text:
inputs = generate_random_text_list(10)
else:


+ 7
- 1
learnware/specification/__init__.py View File

@@ -1,3 +1,9 @@
from .utils import generate_stat_spec, generate_rkme_spec, generate_rkme_image_spec
from .base import Specification, BaseStatSpecification
from .regular import RegularStatsSpecification, RKMEStatSpecification, RKMETableSpecification, RKMEImageSpecification, RKMETextSpecification
from .regular import (
RegularStatsSpecification,
RKMEStatSpecification,
RKMETableSpecification,
RKMEImageSpecification,
RKMETextSpecification,
)

+ 2
- 1
learnware/specification/regular/text/rkme.py View File

@@ -10,6 +10,7 @@ logger = get_module_logger("RKMETextSpecification", "INFO")

class RKMETextSpecification(RKMETableSpecification):
"""Reduced Kernel Mean Embedding (RKME) Specification for Text"""

def __init__(self, gamma: float = 0.1, cuda_idx: int = -1):
RKMETableSpecification.__init__(self, gamma, cuda_idx)
self.language = []
@@ -59,7 +60,7 @@ class RKMETextSpecification(RKMETableSpecification):
@staticmethod
def get_language_ids(X):
try:
text = ' '.join(X)
text = " ".join(X)
lang = langdetect.detect(text)
langs = langdetect.detect_langs(text)
return [l.lang for l in langs]


Loading…
Cancel
Save