Refactor
Signed-off-by: András Schmelczer <andras@schmelczer.dev>
This commit is contained in:
parent
1f8e356ab5
commit
76c9f4a0cd
19 changed files with 205 additions and 165 deletions
|
|
@ -4,7 +4,7 @@ from random import shuffle
|
|||
from devtools import debug
|
||||
from predict_domain import predict_domain
|
||||
|
||||
from good_ai import process_batch, serve
|
||||
from good_ai import process_batch
|
||||
|
||||
if __name__ == "__main__":
|
||||
with open(".cache/data-1/s2-corpus-323.json") as f:
|
||||
|
|
|
|||
7
example/main_service.py
Normal file → Executable file
7
example/main_service.py
Normal file → Executable file
|
|
@ -1,10 +1,9 @@
|
|||
import json
|
||||
from random import shuffle
|
||||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
from devtools import debug
|
||||
from predict_domain import predict_domain
|
||||
|
||||
from good_ai import process_batch, serve
|
||||
from good_ai import serve
|
||||
|
||||
if __name__ == "__main__":
|
||||
serve(predict_domain)
|
||||
|
|
|
|||
|
|
@ -1,23 +1,22 @@
|
|||
import re
|
||||
from typing import Dict, Iterable, List
|
||||
|
||||
|
||||
from config import model_key
|
||||
from models import DomainPrediction
|
||||
from preprocess import preprocess
|
||||
from sklearn.pipeline import Pipeline
|
||||
|
||||
from good_ai import use_model, log_argument, log_metric
|
||||
from good_ai import log_argument, log_metric, use_model
|
||||
from good_ai.utilities.clean import clean
|
||||
|
||||
|
||||
@use_model(model_key, version="latest")
|
||||
@log_argument('text', validator=lambda t: len(t) > 0)
|
||||
@log_argument("text", validator=lambda t: len(t) > 0)
|
||||
def predict_domain(
|
||||
text: str, model: Pipeline, cut_off_probability: float = 0.2
|
||||
) -> List[DomainPrediction]:
|
||||
assert 0 <= cut_off_probability <= 1
|
||||
log_metric('text_length', len(text))
|
||||
log_metric("text_length", len(text))
|
||||
|
||||
cleaned = clean(text, convert_to_ascii=True)
|
||||
text = re.sub(r"[^a-zA-Z0-9]", " ", cleaned)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue