【Programming】Java Development vol.2 / Used SteemJ to count the number of Japanese Steemian / SteemJを使ってJapanese Steemianの数をカウントしてみた。

in #promari6 years ago (edited)

前回に引き続きSteemJを使いJavaからSteem APIを呼び出してみたいと思います。

<p dir="auto"><span><a href="https://github.com/marvin-we/steem-java-api-wrapper" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://github.com/marvin-we/steem-java-api-wrapper <p dir="auto"><img src="https://images.hive.blog/768x0/https://img.esteem.ws/iond0xml4z.png" alt="iond0xml4z.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/iond0xml4z.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/iond0xml4z.png 2x" /> <p dir="auto">javaneseタグで投稿されているSteemianのリストとそのSteemianのレピュテーションを表示したいと思います。ここではSteemJの詳細な使い方は解説しません。 <p dir="auto"><img src="https://images.hive.blog/768x0/https://img.esteem.ws/56dwbycshg.png" alt="56dwbycshg.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/56dwbycshg.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/56dwbycshg.png 2x" /> <p dir="auto">以下取得ソースです。 <pre><code>// Get DiscussionQuery DiscussionQuery discussionQuery = new DiscussionQuery(); discussionQuery.setTag("japanese"); discussionQuery.setLimit(100); List<Discussion> listDiscussion = steemJ.getDiscussionsBy(discussionQuery, DiscussionSortType.GET_DISCUSSIONS_BY_CREATED); LOGGER.info("discussion size:{}", listDiscussion.size()); LOGGER.info("------------- Get discussion query! -------------"); AtomicInteger i = new AtomicInteger(); listDiscussion.stream() .map(Discussion::getAuthor) .distinct() .sorted(comparing(AccountName::getName)) .forEach(account -> LOGGER.info("author[{}]: {}({})", i.getAndIncrement(), account.getName(), getAccountReputation(steemJ, account))); LOGGER.info("japanease steemians:{}", i); <p dir="auto">出力結果はこちら。ユーザー名の昇順で出力しています。 <p dir="auto"><img src="https://images.hive.blog/768x0/https://img.esteem.ws/ud1db8wc12.png" alt="ud1db8wc12.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/ud1db8wc12.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/ud1db8wc12.png 2x" /> <pre><code>------------- Get discussion query! ------------- author[0]: abamogeteru(52) author[1]: abbey701(44) author[2]: aitommylr(60) author[3]: akipponn(61) author[4]: amblog(60) author[5]: andresaulait(55) author[6]: areuspicy(56) author[7]: argon(63) author[8]: bbxb1a4(58) author[9]: chronogn(57) author[10]: crypto-coffee(52) author[11]: cticket(53) author[12]: denjiro(56) author[13]: djynn(65) author[14]: evansezjapanese(46) author[15]: fusan(59) author[16]: glastar(61) author[17]: hhhiiirrrooo(55) author[18]: hiradate(62) author[19]: illustrator-jp(40) author[20]: iyuta(65) author[21]: kamada3(56) author[22]: kan6034(53) author[23]: kaneni(54) author[24]: kayoko(65) author[25]: kinakomochi(68) author[26]: krispnatz(52) author[27]: miho(63) author[28]: mike2004(27) author[29]: nadeshiko(62) author[30]: niwatako(25) author[31]: noopu(65) author[32]: osarusan(55) author[33]: piercesword(49) author[34]: promari(55) author[35]: sallyfun(60) author[36]: saraneco(51) author[37]: shizuka(59) author[38]: sho-t(56) author[39]: shogo(65) author[40]: shokomint(53) author[41]: skyleap(65) author[42]: spinels.records(50) author[43]: steemit112i(38) author[44]: sumi(62) author[45]: suminohou(58) author[46]: sweetsqueenyumi(58) author[47]: tama.arin(51) author[48]: torachibi(60) author[49]: ultraseven(64) author[50]: usagi-alis(55) author[51]: waraji-report(41) author[52]: yadamaniart(69) author[53]: yasu(64) author[54]: yasu24(66) author[55]: yoshiko(69) author[56]: ytrphoto(69) japanease steemians:57 <p dir="auto">あまり見たくはないかもしれませんが、レピュテーションの降順にしてみます。 <pre><code>author[0]: yadamaniart(69) author[1]: ytrphoto(69) author[2]: yoshiko(69) author[3]: kinakomochi(68) author[4]: yasu24(66) author[5]: shogo(65) author[6]: skyleap(65) author[7]: iyuta(65) author[8]: noopu(65) author[9]: djynn(65) author[10]: kayoko(65) author[11]: yasu(64) author[12]: ultraseven(64) author[13]: miho(63) author[14]: argon(63) author[15]: sumi(62) author[16]: hiradate(62) author[17]: nadeshiko(62) author[18]: glastar(61) author[19]: akipponn(61) author[20]: amblog(60) author[21]: torachibi(60) author[22]: aitommylr(60) author[23]: sallyfun(60) author[24]: fusan(59) author[25]: shizuka(59) author[26]: bbxb1a4(58) author[27]: sweetsqueenyumi(58) author[28]: suminohou(58) author[29]: chronogn(57) author[30]: sho-t(56) author[31]: kamada3(56) author[32]: areuspicy(56) author[33]: denjiro(56) author[34]: usagi-alis(55) author[35]: promari(55) author[36]: osarusan(55) author[37]: andresaulait(55) author[38]: hhhiiirrrooo(55) author[39]: kaneni(54) author[40]: cticket(53) author[41]: kan6034(53) author[42]: shokomint(53) author[43]: crypto-coffee(52) author[44]: krispnatz(52) author[45]: abamogeteru(52) author[46]: saraneco(51) author[47]: tama.arin(51) author[48]: spinels.records(50) author[49]: piercesword(49) author[50]: evansezjapanese(46) author[51]: abbey701(44) author[52]: waraji-report(41) author[53]: illustrator-jp(40) author[54]: steemit112i(38) author[55]: mike2004(27) author[56]: niwatako(25) <p dir="auto">直近のjapaneseの投稿から今回は結果を拾いましたので、漏れているSteemianの皆様も多いと思います。 <p dir="auto">レビュテーションの計算は、Githubで公開されている<a href="https://ja.wikipedia.org/wiki/Python" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Pythonの計算式をJavaに置き換えてみました。 <pre><code>List<AccountReputation> accountReputation = steemJ.getAccountReputations(accountName, 1); long raw = accountReputation.get(0).getReputation(); String rawStr = String.valueOf(raw); boolean neg = rawStr.charAt(0) == '-' ? true : false; rawStr = neg ? rawStr.substring(1) : rawStr; double out = Math.log10(Long.parseLong(rawStr)); if (out == Double.NaN) out = 0; out = Math.max(out - 9, 0); out = (neg ? -1 : 1) * out; out = out * 9 + 25; repInt = (int) out; <p dir="auto">トライアンドエラーで色々と遊んでいるので、ソースは汚いのですが、まずはこれで動作させました。 <p dir="auto">DiscussionQueryの仕様で最大100件までしか一度に取得できませんので、取得できてないSteemianの方もいます。全て取得するには何かしら工夫が入りますね。 <p dir="auto"><img src="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmYQChjSnbGyuXBF36PYZ7dh59GzrVQguEZwoE9rnBJkaM" alt="RGgukq5E6HBS5wrYDNU5euL5kWt6DCj2LPGHAqZSwkfuoLdEdH7eB2otBDVMtGomJ8P4VL5cKfjf69rtMbw4585DE9g1mLB8NZM7JXuMHuBBCgyw74nJcZCj8hD8Z6n.png" srcset="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmYQChjSnbGyuXBF36PYZ7dh59GzrVQguEZwoE9rnBJkaM 1x, https://images.hive.blog/1536x0/https://ipfs.busy.org/ipfs/QmYQChjSnbGyuXBF36PYZ7dh59GzrVQguEZwoE9rnBJkaM 2x" /><br /> written by <a href="https://steemit.com/@tamito0201/" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">tamito0201 <p dir="auto">プログラミングとのご縁結びなら<a href="https://www.programming-mariage.jp/" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">プロマリへ。 <p dir="auto">オンラインプログラミング学習スクールの<a href="https://www.programming-mariage.jp/" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">プロマリは、プログラミングの初学者の皆様を応援しています。プログラミング講師と一緒に面白いアプリを作りませんか。 <p dir="auto"><a href="https://www.programming-mariage.jp" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://img.esteem.ws/btpb5hmlur.png" alt="btpb5hmlur.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/btpb5hmlur.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/btpb5hmlur.png 2x" /> <p dir="auto"><a href="https://www.programming-mariage.jp/about" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://img.esteem.ws/omchy0nhkl.png" alt="omchy0nhkl.png" srcset="https://images.hive.blog/768x0/https://img.esteem.ws/omchy0nhkl.png 1x, https://images.hive.blog/1536x0/https://img.esteem.ws/omchy0nhkl.png 2x" /> <p dir="auto">The programming school "<a href="https://www.programming-mariage.jp/" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Promari" will help you learn programming. "<a href="https://www.programming-mariage.jp/" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Promari" is supporting the first scholars of programming. Let's develop an application with our programming instructor.
Sort:  

