<commit_before>import { Injectable } from '@angular/core'
import { Observable } from 'rxjs'

import * as MuteStructs  from 'mute-structs'

@Injectable()
export class DocService {

  private doc: any

  constructor() {
    this.doc = new MuteStructs.LogootSRopes(0)
  }

  setTextOperationsStream(textOperationsStream: Observable<any[]>) {
    textOperationsStream.subscribe( (array: any[][]) => {
      this.handleTextOperations(array)
    })
  }

  handleTextOperations(array: any[][]) {
    array.forEach( (textOperations: any[]) => {
      textOperations.forEach( (textOperation: any) => {
        const logootSOperation: any = textOperation.applyTo(this.doc)
        console.log(logootSOperation)
      })
      console.log('doc: ', this.doc)
    })
  }

}<commit_msg>feat(doc): Apply remote operations and stream resulting text operations<commit_after>import { Injectable } from '@angular/core'
import { Observable } from 'rxjs'

import { NetworkService } from '../core/network/network.service'

import * as MuteStructs  from 'mute-structs'

@Injectable()
export class DocService {

  private doc: any
  private network: NetworkService
  private remoteTextOperationsStream: Observable<any[]>

  constructor(network: NetworkService) {
    this.doc = new MuteStructs.LogootSRopes(0)
    this.network = network
    this.remoteTextOperationsStream = this.network.onRemoteOperations.map( (logootSOperation: any) => {
      return this.handleRemoteOperation(logootSOperation)
    })
  }

  setTextOperationsStream(textOperationsStream: Observable<any[]>) {
    textOperationsStream.subscribe( (array: any[][]) => {
      this.handleTextOperations(array)
    })
  }

  getRemoteTextOperationsStream(): Observable<any[]> {
    return this.remoteTextOperationsStream
  }

  handleTextOperations(array: any[][]) {
    array.forEach( (textOperations: any[]) => {
      textOperations.forEach( (textOperation: any) => {
        const logootSOperation: any = textOperation.applyTo(this.doc)
        console.log(logootSOperation)
      })
      console.log('doc: ', this.doc)
    })
  }

  handleRemoteOperation(logootSOperation: any) {
    const textOperations: any[] = logootSOperation.execute(this.doc)
    return textOperations
  }

}
{'fraction_non_alphanumeric': 0.12292507851054285, 'fraction_numerical': 0.0008972633467922835, 'mean_word_length': 4.068181818181818, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 14, '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': '1045594', 'n_tokens_mistral': 663, 'n_tokens_neox': 680, 'n_words': 129}