<commit_before>#!/usr/bin/env python3

"""
This a script that takes the result of automatic postediting encoded as a
sequence of <keep>, <delete> and insert operations and applies them on the
original text being post-edited.

The inverse script to this one is 'post_edit_prepare_data.py'.
"""

# tests: lint, mypy

import argparse
from neuralmonkey.processors.german import GermanPreprocessor, GermanPostprocessor
from neuralmonkey.learning_utils import load_tokenized

## TODO make reconstruct a postprocessor
def reconstruct(source, edits):
    index = 0
    target = []

    for edit in edits:
        if edit == '<keep>':
            if index < len(source):
                target.append(source[index])
            index += 1

        elif edit == '<delete>':
            index += 1

        else:<commit_msg>making sure scripts from tutorial work<commit_after>#!/usr/bin/env python3

"""
This a script that takes the result of automatic postediting encoded as a
sequence of <keep>, <delete> and insert operations and applies them on the
original text being post-edited.

The inverse script to this one is 'postedit_prepare_data.py'.
"""

# tests: lint, mypy

import argparse
from neuralmonkey.processors.german import GermanPreprocessor, GermanPostprocessor
from neuralmonkey.learning_utils import load_tokenized

## TODO make reconstruct a postprocessor
def reconstruct(source, edits):
    index = 0
    target = []

    for edit in edits:
        if edit == '<keep>':
            if index < len(source):
                target.append(source[index])
            index += 1

        elif edit == '<delete>':
            index += 1

        else:
{'fraction_non_alphanumeric': 0.08606060606060606, 'fraction_numerical': 0.0048484848484848485, 'mean_word_length': 3.0465686274509802, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '2254376', 'n_tokens_mistral': 461, 'n_tokens_neox': 438, 'n_words': 170}