From aa53b218cbc1d92cdb40bd4f55bc685667657ec0 Mon Sep 17 00:00:00 2001 From: Robert Meyer Date: Tue, 6 Mar 2018 07:07:45 +0100 Subject: [PATCH] new rep score punishment --- tests/fixtures/random_data.py | 3 +++ tests/fixtures/raw_data.py | 3 ++- trufflepig/bchain/getdata.py | 3 ++- trufflepig/bchain/posts.py | 2 +- trufflepig/model.py | 41 +++++++++++++++++++++++++++++++---- 5 files changed, 45 insertions(+), 7 deletions(-) diff --git a/tests/fixtures/random_data.py b/tests/fixtures/random_data.py index e84d82c..2c9e6b6 100644 --- a/tests/fixtures/random_data.py +++ b/tests/fixtures/random_data.py @@ -119,6 +119,8 @@ def create_post(): randauthor = np.random.randint(0, len(AUTHORS)) author = AUTHORS[randauthor] + author_reputation = 2000000000 * ntwords + post = { 'title': title, 'reward': reward, @@ -128,6 +130,7 @@ def create_post(): 'body': body, 'author': author, 'permalink': permalink, + 'author_reputation': author_reputation } return post diff --git a/tests/fixtures/raw_data.py b/tests/fixtures/raw_data.py index b8229fe..772bd1b 100644 --- a/tests/fixtures/raw_data.py +++ b/tests/fixtures/raw_data.py @@ -45,6 +45,7 @@ 'Lookat ![j kjds](wehwjrkjewrk.de), yes [iii](jlkajddjsla), and ' '![images (17).jpg](https://steemitimages.com/DQmQF5BxHtPdPu1yKipV67GpnRdzemPpEFCqB59kVXC6Ahy/images%20(17).jpg)'), 'author': 'mary', - 'permalink': 'ladida' + 'permalink': 'ladida', + 'author_reputation': 99999999, } ] diff --git a/trufflepig/bchain/getdata.py b/trufflepig/bchain/getdata.py index 229d13d..117c523 100644 --- a/trufflepig/bchain/getdata.py +++ b/trufflepig/bchain/getdata.py @@ -253,7 +253,8 @@ def get_post_data(authors_and_permalinks, steem, exclusion_voters): 'tags': p.tags, 'body': p.body, 'author': author, - 'permalink': permalink + 'permalink': permalink, + 'author_reputation': int(p.author_reputation) } posts.append(post) return posts diff --git a/trufflepig/bchain/posts.py b/trufflepig/bchain/posts.py index 76ddd05..cc8d935 100644 --- a/trufflepig/bchain/posts.py +++ b/trufflepig/bchain/posts.py @@ -131,7 +131,7 @@ def topN_post(topN_authors, topN_permalinks, topN_titles, ## Delegate and Invest in the Bot -If you feel generous, you can delegate Steem Power to me and boost my daily upvotes on the truffle posts. I will give you a *small* compensation for your trust in me. **Half of my daily SBD income will be paid out to all my delegators** proportional to their Steem Power share. Payouts will start 3 days after your delegation. +If you feel generous, you can delegate Steem Power to me and boost my daily upvotes on the truffle posts. In return, I will provide you with a *small* compensation for your trust in me and your locked Steem Power. **Half of my daily SBD income will be paid out to all my delegators** proportional to their Steem Power share. Payouts will start 3 days after your delegation. Click on one of the following links to delegate **[10]({sp10}), [50]({sp50}), [100]({sp100}), [500]({sp500}), [1000]({sp1000}),** or even **[5000 Steem Power]({sp5000})**. Thank You! diff --git a/trufflepig/model.py b/trufflepig/model.py index 0e30c7d..9bfd204 100644 --- a/trufflepig/model.py +++ b/trufflepig/model.py @@ -748,8 +748,10 @@ def vote_score_step_function(x): return 0.95 elif x >= 5: return 0.9 - else: + elif x >= 3: return 0.4 + else: + return 0.2 def reward_score_step_function(x): @@ -760,8 +762,34 @@ def reward_score_step_function(x): return 1.0 elif x >= 0.5: return 0.9 - else: + elif x >= 0.2: return 0.4 + else: + return 0.2 + + +def reputation_score_step_function(x): + """Mapping of reputation to correction factor""" + if x > 50: + return 1.0 + elif x > 45: + return 0.95 + elif x > 40: + return 0.9 + elif x > 35: + return 0.85 + elif x > 30: + return 0.75 + elif x > 25: + return 0.6 + else: + return 0.3 + + +def compute_simple_reputation(x): + """Maps raw author reputation to simple reputation""" + result = (np.log10(x) - 9) * 9 +25 + return result def compute_rank_score(post_frame, punish_list=PUNISH_LIST, ncores=2, chunksize=500): @@ -779,7 +807,7 @@ def compute_rank_score(post_frame, punish_list=PUNISH_LIST, ncores=2, chunksize= ------- Series of ranks score The score is reward_difference * adjustment - and adjustment=tag_factor*vote_factor*reward_factor*spelling_errors_factor*grammar_factor + and adjustment=tag_factor*vote_factor*reward_factor*spelling_errors_factor*grammar_factor*reputation_factor """ logger.info('Computing tag factor...') @@ -795,6 +823,10 @@ def compute_rank_score(post_frame, punish_list=PUNISH_LIST, ncores=2, chunksize= spelling_errors_factor = post_frame.errors_per_word.apply(lambda x: spelling_error_step_function(x)) + logger.info('Computing reputation factor...') + simple_reputation = post_frame.author_reputation.apply(lambda x: compute_simple_reputation(x)) + reputation_factor = simple_reputation.apply(lambda x: reputation_score_step_function(x)) + logger.info('Applying grammar check...') checker = tfsm.GrammarErrorCounter() errors_per_character = apply_parallel(checker.count_mistakes_per_character, @@ -807,7 +839,8 @@ def compute_rank_score(post_frame, punish_list=PUNISH_LIST, ncores=2, chunksize= logger.info('...Done combining reward difference and factors') result = post_frame.reward_difference - final_factor = grammar_factor * reward_factor * vote_factor * tag_factor * spelling_errors_factor + final_factor = (grammar_factor * reward_factor * vote_factor * + tag_factor * spelling_errors_factor * reputation_factor) # increase negative values for low factors: final_factor.loc[result < 0] = 1.0 / final_factor.loc[result < 0] result = result * final_factor