<commit_before><template>
  <div class="phrase-input-wrapper">
    <input
      v-for="(word, index) in words"
      :key="index"
      type="text"
      class="word-input"
      ref="wordinput"
      @input="onInput(index, $event)"
      @focus="onFocus(index)"
      v-model="inputWords[index]"
      :class="getCssClass(index)"
      :disabled="isExactMatch(index)"
    />
  </div>
</template>

<script>
export default {
  name: "PhraseInput",
  props: {
    validate: {
      type: [String, Object],
      default: ""
    },
    isPhraseInvalid: {
      type: Boolean,
      default: false
    },
    autofocus: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      inputWords: []
    };
  },
  mounted() {
    if (this.autofocus) {
      this.$nextTick(() => {
        this.$refs.wordinput[0].focus();
      });
    }
  },
  computed: {
    isRecovery() {
      return typeof this.validate !== "string";
    },
    words() {
      return this.isRecovery
        ? Array(this.validate.length)
            .join(".")
            .split(".")
        : this.validate.split(" ");
    },
    isPhraseComplete() {
      let phraseComplete = true;
      for (var i = 0; i < this.words.length; i++) {
        if (this.isExactMatch(i) == false) {
          phraseComplete = false;
          break;
        }
      }
      return phraseComplete;
    }
  },
  methods: {
    clear() {
      this.inputWords = [];
      this.$nextTick(() => {
        this.$refs.wordinput[0].focus();
      });
    },
    onFocus(index) {
      let newIndex = 0;
      for (var i = 0; i <= index; i++) {
        if (this.isMatch(i) === false) {
          newIndex = i;
          break;
        }
      }
      if (index !== newIndex) {<commit_msg>fix for phrases with non exact match<commit_after><template>
  <div class="phrase-input-wrapper">
    <input
      v-for="(word, index) in words"
      :key="index"
      type="text"
      class="word-input"
      ref="wordinput"
      @input="onInput(index, $event)"
      @focus="onFocus(index)"
      v-model="inputWords[index]"
      :class="getCssClass(index)"
      :disabled="isExactMatch(index)"
    />
  </div>
</template>

<script>
export default {
  name: "PhraseInput",
  props: {
    validate: {
      type: [String, Object],
      default: ""
    },
    isPhraseInvalid: {
      type: Boolean,
      default: false
    },
    autofocus: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      inputWords: []
    };
  },
  mounted() {
    if (this.autofocus) {
      this.$nextTick(() => {
        this.$refs.wordinput[0].focus();
      });
    }
  },
  computed: {
    isRecovery() {
      return typeof this.validate !== "string";
    },
    words() {
      return this.isRecovery
        ? Array(this.validate.length)
            .join(".")
            .split(".")
        : this.validate.split(" ");
    },
    isPhraseComplete() {
      let phraseComplete = true;
      for (var i = 0; i < this.words.length; i++) {
        if (this.isMatch(i) == false) {
          phraseComplete = false;
          break;
        }
      }
      return phraseComplete;
    }
  },
  methods: {
    clear() {
      this.inputWords = [];
      this.$nextTick(() => {
        this.$refs.wordinput[0].focus();
      });
    },
    onFocus(index) {
      let newIndex = 0;
      for (var i = 0; i <= index; i++) {
        if (this.isMatch(i) === false) {
          newIndex = i;
          break;
        }
      }
      if (index !== newIndex) {
{'fraction_non_alphanumeric': 0.16808631459398068, 'fraction_numerical': 0.0028392958546280523, 'mean_word_length': 1.7805840568271507, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '2649282', 'n_tokens_mistral': 1175, 'n_tokens_neox': 1154, 'n_words': 218}