Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search includes middle name ? #33

Open
Noop3 opened this issue Dec 4, 2023 · 1 comment
Open

search includes middle name ? #33

Noop3 opened this issue Dec 4, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@Noop3
Copy link

Noop3 commented Dec 4, 2023

How do I search for not only first and last name, I want to combine middle name also

@m8sec m8sec added the enhancement New feature or request label Dec 18, 2023
@tvvoorst
Copy link

tvvoorst commented Jul 4, 2024

This definitely is not perfect but got the job done for me. Works for most names that have prefixes (von, El, di etc. ), assume it would work for middle names aswell. Might require some work for multiple middle names.

python3 ../crosslinked.py -f "{f}.{prefix}.{last}@google.de" "Google"

Replace in __init__.py

def nformatter(nformat, name):
    # Get position of name values in text
    tmp = nformat.split('}')
    print(tmp)
    f_position = int(re.search(r'(-?\d+)', tmp[0]).group(0)) if ':' in tmp[0] else 0
    l_position = int(re.search(r'(-?\d+)', tmp[1]).group(0)) if ':' in tmp[1] else -1

    # Extract names from raw text
    tmp = name.split(' ')
    # check if name contains prefix/middlename
    if len(tmp) > 2:
        f_name = tmp[0]
        p_name = tmp[1:-1]
        # combine prefixes with a period
        p_name = '.'.join(map(str, p_name))
        l_name = tmp[-1]

        # Use replace function to create final output
        val = re.sub(r'-?\d+:', '', nformat)
        val = val.replace('{f}', f_name[0])
        val = val.replace('{first}', f_name)
        val = val.replace('{l}', l_name[0])
        val = val.replace('{last}', l_name)
        # if its a one char, or ends in period remove middle name
        if p_name.endswith('.') or (len(p_name) == 1):
            val = val.replace('.{prefix}', "")
            val = val.replace('{prefix}', "")
        else:
            val = val.replace('{prefix}', p_name)
        print(val)
        return val
    else:
        try:
            f_name = tmp[f_position] if len(tmp) > 2 else tmp[0]
            l_name = tmp[l_position] if len(tmp) > 2 else tmp[-1]
        except:
            f_name = tmp[0]
            l_name = tmp[-1]

        # Use replace function to create final output
        val = re.sub(r'-?\d+:', '', nformat)
        val = val.replace('{f}', f_name[0])
        val = val.replace('{first}', f_name)
        val = val.replace('{l}', l_name[0])
        val = val.replace('{last}', l_name)
        # remove prefix name placeholder if it does not exist 
        val = val.replace('.{prefix}', "")
        val = val.replace('{prefix}', "")

        print(val)
        return val

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants