<commit_before>import nltk
import re
import pprint

def do_ner(text):
	print text
	rl = []
	np = []
	ne = []
        for sentence in nltk.sent_tokenize(text): #re.sub(r'[^\x00-\x7F]+',' ', text)):

            sentence_tok = nltk.word_tokenize(sentence)
            sentence_tok = nltk.pos_tag(sentence_tok)


	    grammar = r"""
  NP: {<DT|PP\$>?<JJ>*<NN|NNP>+}   # chunk determiner/possessive, adjectives and noun
""" #      {<NNP>+}                # chunk sequences of proper nouns
#"""        
            cp = nltk.RegexpParser(grammar)

	    ret = dict()
            ret['sentence'] = sentence
            ret['npr'] = cp.parse(sentence_tok)
            ret['ner'] = nltk.ne_chunk(sentence_tok, binary=True)
	    ret['noun_phrases_tree'] = filter(lambda x: x.node == 'NP', ret['npr'].subtrees())<commit_msg>auto-download nltk packages<commit_after>import nltk
import re
import pprint

nltk.download('maxent_ne_chunker')
nltk.download('maxent_treebank_pos_tagger')
nltk.download('punkt')
nltk.download('words')

def do_ner(text):
	print text
	rl = []
	np = []
	ne = []
        for sentence in nltk.sent_tokenize(text): #re.sub(r'[^\x00-\x7F]+',' ', text)):

            sentence_tok = nltk.word_tokenize(sentence)
            sentence_tok = nltk.pos_tag(sentence_tok)


	    grammar = r"""
  NP: {<DT|PP\$>?<JJ>*<NN|NNP>+}   # chunk determiner/possessive, adjectives and noun
""" #      {<NNP>+}                # chunk sequences of proper nouns
#"""        
            cp = nltk.RegexpParser(grammar)

	    ret = dict()
            ret['sentence'] = sentence
            ret['npr'] = cp.parse(sentence_tok)
            ret['ner'] = nltk.ne_chunk(sentence_tok, binary=True)
	    ret['noun_phrases_tree'] = filter(lambda x: x.node == 'NP', ret['npr'].subtrees())
{'fraction_non_alphanumeric': 0.1636466591166478, 'fraction_numerical': 0.0033975084937712344, 'mean_word_length': 2.8, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '569915', 'n_tokens_mistral': 676, 'n_tokens_neox': 635, 'n_words': 115}