Commit b8c0b1edc1d74b729054388190e5bc9180e25683
1 parent
4ac15ea6
Added bonus for partially correct semantic frames and bonus for connecting schemata to frames.
Showing
7 changed files
with
126 additions
and
25 deletions
accounts/models.py
... | ... | @@ -43,7 +43,7 @@ class UserStats(Model): |
43 | 43 | # oplaty za prace leksykograficzne |
44 | 44 | bind_phraseology_frames_history = ManyToManyField('RealizedPhraseologyBinding', db_table='powiazania_frazeologiczne', |
45 | 45 | blank=True, null=True, related_name='user_stats') |
46 | - # !NOWE! oplaty za prace semantyczne | |
46 | + # oplaty za prace semantyczne | |
47 | 47 | semantics_real_history = ManyToManyField('RealizedSemantics', db_table='prace_semantyczne', |
48 | 48 | blank=True, null=True, related_name='user_stats') |
49 | 49 | # kwota uiszczona |
... | ... | @@ -272,7 +272,6 @@ def get_anon_profile(): |
272 | 272 | def filtering_mode(user): |
273 | 273 | return user.usersettings.filter_search |
274 | 274 | |
275 | -# !NOWE! | |
276 | 275 | class RealizedSemantics(Model): |
277 | 276 | """Model representing realized semantic work.""" |
278 | 277 | # wykonane haslo |
... | ... | @@ -288,15 +287,24 @@ class RealizedSemantics(Model): |
288 | 287 | # wlasciwie wykonane ramki (wypelniane dla semantyka) |
289 | 288 | prop_frames = PositiveIntegerField(db_column='poprawne_ramki', |
290 | 289 | default=0) |
290 | + # czesciowo wlasciwie wykonane ramki (wypelniane dla semantyka) !NOWE | |
291 | + part_prop_frames = PositiveIntegerField(db_column='czesciowo_poprawne_ramki', | |
292 | + default=0) | |
291 | 293 | # niewlasciwie wykonane ramki (wypelniane dla semantyka) |
292 | 294 | wrong_frames = PositiveIntegerField(db_column='niepoprawne_ramki', |
293 | 295 | default=0) |
296 | + # dodane powiazania miedzy ramami i schematami !NOWE | |
297 | + added_connections = PositiveIntegerField(db_column='dodane_powiazania', | |
298 | + default=0) | |
294 | 299 | # wykonane ramki (wypelniane dla semantyka) |
295 | 300 | made_frames = PositiveIntegerField(db_column='wykonane_ramki', |
296 | 301 | default=0) |
297 | 302 | # poprawione ramki (wypelniane dla supersemantyka) |
298 | 303 | corr_frames = PositiveIntegerField(db_column='poprawione_ramki', |
299 | 304 | default=0) |
305 | + # czesciowo poprawione ramki (wypelniane dla supersemantyka) !NOWE | |
306 | + part_corr_frames = PositiveIntegerField(db_column='czesciowo_poprawione_ramki', | |
307 | + default=0) | |
300 | 308 | # ramki niepoprawiane (wypelniane dla supersemantyka) |
301 | 309 | ncorr_frames = PositiveIntegerField(db_column='niepoprawione_ramki', |
302 | 310 | default=0) |
... | ... |
dictionary/ajax_lemma_status.py
... | ... | @@ -254,10 +254,20 @@ def lemma_status_change(request, status_id, lemma_id): |
254 | 254 | checked_frame_value = 0.0 |
255 | 255 | corrected_frame_value = 0.0 |
256 | 256 | bonus = 4.0 |
257 | + part_bonus = 2.0 | |
258 | + connection_bonus = 0.1 | |
257 | 259 | ### naliczanie oplat za sprawdzenie i bonusow |
258 | - update_sem_stats_conf_s(lemma_obj.entry_obj, actual_semantic_frames, | |
259 | - lemma_obj.semanticist, request.user, new_status, | |
260 | - checked_frame_value, corrected_frame_value, bonus) | |
260 | + update_sem_stats_conf_s(entry=lemma_obj.entry_obj, | |
261 | + semantic_frames=actual_semantic_frames, | |
262 | + semanticist=lemma_obj.semanticist, | |
263 | + supersemanticist=request.user, | |
264 | + status=new_status, | |
265 | + checked_frame_value=checked_frame_value, | |
266 | + corrected_frame_value=corrected_frame_value, | |
267 | + bonus_factor=bonus, | |
268 | + part_bonus_factor=part_bonus, | |
269 | + connection_bonus=connection_bonus) | |
270 | + | |
261 | 271 | add_new_frames_to_phraseologic_propositions(lemma_obj) |
262 | 272 | changed = True |
263 | 273 | # zmiana statusu na w obrobce semantycznej |
... | ... | @@ -496,7 +506,8 @@ def update_sem_stats_ready_s(entry, semantic_frames, semanticist, status, frame_ |
496 | 506 | semanticist.user_stats.semantics_real_history.add(realized_semantics) |
497 | 507 | |
498 | 508 | def update_sem_stats_conf_s(entry, semantic_frames, semanticist, supersemanticist, status, |
499 | - checked_frame_value, corrected_frame_value, bonus_factor): | |
509 | + checked_frame_value, corrected_frame_value, | |
510 | + bonus_factor, part_bonus_factor, connection_bonus): | |
500 | 511 | ready_statuses = Lemma_Status.objects.filter(type__sym_name='ready_s') |
501 | 512 | q_ready_statuses = [Q(status=ready_status) for ready_status in ready_statuses.all()] |
502 | 513 | |
... | ... | @@ -505,17 +516,28 @@ def update_sem_stats_conf_s(entry, semantic_frames, semanticist, supersemanticis |
505 | 516 | checked_sem_frames = semantic_frames |
506 | 517 | ready_to_checked_diffs = get_frames_differences(ready_sem_frames.all(), checked_sem_frames.all()) |
507 | 518 | checked_to_ready_diffs = get_frames_differences(checked_sem_frames.all(), ready_sem_frames.all()) |
508 | - sem_dict = {'same_frames': len(ready_to_checked_diffs['matching_frames']), | |
519 | + | |
520 | + connections_amount = count_connections(ready_to_checked_diffs) | |
521 | + sem_cash = (bonus_factor*float(len(ready_to_checked_diffs['matching_frames'])) + | |
522 | + part_bonus_factor*float(len(ready_to_checked_diffs['part_matching_frames'])) + | |
523 | + connection_bonus*float(connections_amount)) | |
524 | + sem_dict = {'same_frames': len(ready_to_checked_diffs['matching_frames']), | |
525 | + 'part_same_frames': len(ready_to_checked_diffs['part_matching_frames']), | |
509 | 526 | 'wrong_frames': len(ready_to_checked_diffs['missing_frames']), |
510 | - 'cash': bonus_factor*float(len(ready_to_checked_diffs['matching_frames']))} | |
527 | + 'added_connections': connections_amount, | |
528 | + 'cash': sem_cash} | |
529 | + | |
530 | + supersem_cash = (float(len(checked_to_ready_diffs['missing_frames'])+len(checked_to_ready_diffs['part_matching_frames']))*corrected_frame_value + | |
531 | + float(len(ready_to_checked_diffs['matching_frames']))*checked_frame_value) | |
511 | 532 | supersem_dict = {'same_frames': len(checked_to_ready_diffs['matching_frames']), |
533 | + 'part_same_frames': len(checked_to_ready_diffs['part_matching_frames']), | |
512 | 534 | 'redo_frames': len(checked_to_ready_diffs['missing_frames']), |
513 | - 'cash': (float(len(checked_to_ready_diffs['missing_frames']))*corrected_frame_value+ | |
514 | - float(len(ready_to_checked_diffs['matching_frames']))*checked_frame_value)} | |
535 | + 'cash': supersem_cash} | |
515 | 536 | |
516 | 537 | supersem_real_semantics = RealizedSemantics(entry=entry, |
517 | 538 | cash=supersem_dict['cash'], |
518 | 539 | corr_frames=supersem_dict['redo_frames'], |
540 | + part_corr_frames=supersem_dict['part_same_frames'], | |
519 | 541 | ncorr_frames=supersem_dict['same_frames'], |
520 | 542 | status=status, |
521 | 543 | bonus=False) |
... | ... | @@ -526,12 +548,22 @@ def update_sem_stats_conf_s(entry, semantic_frames, semanticist, supersemanticis |
526 | 548 | sem_real_semantics = RealizedSemantics(entry=entry, |
527 | 549 | cash=sem_dict['cash'], |
528 | 550 | prop_frames=sem_dict['same_frames'], |
551 | + part_prop_frames=sem_dict['part_same_frames'], | |
529 | 552 | wrong_frames=sem_dict['wrong_frames'], |
553 | + added_connections=sem_dict['added_connections'], | |
530 | 554 | status=status, |
531 | 555 | bonus=True) |
532 | 556 | sem_real_semantics.save() |
533 | 557 | sem_real_semantics.frames.add(*semantic_frames.all()) |
534 | 558 | semanticist.user_stats.semantics_real_history.add(sem_real_semantics) |
535 | - | |
559 | + | |
560 | +def count_connections(differences): | |
561 | + amount = 0 | |
562 | + for frame in differences['matching_frames']: | |
563 | + amount += frame.connected_schemata().count() | |
564 | + for frame in differences['part_matching_frames']: | |
565 | + amount += frame.connected_schemata().count() | |
566 | + return amount | |
567 | + | |
536 | 568 | def remove_semantic_payments(entry): |
537 | 569 | RealizedSemantics.objects.filter(entry=entry).delete() |
... | ... |
dictionary/ajax_user_stats.py
... | ... | @@ -88,8 +88,8 @@ def get_user_stats(request, user_name): |
88 | 88 | 'all_semantic_owned_lemmas_count': all_semantic_owned_lemmas.count(), |
89 | 89 | 'all_semantic_owned_frames_count': all_semantic_owned_frames_count, |
90 | 90 | 'earned_cash': total_earned_cash, |
91 | - 'paid_cash' : round(user.user_stats.paid_cash, 2), | |
92 | - 'surcharge' : round(user.user_stats.paid_cash-total_earned_cash, 2), | |
91 | + 'paid_cash': round(user.user_stats.paid_cash, 2), | |
92 | + 'surcharge': round(user.user_stats.paid_cash-total_earned_cash, 2), | |
93 | 93 | 'lex_work_stats': lex_work_stats, |
94 | 94 | 'phraseology_work_stats': phraseology_work_stats, |
95 | 95 | 'semantics_work_stats': semantics_work_stats} |
... | ... | @@ -244,6 +244,9 @@ def get_semantics_stats(user): |
244 | 244 | prop_frames = RealizedSemantics.objects.filter(user_stats__user=user).aggregate(Sum('prop_frames'))['prop_frames__sum'] |
245 | 245 | if prop_frames == None: |
246 | 246 | prop_frames = 0 |
247 | + part_prop_frames = RealizedSemantics.objects.filter(user_stats__user=user).aggregate(Sum('part_prop_frames'))['part_prop_frames__sum'] | |
248 | + if part_prop_frames == None: | |
249 | + part_prop_frames = 0 | |
247 | 250 | wrong_frames = RealizedSemantics.objects.filter(user_stats__user=user).aggregate(Sum('wrong_frames'))['wrong_frames__sum'] |
248 | 251 | if wrong_frames == None: |
249 | 252 | wrong_frames = 0 |
... | ... | @@ -255,17 +258,22 @@ def get_semantics_stats(user): |
255 | 258 | ncorr_frames = 0 |
256 | 259 | made_frames = RealizedSemantics.objects.filter(user_stats__user=user).aggregate(Sum('made_frames'))['made_frames__sum'] |
257 | 260 | if made_frames == None: |
258 | - made_frames = 0 | |
261 | + made_frames = 0 | |
262 | + added_connections = RealizedSemantics.objects.filter(user_stats__user=user).aggregate(Sum('added_connections'))['added_connections__sum'] | |
263 | + if added_connections == None: | |
264 | + added_connections = 0 | |
259 | 265 | efficacy = 0.0 |
260 | 266 | if prop_frames+wrong_frames > 0: |
261 | 267 | efficacy = float(prop_frames)/float(prop_frames+wrong_frames)*100.0 |
262 | 268 | |
263 | - sem_work_stats = {'earned_cash' : round(earned_cash, 2), | |
264 | - 'bonus_cash' : round(bonus_cash, 2), | |
265 | - 'prop_frames' : prop_frames, | |
266 | - 'wrong_frames' : wrong_frames, | |
267 | - 'corr_frames' : corr_frames, | |
269 | + sem_work_stats = {'earned_cash': round(earned_cash, 2), | |
270 | + 'bonus_cash': round(bonus_cash, 2), | |
271 | + 'prop_frames': prop_frames, | |
272 | + 'part_prop_frames': part_prop_frames, | |
273 | + 'wrong_frames': wrong_frames, | |
274 | + 'corr_frames': corr_frames, | |
268 | 275 | 'checked_frames': ncorr_frames+corr_frames, |
269 | - 'made_frames' : made_frames, | |
270 | - 'efficacy' : round(efficacy, 2)} | |
276 | + 'made_frames': made_frames, | |
277 | + 'efficacy': round(efficacy, 2), | |
278 | + 'added_connections' : added_connections} | |
271 | 279 | return sem_work_stats |
... | ... |
dictionary/templates/sel_user_stats.html
... | ... | @@ -123,7 +123,7 @@ |
123 | 123 | <table class='PaymentsTable'> |
124 | 124 | <tr> |
125 | 125 | <td class='EmptyCell' colspan=1></td> |
126 | - <td class='ColumnHeader' colspan=5>Semantycy:</td> | |
126 | + <td class='ColumnHeader' colspan=7>Semantycy:</td> | |
127 | 127 | <td class='ColumnHeader' colspan=2>Supersemantycy:</td> |
128 | 128 | </tr> |
129 | 129 | <tr> |
... | ... | @@ -131,7 +131,9 @@ |
131 | 131 | <td class='ColumnHeader'>Bonus:</td> |
132 | 132 | <td class='ColumnHeader'>Wykonane ramy:</td> |
133 | 133 | <td class='ColumnHeader'>Poprawnie wykonane ramy:</td> |
134 | + <td class='ColumnHeader'>Częściowo poprawnie wykonane ramy:</td> | |
134 | 135 | <td class='ColumnHeader'>Błędnie wykonane ramy:</td> |
136 | + <td class='ColumnHeader'>Dodane powiązania ze składnią:</td> | |
135 | 137 | <td class='ColumnHeader'>Skuteczność:</td> |
136 | 138 | <td class='ColumnHeader'>Sprawdzone ramy:</td> |
137 | 139 | <td class='ColumnHeader'>Poprawione ramy:</td> |
... | ... | @@ -141,7 +143,9 @@ |
141 | 143 | <td>{{semantics_work_stats.bonus_cash}} zł</td> |
142 | 144 | <td>{{semantics_work_stats.made_frames}}</td> |
143 | 145 | <td>{{semantics_work_stats.prop_frames}}</td> |
146 | + <td>{{semantics_work_stats.part_prop_frames}}</td> | |
144 | 147 | <td>{{semantics_work_stats.wrong_frames}}</td> |
148 | + <td>{{semantics_work_stats.added_connections}}</td> | |
145 | 149 | <td>{{semantics_work_stats.efficacy}} %</td> |
146 | 150 | <td>{{semantics_work_stats.checked_frames}}</td> |
147 | 151 | <td>{{semantics_work_stats.corr_frames}}</td> |
... | ... |
dictionary/views.py
... | ... | @@ -437,7 +437,7 @@ def manage_arg_realizations(request): |
437 | 437 | return to_return |
438 | 438 | |
439 | 439 | def download_walenty(request): |
440 | - generation_date = datetime.datetime.now() | |
440 | + generation_date = datetime.datetime.now() - datetime.timedelta(days=1) | |
441 | 441 | walenty_file_name = '%s_%s.tar.gz' % ('walenty', generation_date.strftime('%Y%m%d')) |
442 | 442 | walenty_path = os.path.join(settings.WALENTY_PATH, walenty_file_name) |
443 | 443 | |
... | ... |
semantics/models.py
... | ... | @@ -54,6 +54,12 @@ class SemanticFrame(models.Model): |
54 | 54 | return False |
55 | 55 | return True |
56 | 56 | |
57 | + def connected_schemata(self): | |
58 | + connected_schemata_ids = [] | |
59 | + for compl in self.complements.all(): | |
60 | + connected_schemata_ids.extend([schema.id for schema in compl.connected_schemata()]) | |
61 | + return Frame.objects.filter(id__in=connected_schemata_ids).distinct() | |
62 | + | |
57 | 63 | def __unicode__(self): |
58 | 64 | complements_str_tab = [unicode(compl) for compl in self.complements.all()] |
59 | 65 | return u'%d --> %s' % (self.id, u'+'.join(complements_str_tab)) |
... | ... | @@ -125,6 +131,10 @@ class Complement(models.Model): # pola z ramki |
125 | 131 | return False |
126 | 132 | return True |
127 | 133 | |
134 | + def connected_schemata(self): | |
135 | + schemata_ids = [real.frame.id for real in self.realizations.all()] | |
136 | + return Frame.objects.filter(id__in=schemata_ids).distinct() | |
137 | + | |
128 | 138 | def __unicode__(self): |
129 | 139 | return u'%d:%s' % (self.id, self.roles.all()) |
130 | 140 | |
... | ... |
semantics/utils.py
... | ... | @@ -2,19 +2,29 @@ |
2 | 2 | |
3 | 3 | def get_frames_differences(initial_frames, frames): |
4 | 4 | differences = {'matching_frames': [], |
5 | + 'part_matching_frames': [], | |
5 | 6 | 'missing_frames': []} |
7 | + matching_frames = [] | |
6 | 8 | for ini_frame in initial_frames: |
7 | 9 | matching_frame = get_matching_frame(frames, ini_frame) |
8 | 10 | if matching_frame: |
9 | 11 | differences['matching_frames'].append(ini_frame) |
12 | + matching_frames.append(matching_frame) | |
10 | 13 | else: |
11 | 14 | differences['missing_frames'].append(ini_frame) |
12 | - return differences | |
15 | + not_matched_frames = list(set(frames) - set(matching_frames)) | |
16 | + for miss_frame in differences['missing_frames']: | |
17 | + part_matching_frames = get_partially_matching_frames(not_matched_frames, miss_frame) | |
18 | + if part_matching_frames: | |
19 | + not_matched_frames.remove(part_matching_frames[0]) | |
20 | + differences['part_matching_frames'].append(miss_frame) | |
21 | + differences['missing_frames'] = list(set(differences['missing_frames']) - set(differences['part_matching_frames'])) | |
22 | + return differences | |
13 | 23 | |
14 | 24 | def get_matching_frame(frames, frame_to_find): |
15 | 25 | for frame in frames.all(): |
16 | 26 | if frames_match(frame, frame_to_find): |
17 | - return frame_to_find | |
27 | + return frame | |
18 | 28 | return None |
19 | 29 | |
20 | 30 | def frames_match(frame1, frame2): |
... | ... | @@ -96,3 +106,32 @@ def matching_synset_relation_exists(rel_to_find, relations): |
96 | 106 | if rel_to_find.to == rel.to: |
97 | 107 | return True |
98 | 108 | return False |
109 | + | |
110 | +def get_partially_matching_frames(frames, frame_to_find): | |
111 | + matching_frames = [] | |
112 | + for frame in frames: | |
113 | + if frames_partially_match(frame, frame_to_find): | |
114 | + matching_frames.append(frame) | |
115 | + return matching_frames | |
116 | + | |
117 | +def frames_partially_match(frame1, frame2): | |
118 | + complements1 = frame1.complements | |
119 | + complements2 = frame2.complements | |
120 | + if complements1.count() == complements2.count(): | |
121 | + for compl in complements1.all(): | |
122 | + if not partially_matching_complement_exists(complements2.all(), compl): | |
123 | + return False | |
124 | + else: | |
125 | + return False | |
126 | + return True | |
127 | + | |
128 | +def partially_matching_complement_exists(complements, compl_to_find): | |
129 | + for compl in complements: | |
130 | + if complements_partially_match(compl, compl_to_find): | |
131 | + return True | |
132 | + return False | |
133 | + | |
134 | +def complements_partially_match(compl1, compl2): | |
135 | + if roles_match(compl1.roles, compl2.roles): | |
136 | + return True | |
137 | + return False | |
... | ... |