Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sourcery refactored master branch #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/carrier_owl.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ def calc_score(abst: str, keywords: dict) -> (float, list):
sum_score = 0.0
hit_kwd_list = []

for word in keywords.keys():
score = keywords[word]
for word, score in keywords.items():
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function calc_score refactored with the following changes:

if word.lower() in abst.lower():
sum_score += score
hit_kwd_list.append(word)
Expand Down Expand Up @@ -107,14 +106,11 @@ def get_translated_text(from_lang: str, to_lang: str, from_text: str) -> str:
https://qiita.com/fujino-fpu/items/e94d4ff9e7a5784b2987
'''

sleep_time = 1

# urlencode
from_text = urllib.parse.quote(from_text)

# url作成
url = 'https://www.deepl.com/translator#' \
+ from_lang + '/' + to_lang + '/' + from_text
url = f'https://www.deepl.com/translator#{from_lang}/{to_lang}/{from_text}'
Comment on lines -110 to +113
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_translated_text refactored with the following changes:


# ヘッドレスモードでブラウザを起動
options = Options()
Expand All @@ -125,7 +121,8 @@ def get_translated_text(from_lang: str, to_lang: str, from_text: str) -> str:
driver.get(url)
driver.implicitly_wait(10) # 見つからないときは、10秒まで待つ

for i in range(30):
sleep_time = 1
for _ in range(30):
# 指定時間待つ
time.sleep(sleep_time)
html = driver.page_source
Expand Down Expand Up @@ -167,7 +164,7 @@ def main():
keywords = config['keywords']
score_threshold = float(config['score_threshold'])

day_before_yesterday = datetime.datetime.today() - datetime.timedelta(days=2)
day_before_yesterday = datetime.datetime.now() - datetime.timedelta(days=2)
Comment on lines -170 to +167
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:

day_before_yesterday_str = day_before_yesterday.strftime('%Y%m%d')
# datetime format YYYYMMDDHHMMSS
arxiv_query = f'({subject}) AND ' \
Expand Down