Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3491180
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:36:21+00:00 2026-05-18T11:36:21+00:00

I am mapping some human-input text to part names today, and came across a

  • 0

I am mapping some human-input text to part names today, and came across a case that might be of general interest. Here is the human-input text:

Seat (Dis.)

Disc seat

seats

Seat (Suc.)

Suct seat

The two parts names to map to are SEAT, DISCHARGE and SEAT, SUCTION. We will also map the ambiguous seats to SEAT, DISCHARGE. The reason for using a regex is that we can anticipate new cases in the future such as discharge seat etc.

So currently I am tackling this with two search() calls like this pseudocode:

if [Ss][Ee][Aa][Tt] matches input name:

if [Ss][Uu][Cc] matches input name, part is SEAT, SUCTION
else part is SEAT, DISCHARGE

Is there a better way to do this kind of mapping? Better would mean: more compact code, easier to tweak to handle new cases, or a better probability to handle more cases without code modification.

  • 1 1 Answer
  • 4 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T11:36:22+00:00Added an answer on May 18, 2026 at 11:36 am

    Rather than look for all permutations of uppercase/lowercase letters, try just lowercasing the string and searching for the lowercase version.

    linput = input.lower()
    if 'seat' in linput:
        if 'suc' in linput:
            return 'SEAT, SUCTION'
        else:
            return 'SEAT, DISCHARGE'
    

    I’m not sure in this case that a regex is warranted, unless you have more examples of strings you need to match. However, if you really want to do it that way, you can also make the regex call case insensitive by passing the re.I flag to any of the regex functions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got some c# code that is mapping processes to ip addresses, I'm basically
I'm writing a FUSE filesystem that does some mapping through sqlite, then passes the
I have an abstract superclass that has JPA annotations on it mapping some of
I am mapping some io memory to vmalloced area of in the driver. I
I want to temporary store some mapping data. The mapping is one to one.
I'm learning Fluent NHibernate (and by extension, NHibernate generally). I'm using auto-mapping with some
My question is: is there a way with a DataContext/Table mapping to implement some
After some struggle with smooks bean binding and CSV mapping, I managed to parse
Hi I'm looking for some help in mapping the following tables to a hibernate
I have a number of tables containing some basic (business related) mapping data. What's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.