<commit_before>import NamespacedIdentity from "./NamespacedIdentity";
class NamespacedDictionary<V> {

  private _nameObjectMap: Map<string, Map<string, V>> = new Map<string, Map<string, V>>();

  private _fqnObjectMap: Map<string, V> = new Map<string, V>();

  public set(key: NamespacedIdentity, value: V): void {
    let namedChildMap: Map<string, V>;
    if (this._nameObjectMap.has(key.name)) {
      namedChildMap = this._nameObjectMap.get(key.name);
    } else {
      namedChildMap = new Map<string, V>();
      this._nameObjectMap.set(key.name, namedChildMap);
    }
    namedChildMap.set(key.fqn, value);
    this._fqnObjectMap.set(key.fqn, value);
  }

  public delete(key: NamespacedIdentity): void {
    if (this._fqnObjectMap.has(key.fqn)) {
      const theMap = this._nameObjectMap.get(key.name);
      if (theMap.size === 1) {
        this._nameObjectMap.delete(key.name);
      } else {
        theMap.delete(key.fqn);
      }
      this._fqnObjectMap.delete(key.fqn);
    }
  }

  public get(name: string): V;
  public get(ns: string, name: string): V;
  public get(nsi: NamespacedIdentity): V;
  public get(element: Element): V;
  public get(attribute: Attr): V;
  public get(arg1: string | Element | NamespacedIdentity | Attr, name?: string): V {
    if (typeof arg1 === "string") {
      if (name) {
        return this.get(new NamespacedIdentity(arg1 as string, name));
      } else {
        const namedMap = this._nameObjectMap.get((arg1 as string).toUpperCase());
        if (namedMap.size === 1) {
          const itr = namedMap.values();
          return itr.next().value;
        } else {
          throw new Error(`Specified tag name ${arg1} is ambigious to identify.`);
        }
      }
    } else {
      if (arg1 instanceof NamespacedIdentity) {
        return this.fromFQN((arg1 as NamespacedIdentity).fqn);
      } else {
        if (arg1.prefix) {
          return this.get(new NamespacedIdentity(arg1.namespaceURI, arg1.localName));
        } else {
          if (arg1.namespaceURI && this._fqnObjectMap.has(arg1.localName.toUpperCase() + "|" + arg1.namespaceURI.toUpperCase())) {
            return this.get(new NamespacedIdentity(arg1.namespaceURI.toUpperCase(), arg1.localName.toUpperCase()));
          }
          if ((arg1 as Attr).ownerElement.namespaceURI && this._fqnObjectMap.has(arg1.localName.toUpperCase() + "|" + (arg1 as Attr).ownerElement.namespaceURI.toUpperCase())) {
            return this.get(new NamespacedIdentity((arg1 as Attr).ownerElement.namespaceURI.toUpperCase(), arg1.localName.toUpperCase()));
          }
          return this.get(arg1.localName);
        }
      }
    }
  }

  public fromFQN(fqn: string): V {
    return this._fqnObjectMap.get(fqn);
  }

  public isAmbigious(name: string): boolean {
    return this._nameObjectMap.get(name.toUpperCase()).size > 1;
  }

  public has(name: string): boolean {
    return this._nameObjectMap.has(name);
  }

  public pushDictionary(dict: NamespacedDictionary<V>): void {
    dict._fqnObjectMap.forEach((value, keyFQN) => {
      const id = NamespacedIdentity.fromFQN(keyFQN);
      this.set(id, value);
    });
  }
}<commit_msg>fix NamespacedDictionary.pushDictionary<commit_after>import NamespacedIdentity from "./NamespacedIdentity";
class NamespacedDictionary<V> {

  private _nameObjectMap: Map<string, Map<string, V>> = new Map<string, Map<string, V>>();

  private _fqnObjectMap: Map<string, V> = new Map<string, V>();

  public set(key: NamespacedIdentity, value: V): void {
    let namedChildMap: Map<string, V>;
    if (this._nameObjectMap.has(key.name)) {
      namedChildMap = this._nameObjectMap.get(key.name);
    } else {
      namedChildMap = new Map<string, V>();
      this._nameObjectMap.set(key.name, namedChildMap);
    }
    namedChildMap.set(key.fqn, value);
    this._fqnObjectMap.set(key.fqn, value);
  }

  public delete(key: NamespacedIdentity): void {
    if (this._fqnObjectMap.has(key.fqn)) {
      const theMap = this._nameObjectMap.get(key.name);
      if (theMap.size === 1) {
        this._nameObjectMap.delete(key.name);
      } else {
        theMap.delete(key.fqn);
      }
      this._fqnObjectMap.delete(key.fqn);
    }
  }

  public get(name: string): V;
  public get(ns: string, name: string): V;
  public get(nsi: NamespacedIdentity): V;
  public get(element: Element): V;
  public get(attribute: Attr): V;
  public get(arg1: string | Element | NamespacedIdentity | Attr, name?: string): V {
    if (typeof arg1 === "string") {
      if (name) {
        return this.get(new NamespacedIdentity(arg1 as string, name));
      } else {
        const namedMap = this._nameObjectMap.get((arg1 as string).toUpperCase());
        if (namedMap.size === 1) {
          const itr = namedMap.values();
          return itr.next().value;
        } else {
          throw new Error(`Specified tag name ${arg1} is ambigious to identify.`);
        }
      }
    } else {
      if (arg1 instanceof NamespacedIdentity) {
        return this.fromFQN((arg1 as NamespacedIdentity).fqn);
      } else {
        if (arg1.prefix) {
          return this.get(new NamespacedIdentity(arg1.namespaceURI, arg1.localName));
        } else {
          if (arg1.namespaceURI && this._fqnObjectMap.has(arg1.localName.toUpperCase() + "|" + arg1.namespaceURI.toUpperCase())) {
            return this.get(new NamespacedIdentity(arg1.namespaceURI.toUpperCase(), arg1.localName.toUpperCase()));
          }
          if ((arg1 as Attr).ownerElement.namespaceURI && this._fqnObjectMap.has(arg1.localName.toUpperCase() + "|" + (arg1 as Attr).ownerElement.namespaceURI.toUpperCase())) {
            return this.get(new NamespacedIdentity((arg1 as Attr).ownerElement.namespaceURI.toUpperCase(), arg1.localName.toUpperCase()));
          }
          return this.get(arg1.localName);
        }
      }
    }
  }

  public fromFQN(fqn: string): V {
    return this._fqnObjectMap.get(fqn);
  }

  public isAmbigious(name: string): boolean {
    return this._nameObjectMap.get(name.toUpperCase()).size > 1;
  }

  public has(name: string): boolean {
    return this._nameObjectMap.has(name);
  }

  public pushDictionary(dict: NamespacedDictionary<V>): NamespacedDictionary<V> {
    dict._fqnObjectMap.forEach((value, keyFQN) => {
      const id = NamespacedIdentity.fromFQN(keyFQN);
      this.set(id, value);
    });
    return this;
  }
}
{'fraction_non_alphanumeric': 0.13876651982378854, 'fraction_numerical': 0.007551919446192574, 'mean_word_length': 3.0671785028790786, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 28, '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': '4136576', 'n_tokens_mistral': 2135, 'n_tokens_neox': 2045, 'n_words': 407}