駅から徒歩27分

技術メモとその他なんでも

論文のアブストを毎日slackに流してみた

本記事は 合同会社DMM 23卒内定者 Advent Calendar 2022 の17日目の記事です.

はじめに

こんにちは.DMM.com 23卒 エンジニア職のshikachiiです. twitter.com

最近冷える日が続きますが,この記事をご覧になられている皆様方に置かれましては風邪や流行病に罹らぬよう一層お気をつけください. せっかくなので今回は自己紹介も挟みつつ記事を書ければと思います.

自己紹介

生まれも育ちも長野です. 長野高専を卒業した後に山梨大学に三年次編入し,現在は同大学院でコンピュータビジョンに関する研究をしています.

また,都内のベンチャー起業でエンジニアインターンをしておりフロントエンド(React, Vue, その他諸々...)をガリガリと書いてきました.

趣味は,お酒・バイク・競馬です. 最近はバイスサワーにハマってて居酒屋で見かける度頼んでいる気がします. けっこうレアなので皆さんも見かけたら飲んでみてください!

本題

閑話休題.皆さんは自分の研究分野の最新論文読んでいますか?私は全然読めていません... 自分から論文を探しに行って,翻訳して,読み込んで...というのが億劫で中々できずにいます. そんなとき最新の論文が目の前に流れてくれば怠惰な私でも動向だけでもつかめるのではと思い,slackチャンネルに論文のアブストを流してみました.

はじめの一歩

では論文はどこから探せばよいでしょうか? Google ScholarIEEEなど様々ありますが,今回はarXivを用いたいと思います. また,今回は簡単さ重視のためGAS(Google App Script)を使ってみました.

取得

arXivから論文を取得する方法は こちら にあります. arXiv API 利用規約 に則りレート制限にかからないようにAPIを叩くようにしてください.

では,試しに1件だけ取得してみます.

$ curl http://export.arxiv.org/api/query?search_query=all:%22cs.CV%22&start=0&max_results=1&sortBy=submittedDate&sortOrder=descending
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <link href="http://arxiv.org/api/query?search_query%3Dall%3A%22cs.CV%22%26id_list%3D%26start%3D0%26max_results%3D1" rel="self" type="application/atom+xml"/>
  <title type="html">ArXiv Query: search_query=all:"cs.CV"&amp;id_list=&amp;start=0&amp;max_results=1</title>
  <id>http://arxiv.org/api/ogkPVrpqaNLGAlvJmvDyPJi1Msw</id>
  <updated>2022-12-15T00:00:00-05:00</updated>
  <opensearch:totalResults xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">87248</opensearch:totalResults>
  <opensearch:startIndex xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">0</opensearch:startIndex>
  <opensearch:itemsPerPage xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">1</opensearch:itemsPerPage>
  <entry>
    <id>http://arxiv.org/abs/2212.07422v1</id>
    <updated>2022-12-14T18:59:19Z</updated>
    <published>2022-12-14T18:59:19Z</published>
    <title>ECON: Explicit Clothed humans Obtained from Normals</title>
    <summary>  The combination of artist-curated scans, and deep implicit functions (IF), is
