<commit_before>package com.imcode.imcms.domain.service.api;

import com.imcode.imcms.domain.dto.TextValidationResult;
import com.imcode.imcms.domain.service.TextValidationService;
import com.jcabi.w3c.Defect;
import com.jcabi.w3c.ValidationResponse;
import com.jcabi.w3c.ValidatorBuilder;
import org.springframework.stereotype.Service;

import java.io.IOException;

/**
 * {@link TextValidationService} implementation with w3c text validation.
 *
 * @author <NAME> from Ubrainians for imCode
 * 31.01.18.
 */
@Service
class W3cTextValidationService implements TextValidationService {

    /**
     * {@inheritDoc}
     *
     * @param content Text, that should be validated by W3C
     * @see ValidatorBuilder
     * @see ValidationResponse
     * @see com.jcabi.w3c.Validator
     * @see Defect
     */
    @Override
    public TextValidationResult validateText(String content) throws IOException {
        // this wrapping is necessary because validator checks full page, not the piece of html.
        final String contentWrapper = "<!DOCTYPE html>\n"
                + "<html>\n"
                + "  <head>\n"
                + "    <meta charset=\"utf-8\">\n"
                + "    <title>ImCMS HTML validation</title>\n"
                + "    <meta name=\"description\" content=\"ImCMS HTML validation\">\n"
                + "  </head>\n"
                + "  <body>%s</body>\n"
                + "</html>";

        content = String.format(contentWrapper, content);

        final ValidationResponse response = new ValidatorBuilder().html().validate(content);

        return new TextValidationResult(response);
    }
}<commit_msg>IMCMS-233 - Apply new UI to the admin panel and editors: - Fixed text validator.<commit_after>package com.imcode.imcms.domain.service.api;

import com.imcode.imcms.domain.dto.TextValidationResult;
import com.imcode.imcms.domain.service.TextValidationService;
import com.jcabi.w3c.Defect;
import com.jcabi.w3c.ValidationResponse;
import com.jcabi.w3c.ValidatorBuilder;
import org.springframework.stereotype.Service;

import java.io.IOException;

/**
 * {@link TextValidationService} implementation with w3c text validation.
 *
 * @author <NAME> from Ubrainians for imCode
 * 31.01.18.
 */
@Service
class W3cTextValidationService implements TextValidationService {

    /**
     * {@inheritDoc}
     *
     * @param content Text, that should be validated by W3C
     * @see ValidatorBuilder
     * @see ValidationResponse
     * @see com.jcabi.w3c.Validator
     * @see Defect
     */
    @Override
    public TextValidationResult validateText(String content) throws IOException {
        // this wrapping is necessary because validator checks full page, not the piece of html.
        final String contentWrapper = "<!DOCTYPE html>\n"
                + "<html lang=\"en\">\n"
                + "  <head>\n"
                + "    <meta charset=\"utf-8\">\n"
                + "    <title>ImCMS HTML validation</title>\n"
                + "    <meta name=\"description\" content=\"ImCMS HTML validation\">\n"
                + "  </head>\n"
                + "  <body>%s</body>\n"
                + "</html>";

        content = String.format(contentWrapper, content);

        final ValidationResponse response = new ValidatorBuilder().html().validate(content);

        return new TextValidationResult(response);
    }
}
{'fraction_non_alphanumeric': 0.1183467142432352, 'fraction_numerical': 0.009217960154623847, 'mean_word_length': 2.617204301075269, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '6990623', 'n_tokens_mistral': 1005, 'n_tokens_neox': 939, 'n_words': 223}