-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Script for recomputing FK scores for languages with new constants
- Loading branch information
1 parent
a71c82d
commit d45e4ff
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import zeeguu.core | ||
from zeeguu.api.app import create_app | ||
from zeeguu.core.model import Article, Language | ||
from zeeguu.core.language.difficulty_estimator_factory import DifficultyEstimatorFactory | ||
|
||
app = create_app() | ||
app.app_context().push() | ||
|
||
print("starting...") | ||
|
||
|
||
session = zeeguu.core.model.db.session | ||
with session.begin(): | ||
for article in Article.query.filter( | ||
Article.language.has(Language.code.in_(["es", "fr", "it", "nl", "ru"])) | ||
).all(): | ||
print(f"Article language: {article.language}") | ||
print(f"Difficulty before: {article.fk_difficulty} for {article.title}") | ||
fk_estimator = DifficultyEstimatorFactory.get_difficulty_estimator("fk") | ||
fk_difficulty = fk_estimator.estimate_difficulty( | ||
article.content, article.language, None | ||
)["grade"] | ||
|
||
article.fk_difficulty = fk_difficulty | ||
print(f"Difficulty after: {article.fk_difficulty} for {article.title}\n") | ||
|
||
session.add(article) | ||
session.commit() |