HomePosts

【Django】JWT 認証付きの API のテストでユーザー認証を行う方法

2023-06-11

JWT 認証には [djangorestframework-simplejwt](https://github.com/jazzband/djangorestframework-simplejwt) を用いていることを前提とする。 ```python from django.contrib.auth import get_user_model from rest_framework.test import APITestCase from rest_framework_simplejwt.tokens import RefreshToken User = get_user_model() class ExampleTests(APITestCase): def setUp(self): self.user = User.objects.create_user(username='username', password='password') self.refresh = RefreshToken.for_user(self.user) self.client.credentials( HTTP_AUTHORIZATION='Bearer ' + str(self.refresh.access_token) ) ``` ### 参考 - https://django-rest-framework-simplejwt.readthedocs.io/en/latest/creating_tokens_manually.html

cron で 1 時間ごとに自動で git push する

2023-05-13

現在の設定を確認 ```shell crontab -l ``` 現在の設定を削除 ```shell crontab -r ``` 現在の設定を編集 ```shell crontab -e ``` 1 時間ごとに自動で git push する ```shell 0 * * * * export LANG=ja_JP.UTF-8 && git add -A && git diff --staged --quiet || (git commit -m "$(date +"%Y-%m-%d %H:%M:%S")" && git push) >/dev/null 2>&1 ``` ### 参考 - https://www.server-memo.net/tips/crontab.html - https://orebibou.com/ja/home/201412/20141225_001/ - https://superuser.com/questions/564829/git-push-to-github-via-cron-on-mac - https://www.cyberciti.biz/faq/disable-the-mail-alert-by-crontab-command/

CIKM 2022 にてポスター発表を行いました

2022-10-25

この度、アトランタで開催された CIKM 2022 に参加し、short paper として採択された論文のポスター発表を行いました。 今回採択された論文はこちらです。 Tsubasa Nakagawa, Shunsuke Kitada, Hitoshi Iyatomi [Expressions Causing Differences in Emotion Recognition in Social Networking Service Documents](https://doi.org/10.1145/3511808.3557599) Proceedings of the 31st ACM International Conference on Information & Knowledge Management (CIKM '22) 内容としては書き手と読み手の感情認識の差の原因となる表現を検出するフレームワークの提案となっています。 今回が初めての国際会議であり、初めての海外だったため、毎日が新鮮でした。 未熟な自分がこうして無事発表を終えれたのも、論文執筆の段階から全面的にサポートしていただいた教授と先輩のおかげです。 つくづく周りの環境に恵まれているなと実感させられます。 最高に充実した 10 日間でした! 今回発表に使用したポスターは[こちら](/posts/attended-cikm-2022/poster.pdf) ### 発表の様子 ![ポスターセッション](/posts/attended-cikm-2022/poster_session.jpg)

CIKM 2022 に論文が採択されました

2022-08-07

この度、主著論文が CIKM 2022 に short paper として採択されました。 内容としては書き手と読み手の感情認識の差の原因となる表現を検出するフレームワークの提案となっています。 Tsubasa Nakagawa, Shunsuke Kitada, Hitoshi Iyatomi [Expressions Causing Differences in Emotion Recognition in Social Networking Service Documents](https://doi.org/10.1145/3511808.3557599) Proceedings of the 31st ACM International Conference on Information & Knowledge Management (CIKM '22) ### Abstract It is often difficult to correctly infer a writer's emotion from text exchanged online, and differences in recognition between writers and readers can be problematic. In this paper, we propose a new framework for detecting sentences that create differences in emotion recognition between the writer and the reader and for detecting the kinds of expressions that cause such differences. The proposed framework consists of a bidirectional encoder representations from transformers (BERT)-based detector that detects sentences causing differences in emotion recognition and an analysis that acquires expressions that characteristically appear in such sentences. The detector, based on a Japanese SNS-document dataset with emotion labels annotated by both the writer and three readers of the social networking service (SNS) documents, detected "hidden-anger sentences" with AUC = 0.772; these sentences gave rise to differences in the recognition of anger. Because SNS documents contain many sentences whose meaning is extremely difficult to interpret, by analyzing the sentences detected by this detector, we obtained several expressions that appear characteristically in hidden-anger sentences. The detected sentences and expressions do not convey anger explicitly, and it is difficult to infer the writer's anger, but if the implicit anger is pointed out, it becomes possible to guess why the writer is angry. Put into practical use, this framework would likely have the ability to mitigate problems based on misunderstandings.

Next.js で Markdown ブログを作った

2022-08-06

Markdown で記事を書けるブログを作ってみました。 Gatsby を使った方が簡単にできそうだったのですが、ある程度自分で作った方が後からカスタムしやすいかなと思い、今回は Next.js を使用しました。 ソースコードは[こちら](https://github.com/nakatuba/blog) 使用したライブラリは主に - [gray-matter](https://github.com/jonschlinkert/gray-matter) - ファイルの先頭に書いたメタ情報(front matter というらしい)を解析してくれる ``` --- title: Next.js で Markdown ブログを作った date: '2022-08-06' --- ``` - [react-markdown](https://github.com/remarkjs/react-markdown) - Markdown を HTML の要素に変換してくれる - [react-syntax-highlighter](https://github.com/react-syntax-highlighter/react-syntax-highlighter) - コードを載せたときにシンタックスハイライトしてくれる - [Chakra UI](https://github.com/chakra-ui/chakra-ui) - 豊富なコンポーネントを提供してくれる UI ライブラリ - [chakra-ui-markdown-renderer](https://github.com/mustaphaturhan/chakra-ui-markdown-renderer) - Markdown から変換された HTML の要素を Chakra UI のコンポーネントに変換してくれる ### 今後 インターンに参加した感想や研究のこと、技術的なメモを残していければいいなと思っています。

© 2022 Tsubasa Nakagawa. All rights reserved