enabling the creation of detailed, clothed, 3D humans from images. However,
existing methods are far from perfect. IF-based methods recover free-form
geometry but produce disembodied limbs or degenerate shapes for unseen poses or
clothes. To increase robustness for these cases, existing work uses an explicit
parametric body model to constrain surface reconstruction, but this limits the
recovery of free-form surfaces such as loose clothing that deviates from the
body. What we want is a method that combines the best properties of implicit
and explicit methods. To this end, we make two key observations: (1) current
networks are better at inferring detailed 2D maps than full-3D surfaces, and
(2) a parametric model can be seen as a "canvas" for stitching together
detailed surface patches. ECON infers high-fidelity 3D humans even in loose
clothes and challenging poses, while having realistic faces and fingers. This
goes beyond previous methods. Quantitative, evaluation of the CAPE and
Renderpeople datasets shows that ECON is more accurate than the state of the
art. Perceptual studies also show that ECON's perceived realism is better by a
large margin. Code and models are available for research purposes at
https://xiuyuliang.cn/econ
</summary>
    <author>
      <name>Yuliang Xiu</name>
    </author>
    <author>
      <name>Jinlong Yang</name>
    </author>
    <author>
      <name>Xu Cao</name>
    </author>
    <author>
      <name>Dimitrios Tzionas</name>
    </author>
    <author>
      <name>Michael J. Black</name>
    </author>
    <arxiv:comment xmlns:arxiv="http://arxiv.org/schemas/atom">Homepage: https://xiuyuliang.cn/econ Code:
  https://github.com/YuliangXiu/ECON</arxiv:comment>
    <link href="http://arxiv.org/abs/2212.07422v1" rel="alternate" type="text/html"/>
    <link title="pdf" href="http://arxiv.org/pdf/2212.07422v1" rel="related" type="application/pdf"/>
    <arxiv:primary_category xmlns:arxiv="http://arxiv.org/schemas/atom" term="cs.CV" scheme="http://arxiv.org/schemas/atom"/>
    <category term="cs.CV" scheme="http://arxiv.org/schemas/atom"/>
    <category term="cs.AI" scheme="http://arxiv.org/schemas/atom"/>
    <category term="cs.GR" scheme="http://arxiv.org/schemas/atom"/>
  </entry>
</feed>

無事論文データ(タイトル,著者,アブスト,etc…)を取得できました! XMLなのが気がかりですが,パーサはたくさんあるため心配御無用です.

解析

GASでXMLを処理する場合は,XmlServiceが便利です. 早速パースしてきましょう.

// データ取得
const url = 'http://export.arxiv.org/api/query?...'
const xml = UrlFetchApp.fetch(url).getContentText();

// XML解析
const xmlDocs = XmlService.parse(xml);
const namespace = XmlService.getNamespace('', 'http://www.w3.org/2005/Atom');
const doc = xmlDocs.getRootElement().getChildren('entry', namespace);

無事パースできたので,各エントリについても処理していきます.

// スムーズな翻訳のため改行を取り除く
const plain = (str) => {
  return str.replace(/\r?\n/g, '');
}

// 各エントリ毎に処理
doc.forEach((d) => {
    const enTitle = plain(d.getChild('title', namespace).getText());

    const enSummary = plain(d.getChild('summary', namespace).getText());
    const jaSummary = LanguageApp.translate(enSummary, 'en', 'ja');

    const url = d.getChild('id', namespace).getText();

    const entry = {
      title: enTitle,
      summary: jaSummary.replace(/。/g, '。\n'),
      url,
    };

    postslack(entry);
});

ここで,英語のアブストをGASのLanguageApp.translateメソッドにより翻訳しています. developers.google.com

投稿

投稿場所は個人の管理するslackチャンネルにしました.通知もすぐ来るので便利です. よしなにslackのWebhookURLを取得できたら,UrlFetchApp.fetchメソッドでPOSTすることにより,指定したチャンネルに論文タイトル(URL)と翻訳されたアブストが投稿されます.

投稿された論文のアブスト

// Webhook URL
const url = 'https://hooks.slack.com/services/{YOUR_SECRET}';

const content = {
  'username': '{YOUR_NAME}',
  'text': `<${entry.url}|${entry.title}>\n${entry.summary}`,
};

const options = {
  'method': 'post',
  'content': 'applications/json',
  'payload': JSON.stringify(content),
};

UrlFetchApp.fetch(url, options);

まとめ

今回はarXivから最新の論文データを取得し,slackに投稿してみました. 最新3件かつ日本語ということでサッと見ることができ,ある程度動向を掴めたような気がします(気だけでも…). 今回は単純に投稿の新しい順に取得しましたが,引用数なども見て新しいかつ人気な論文を流すことができれば更に面白い論文を見つけられる気がしています.

コード全容

今回のコードはこちらのgist から確認できます.

おまけ

今週末12/18に行われるG1レース(朝日杯FS)の予想を載せてみます. 当たったらうれしいです.

◎ 3(オールパルフェ)
◯ 2(ドルチェモア)
▲ 7(オオバンブルマイ)
△ 12(ダノンタッチダウン),14(レイベリング)