Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for index, country in self.automaton.iter(text):
# log.debug("Matched: %s -> %s", name, country)
country_tags.append(country)
doc_tags = []
co_counts = Counter(country_tags)
top_n = co_counts.most_common(self.MAX_TAGS)
for tag_num in range(1, self.MAX_TAGS + 1):
if len(top_n) >= tag_num:
freq = top_n[tag_num-1][1] / max(1, word_count)
log.info('tag is %s, freq = %.2f', top_n[tag_num-1], freq)
if freq >= self.TAG_FREQUENCY_CUT:
doc_tags.append(top_n[tag_num-1][0])
return CountryTags(countries=doc_tags)