<commit_before>#!/usr/bin/env python
#-*- coding: utf-8 -*-

""" 
summarizer extracts summary or first paragraph from news
"""
# @author chengdujin
# @contact <EMAIL>
# created Jul. 29, 2013


import sys
reload(sys)
sys.setdefaultencoding('UTF-8')
sys.path.append('..')

import chardet
import html2text
import logger
import nltk

# CONSTANTS
from config import PARAGRAPH_CRITERIA
from config import SUMMARY_LENGTH_LIMIT


def _get_shorter_text(content, language, limit):
    """
    limit the number of words to 500
    """
    if not content or not language:
        logger.error('Method malformed!')
        return None

    try:
        # data should be processed as unicode, so
        if isinstance(content, str):
            content = content.decode(
                chardet.detect(content)['encoding'], 'ignore')

        # break text by sentence
        if language.startswith('zh') or language == 'ja':<commit_msg>corrected a wrong import<commit_after>#!/usr/bin/env python
#-*- coding: utf-8 -*-

""" 
summarizer extracts summary or first paragraph from news
"""
# @author chengdujin
# @contact <EMAIL>
# created Jul. 29, 2013


import sys
reload(sys)
sys.setdefaultencoding('UTF-8')
sys.path.append('..')

import chardet
from config import logger
import html2text
import nltk

# CONSTANTS
from config import PARAGRAPH_CRITERIA
from config import SUMMARY_LENGTH_LIMIT


def _get_shorter_text(content, language, limit):
    """
    limit the number of words to 500
    """
    if not content or not language:
        logger.error('Method malformed!')
        return None

    try:
        # data should be processed as unicode, so
        if isinstance(content, str):
            content = content.decode(
                chardet.detect(content)['encoding'], 'ignore')

        # break text by sentence
        if language.startswith('zh') or language == 'ja':
{'fraction_non_alphanumeric': 0.10593900481540931, 'fraction_numerical': 0.012841091492776886, 'mean_word_length': 3.1008771929824563, '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': '1541510', 'n_tokens_mistral': 594, 'n_tokens_neox': 547, 'n_words': 178}