<commit_before>package lila.analyse

import play.api.libs.json._

import lila.common.PimpedJson._
import lila.game.Game

object JsonView {

  def moves(analysis: Analysis) = JsArray(analysis.infoAdvices map {
    case ((info, adviceOption)) => Json.obj(
      "eval" -> info.score.map(_.centipawns),
      "mate" -> info.mate,
      "variation" -> info.variation.isEmpty.fold(JsNull, info.variation mkString " "),
      "comment" -> adviceOption.map(_.makeComment(false, true))
    ).noNull
  })

  def player(pov: lila.game.Pov)(analysis: Analysis) =
    analysis.summary.find(_._1 == pov.color).map(_._2).map(s =>
      JsObject(s map {
        case (nag, nb) => nag.toString.toLowerCase -> JsNumber(nb)
      }) ++ lila.analyse.Accuracy.mean(pov, analysis).fold(Json.obj()) { acpl =>
        Json.obj("acpl" -> acpl)
      }
    )

  def bothPlayers(game: Game, analysis: Analysis) = Json.obj(
    "white" -> player(game.whitePov)(analysis),
    "black" -> player(game.blackPov)(analysis))

  def mobile(game: Game, analysis: Analysis) = Json.obj(
    "summary" -> bothPlayers(game, analysis),
    "moves" -> moves(analysis)
  )
}<commit_msg>Add more infos to remote analysis json<commit_after>package lila.analyse

import play.api.libs.json._

import lila.common.PimpedJson._
import lila.game.Game

object JsonView {

  def moves(analysis: Analysis) = JsArray(analysis.infoAdvices map {
    case ((info, adviceOption)) => Json.obj(
      "eval" -> info.score.map(_.centipawns),
      "best" -> info.best.map(_.uci),
      "mate" -> info.mate,
      "variation" -> info.variation.isEmpty.fold(JsNull, info.variation mkString " "),
      "judgment" -> adviceOption.map { a =>
        Json.obj(
          "glyph" -> Json.obj(
            "name" -> a.judgment.glyph.name,
            "symbol" -> a.judgment.glyph.symbol
          ),
          "name" -> a.judgment.name
        )
      },
      "comment" -> adviceOption.map(_.makeComment(false, true))
    ).noNull
  })

  def player(pov: lila.game.Pov)(analysis: Analysis) =
    analysis.summary.find(_._1 == pov.color).map(_._2).map(s =>
      JsObject(s map {
        case (nag, nb) => nag.toString.toLowerCase -> JsNumber(nb)
      }) ++ lila.analyse.Accuracy.mean(pov, analysis).fold(Json.obj()) { acpl =>
        Json.obj("acpl" -> acpl)
      }
    )

  def bothPlayers(game: Game, analysis: Analysis) = Json.obj(
    "white" -> player(game.whitePov)(analysis),
    "black" -> player(game.blackPov)(analysis))

  def mobile(game: Game, analysis: Analysis) = Json.obj(
    "summary" -> bothPlayers(game, analysis),
    "moves" -> moves(analysis)
  )
}
{'fraction_non_alphanumeric': 0.16800920598388952, 'fraction_numerical': 0.0015343306482546988, 'mean_word_length': 2.904191616766467, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '961858', 'n_tokens_mistral': 915, 'n_tokens_neox': 892, 'n_words': 160}