Skip to content

Commit

Permalink
new rep score punishment
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Meyer committed Mar 6, 2018
1 parent 1dce934 commit aa53b21
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 7 deletions.
3 changes: 3 additions & 0 deletions tests/fixtures/random_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -128,6 +130,7 @@ def create_post():
'body': body,
'author': author,
'permalink': permalink,
'author_reputation': author_reputation
}

return post
Expand Down
3 changes: 2 additions & 1 deletion tests/fixtures/raw_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
]
3 changes: 2 additions & 1 deletion trufflepig/bchain/getdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion trufflepig/bchain/posts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
41 changes: 37 additions & 4 deletions trufflepig/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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...')
Expand All @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit aa53b21

Please sign in to comment.