<commit_before>
from mangrove.datastore.entity import  get_all_entities, Entity
# from mangrove.datastore.queries import get_entities_by_type

from mangrove.errors.MangroveException import NumberNotRegisteredException, MultipleReportersForANumberException
from mangrove.form_model.form_model import MOBILE_NUMBER_FIELD
from mangrove.transport.repository.survey_responses import get_survey_responses_for_activity_period

REPORTER_ENTITY_TYPE = ["reporter"]


def find_reporter(dbm, from_number):
    from_reporter_list = find_reporters_by_from_number(dbm, from_number)
    return [each.latest_values() for each in from_reporter_list]


def find_reporter_entity(dbm, from_number):
    reporter_list = find_reporters_by_from_number(dbm, from_number)
    if len(reporter_list) > 1:
        raise MultipleReportersForANumberException(from_number)
    return reporter_list[0]


def find_reporters_by_from_number(dbm, from_number):
    rows = dbm.view.datasender_by_mobile(start_key=[from_number], end_key=[from_number,{},{}], include_docs=True)
    if (len(rows) == 0): raise NumberNotRegisteredException(from_number)<commit_msg>Pooja/Ajay | #3556 | Bugfix - Fixed import for reminders<commit_after>
from mangrove.datastore.entity import  get_all_entities, Entity
from mangrove.datastore.queries import get_entities_by_type

from mangrove.errors.MangroveException import NumberNotRegisteredException, MultipleReportersForANumberException
from mangrove.form_model.form_model import MOBILE_NUMBER_FIELD
from mangrove.transport.repository.survey_responses import get_survey_responses_for_activity_period

REPORTER_ENTITY_TYPE = ["reporter"]


def find_reporter(dbm, from_number):
    from_reporter_list = find_reporters_by_from_number(dbm, from_number)
    return [each.latest_values() for each in from_reporter_list]


def find_reporter_entity(dbm, from_number):
    reporter_list = find_reporters_by_from_number(dbm, from_number)
    if len(reporter_list) > 1:
        raise MultipleReportersForANumberException(from_number)
    return reporter_list[0]


def find_reporters_by_from_number(dbm, from_number):
    rows = dbm.view.datasender_by_mobile(start_key=[from_number], end_key=[from_number,{},{}], include_docs=True)
    if (len(rows) == 0): raise NumberNotRegisteredException(from_number)
{'fraction_non_alphanumeric': 0.07520769567118496, 'fraction_numerical': 0.004372540445999125, 'mean_word_length': 7.633962264150943, 'pattern_counts': {'":': 0, '<': 3, '<?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': '121350', 'n_tokens_mistral': 786, 'n_tokens_neox': 742, 'n_words': 129}