Correction4W
This commit is contained in:
parent
47ee7b9ff8
commit
88fc344530
@ -30,9 +30,10 @@ class DataAndScore:
|
|||||||
|
|
||||||
class UseSource():
|
class UseSource():
|
||||||
title: str
|
title: str
|
||||||
evnetId: str
|
eventId: str
|
||||||
def __init__(self, title, eventId) -> None:
|
def __init__(self, title, eventId) -> None:
|
||||||
self.title = title
|
self.title = title
|
||||||
|
self.eventId = eventId
|
||||||
|
|
||||||
def stripped(self, input_string) -> str:
|
def stripped(self, input_string) -> str:
|
||||||
return re.sub(r'[^a-zA-Z0-9]', '', input_string)
|
return re.sub(r'[^a-zA-Z0-9]', '', input_string)
|
||||||
@ -44,15 +45,15 @@ class UseSource():
|
|||||||
|
|
||||||
result: List[WeightedData] = []
|
result: List[WeightedData] = []
|
||||||
if (anii is not None) and (anii.status == "COMPLETED" and anii.data is not None):
|
if (anii is not None) and (anii.status == "COMPLETED" and anii.data is not None):
|
||||||
result.append(WeightedData(anii, 2))
|
result.append(WeightedData(anii, 1.2))
|
||||||
if (imdb is not None) and (imdb.status == "COMPLETED" and imdb.data is not None):
|
if (imdb is not None) and (imdb.status == "COMPLETED" and imdb.data is not None):
|
||||||
imdb_weight = 1
|
imdb_weight = 1
|
||||||
#if (imdb.data.title == title or unidecode(self.stripped(imdb.data.title)) == unidecode(self.stripped(title))): To use after test
|
#if (imdb.data.title == title or unidecode(self.stripped(imdb.data.title)) == unidecode(self.stripped(title))): To use after test
|
||||||
if (imdb.data.title == title or unidecode(imdb.data.title) == unidecode(title)):
|
if (imdb.data.title == title or unidecode(imdb.data.title) == unidecode(title)):
|
||||||
imdb_weight = 10
|
imdb_weight = 100
|
||||||
result.append(WeightedData(imdb, imdb_weight))
|
result.append(WeightedData(imdb, imdb_weight))
|
||||||
if (mal is not None) and (mal.status == "COMPLETED" and mal.data is not None):
|
if (mal is not None) and (mal.status == "COMPLETED" and mal.data is not None):
|
||||||
result.append(WeightedData(mal, 4))
|
result.append(WeightedData(mal, 1.8))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def __calculate_score(self, title: str, weightData: List[WeightedData]) -> List[DataAndScore]:
|
def __calculate_score(self, title: str, weightData: List[WeightedData]) -> List[DataAndScore]:
|
||||||
@ -60,11 +61,14 @@ class UseSource():
|
|||||||
result: List[WeightedData] = []
|
result: List[WeightedData] = []
|
||||||
for wd in weightData:
|
for wd in weightData:
|
||||||
highScore = fuzz.ratio(self.stripped(title.lower()), self.stripped(wd.result.data.title.lower()))
|
highScore = fuzz.ratio(self.stripped(title.lower()), self.stripped(wd.result.data.title.lower()))
|
||||||
|
logger.info(f"[H:{highScore}]\t{self.stripped(wd.result.data.title.lower())} => {self.stripped(title.lower())}")
|
||||||
for name in wd.result.data.altTitle:
|
for name in wd.result.data.altTitle:
|
||||||
altScore = fuzz.ratio(self.stripped(title.lower()), self.stripped(name.lower()))
|
altScore = fuzz.ratio(self.stripped(title.lower()), self.stripped(name.lower()))
|
||||||
if (altScore > highScore):
|
if (altScore > highScore):
|
||||||
highScore = altScore
|
highScore = altScore
|
||||||
|
logger.info(f"[A:{highScore}]\t{self.stripped(wd.result.data.title.lower())} => {self.stripped(title.lower())}")
|
||||||
givenScore = highScore * (wd.weight / 10)
|
givenScore = highScore * (wd.weight / 10)
|
||||||
|
logger.info(f"[G:{givenScore}]\t{self.stripped(wd.result.data.title.lower())} => {self.stripped(title.lower())} Weight:{wd.weight}")
|
||||||
result.append(DataAndScore(wd.result, givenScore))
|
result.append(DataAndScore(wd.result, givenScore))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@ -78,7 +82,7 @@ class UseSource():
|
|||||||
jsr = ""
|
jsr = ""
|
||||||
try:
|
try:
|
||||||
jsr = json.dumps([obj.to_dict() for obj in scored], indent=4)
|
jsr = json.dumps([obj.to_dict() for obj in scored], indent=4)
|
||||||
with open(f"./logs/{self.evnetId}.json", "w", encoding="utf-8") as f:
|
with open(f"./logs/{self.eventId}.json", "w", encoding="utf-8") as f:
|
||||||
f.write(jsr)
|
f.write(jsr)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.info("Couldn't dump log..")
|
logger.info("Couldn't dump log..")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user