icon fix, i18n

This commit is contained in:
Sander Land committed 2020-05-25 23:23:11 +02:00
1 parent 74c57f9433
commit 155ddd631c
15 files changed
+430 -206

No files matched your search

+11 -13
View File
@@ -4,6 +4,7 @@ from typing import Dict, List, Optional, Tuple
from katrain.core.common import evaluation_class, var_to_grid, i18n
from katrain.core.sgf_parser import Move, SGFNode
from katrain.gui.style import PV_COLOR
class GameNode(SGFNode):
@@ -40,11 +41,7 @@ class GameNode(SGFNode):
if comment:
properties["C"] = ["\n".join(properties.get("C", "")) + comment]
if self.is_root:
properties["C"] = [
i18n._("SGF start message") + "\n"
+ "\n".join(properties.get("C", ""))
+ "\nSGF with review generated by KaTrain."
]
properties["C"] = [i18n._("SGF start message") + "\n" + "\n".join(properties.get("C", "")) + "\nSGF with review generated by KaTrain."]
if self.note.strip():
properties["C"] = ["\n".join(properties.get("C", "")) + f"\nNote: {self.note}"]
return properties
@@ -117,7 +114,7 @@ class GameNode(SGFNode):
def make_pv(self, player, pv, interactive):
pvtext = f"{player}{' '.join(pv)}"
if interactive:
pvtext = f"[u][ref={pvtext}][color=#334466]{pvtext}[/color][/ref][/u]"
pvtext = f"[u][ref={pvtext}][color={PV_COLOR}]{pvtext}[/color][/ref][/u]"
return pvtext
def comment(self, sgf=False, teach=False, hints=False, interactive=True):
@@ -129,8 +126,8 @@ class GameNode(SGFNode):
if self.analysis_ready:
score = self.score
if sgf:
text += f"Score: {self.format_score(score)}\n"
text += f"Win Rate: {self.format_winrate()}\n"
text += i18n._("Info:score").format(score=self.format_score(score)) + "\n"
text += i18n._("Info:winrate").format(winrate=self.format_winrate()) + "\n"
if self.parent and self.parent.analysis_ready:
previous_top_move = self.parent.candidate_moves[0]
if sgf or hints:
@@ -138,19 +135,20 @@ class GameNode(SGFNode):
points_lost = self.points_lost
if sgf and points_lost > 0.5:
text += i18n._("Info:point loss").format(points=points_lost) + "\n"
text += i18n._("Info:top move").format(top_move=previous_top_move['move'],score=self.format_score(previous_top_move['scoreLead'])) +".\n"
text += i18n._("Info:top move").format(top_move=previous_top_move["move"], score=self.format_score(previous_top_move["scoreLead"])) + "\n"
else:
text += i18n._("Info:best move")+"\n"
text += i18n._("Info:best move") + "\n"
if previous_top_move.get("pv") and (sgf or hints):
text += i18n._("Info:PV") + ": " + self.make_pv(single_move.player,previous_top_move['pv'],interactive) + "\n"
print("PREV", previous_top_move)
text += i18n._("Info:PV").format(pv=self.make_pv(single_move.player, previous_top_move["pv"], interactive)) + "\n"
if sgf or hints or teach:
policy_ranking = self.parent.policy_ranking
currmove_policy_with_ix = [(ix + 1, p) for (p, m), ix in zip(policy_ranking, range(len(policy_ranking))) if m == single_move]
if currmove_policy_with_ix:
text += i18n._("Info:policy rank").format(rank=currmove_policy_with_ix[0][0],probability=currmove_policy_with_ix[0][1]) + "\n"
text += i18n._("Info:policy rank").format(rank=currmove_policy_with_ix[0][0], probability=currmove_policy_with_ix[0][1]) + "\n"
if not currmove_policy_with_ix or currmove_policy_with_ix[0] != 1 and (sgf or hints):
text += i18n._("Info:policy best").format(move=policy_ranking[0][1].gtp(),probability=policy_ranking[0][0]) +".\n"
text += i18n._("Info:policy best").format(move=policy_ranking[0][1].gtp(), probability=policy_ranking[0][0]) + "\n"
if self.auto_undo and sgf:
text += i18n._("Info:teaching undo") + "\n"
top_pv = self.analysis_ready and self.candidate_moves[0].get("pv")