<commit_before>package scala.xml.nobinding;

import scala.collection.mutable.HashMap ;
import scala.xml.{Node,Text,FactoryAdapter,Utility} ;
import org.xml.sax.InputSource;

/** nobinding adaptor providing callbacks to parser to create elements.
*   implements hash-consing
*/
class NoBindingFactoryAdapter extends FactoryAdapter  {

  def nodeContainsText( label:java.lang.String ):boolean = true;

  /* default behaviour is hash-consing */
  val cache = new HashMap[int,Symbol]();

  def createNode( label: String, attrs: HashMap[String,String], children: List[Node] ):Symbol = {

    val elHashCode = Utility.hashCode( label, attrs, children ) ;

    cache.get( elHashCode ).match{
      case Some(cachedElem) =>
        //System.err.println("[using cached elem +"+cachedElem.toXML+"!]");
      cachedElem
      case None => val el = if( children.isEmpty ) {
       new Symbol( label ) {
          override def attributes = attrs;
          override def hashCode() = Utility.hashCode( label, attrs.toList.hashCode(), children );
        };
      } else {
       new Symbol( label, children:_* ) {
          override def attributes = attrs;
          override def hashCode() = Utility.hashCode( label, attrs.toList.hashCode(), children );
        };
      }
      cache.update( elHashCode, el );
      el
    }
  }

  def createText( text:String ) = Text( text );

  override def loadXML( source:InputSource ):Symbol =
    super.loadXML( source ).asInstanceOf[ Symbol ]
}
<commit_msg>handling of attribUTES<commit_after>package scala.xml.nobinding;

import scala.collection.mutable.HashMap ;
import scala.collection.immutable.ListMap ;
import scala.xml.{Node,Text,FactoryAdapter,Utility} ;
import org.xml.sax.InputSource;

/** nobinding adaptor providing callbacks to parser to create elements.
*   implements hash-consing
*/
class NoBindingFactoryAdapter extends FactoryAdapter  {

  def nodeContainsText( label:java.lang.String ):boolean = true;

  /* default behaviour is hash-consing */
  val cache = new HashMap[int,Symbol]();

  def createNode( label: String, attrs: HashMap[String,String], children: List[Node] ):Symbol = {

    val elHashCode = Utility.hashCode( label, attrs, children ) ;

    val attrList = attrs.toList;

    cache.get( elHashCode ).match{
      case Some(cachedElem) =>
        //System.err.println("[using cached elem +"+cachedElem.toXML+"!]");
      cachedElem
      case None => val el = if( children.isEmpty ) {
       new Symbol( label ) {
          override def attributes = ListMap.Empty[String,String].incl( attrList );
          override def hashCode() = Utility.hashCode( label, attrList.hashCode(), children );
        };
      } else {
       new Symbol( label, children:_* ) {
          override def attributes = ListMap.Empty[String,String].incl( attrList );
          override def hashCode() = Utility.hashCode( label, attrList.hashCode(), children );
        };
      }
      cache.update( elHashCode, el );
      el
    }
  }

  def createText( text:String ) = Text( text );

  override def loadXML( source:InputSource ):Symbol =
    super.loadXML( source ).asInstanceOf[ Symbol ]
}

{'fraction_non_alphanumeric': 0.1204088150750559, 'fraction_numerical': 0.0, 'mean_word_length': 3.2267206477732793, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '1690139', 'n_tokens_mistral': 906, 'n_tokens_neox': 905, 'n_words': 239}