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

in #promari5 years ago (edited)

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

https://github.com/marvin-we/steem-java-api-wrapper

iond0xml4z.png

javaneseタグで投稿されているSteemianのリストとそのSteemianのレピュテーションを表示したいと思います。ここではSteemJの詳細な使い方は解説しません。

56dwbycshg.png

以下取得ソースです。

// 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);

出力結果はこちら。ユーザー名の昇順で出力しています。

ud1db8wc12.png

------------- 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

あまり見たくはないかもしれませんが、レピュテーションの降順にしてみます。

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)

直近のjapaneseの投稿から今回は結果を拾いましたので、漏れているSteemianの皆様も多いと思います。

レビュテーションの計算は、Githubで公開されているPythonの計算式をJavaに置き換えてみました。

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;

トライアンドエラーで色々と遊んでいるので、ソースは汚いのですが、まずはこれで動作させました。

DiscussionQueryの仕様で最大100件までしか一度に取得できませんので、取得できてないSteemianの方もいます。全て取得するには何かしら工夫が入りますね。

RGgukq5E6HBS5wrYDNU5euL5kWt6DCj2LPGHAqZSwkfuoLdEdH7eB2otBDVMtGomJ8P4VL5cKfjf69rtMbw4585DE9g1mLB8NZM7JXuMHuBBCgyw74nJcZCj8hD8Z6n.png
written by tamito0201

プログラミングとのご縁結びならプロマリへ。

オンラインプログラミング学習スクールのプロマリは、プログラミングの初学者の皆様を応援しています。プログラミング講師と一緒に面白いアプリを作りませんか。

btpb5hmlur.png

omchy0nhkl.png

The programming school "Promari" will help you learn programming. "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) :

You received more than 5000 upvotes. Your next target is to reach 6000 upvotes.

Click here to view your Board
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

Carnival Challenge - Collect badge and win 5 STEEM
Vote for @Steemitboard as a witness and get one more award and increased upvotes!

thank you for your support!!

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

Posted using Partiko iOS

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

Coin Marketplace

STEEM 0.35
TRX 0.12
JST 0.040
BTC 70753.86
ETH 3589.34
USDT 1.00
SBD 4.75