どうしても習得できなかったJava。クラスとか意味が分からなかったです。JavaScriptは全く別物ですぐ理解できたんですけどねー。

Javaはバージョンが上がって習得しづらいくなってしましました。Javaは慣れ親しんでるので抵抗はあまりないんですが、JavaScriptは逆に習得しづらいです。どちらもよくつかわれるので頑張ってキャッチアップしています!

私はC言語やアセンブラで育ったので、Javaは理解しがたかったです。

C言語やアセンブラのほうが難易度高いですよね笑。またちょっと面白いプログラム書いてみます!

より、機械よりの言語だからね😅

Posted using Partiko Android

Congratulations @promari! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

<table><tr><td><span><img src="https://images.hive.blog/768x0/https://steemitimages.com/60x70/http://steemitboard.com/@promari/voted.png?201902282247" srcset="https://images.hive.blog/768x0/https://steemitimages.com/60x70/http://steemitboard.com/@promari/voted.png?201902282247 1x, https://images.hive.blog/1536x0/https://steemitimages.com/60x70/http://steemitboard.com/@promari/voted.png?201902282247 2x" /><td>You received more than 5000 upvotes. Your next target is to reach 6000 upvotes. <p dir="auto"><sub><em><a href="https://steemitboard.com/@promari" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Click here to view your Board<br /> <sub><em>If you no longer want to receive notifications, reply to this comment with the word <code>STOP <p dir="auto"><strong><span>Do not miss the last post from <a href="/@steemitboard">@steemitboard: <table><tr><td><a href="https://steemit.com/carnival/@steemitboard/carnival-2019" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://steemitimages.com/64x128/http://i.cubeupload.com/rltzHT.png" srcset="https://images.hive.blog/768x0/https://steemitimages.com/64x128/http://i.cubeupload.com/rltzHT.png 1x, https://images.hive.blog/1536x0/https://steemitimages.com/64x128/http://i.cubeupload.com/rltzHT.png 2x" /><td><a href="https://steemit.com/carnival/@steemitboard/carnival-2019" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Carnival Challenge - Collect badge and win 5 STEEM <h6><a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Vote for @Steemitboard as a witness and get one more award and increased upvotes!

thank you for your support!!

へえ、これは科学的ですね!Resteemさせていただきました。ありがとうございます。

Posted using Partiko iOS

ありがとうございます!文字数カウンタなどもこれを使うと組めそうです!