<commit_before>import web
from PyZ3950 import zoom
from pymarc import MARCReader, marc8_to_unicode

class Serializer:
  """Serializes a PyZ3950.zoom.ResultSet object as a pymarc.MARCReader object"""
  def pymarc_serialize(self):
    result_list = []
    for result in self:
      result_list.append(result.data)
    return MARCReader("".join(result_list))

class Humanizer:
  """Humanizes a pymarc.Field or pymarc.Record object.
  
  Uses the string methods of pymarc to generate MARCBreaker format data.
  Newlines are prettified into line break tags, and then the ANSEL characters
  are encoded into Unicode."""
  def humanize(self):
    h = self.__str__()
    h = web.net.htmlquote(h)
    h = h.replace('\n', '<br/>\n')
    return marc8_to_unicode(h)
#<commit_msg>making imports in pymarc_helper more efficient<commit_after>from web.net import htmlquote
from pymarc import MARCReader, marc8_to_unicode

class Serializer:
  """Serializes a PyZ3950.zoom.ResultSet object as a pymarc.MARCReader object"""
  def pymarc_serialize(self):
    result_list = []
    for result in self:
      result_list.append(result.data)
    return MARCReader("".join(result_list))

class Humanizer:
  """Humanizes a pymarc.Field or pymarc.Record object.
  
  Uses the string methods of pymarc to generate MARCBreaker format data.
  Newlines are prettified into line break tags, and then the ANSEL characters
  are encoded into Unicode."""
  def humanize(self):
    h = self.__str__()
    h = htmlquote(h)
    h = h.replace('\n', '<br/>\n')
    return marc8_to_unicode(h)
#
{'fraction_non_alphanumeric': 0.09465550547327753, 'fraction_numerical': 0.0103026400515132, 'mean_word_length': 4.029126213592233, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6092217', 'n_tokens_mistral': 531, 'n_tokens_neox': 516, 'n_words': 157}