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

TTS: Pass molecule parsing error up to the user #40

Open
mattwelborn opened this issue Feb 27, 2020 · 5 comments
Open

TTS: Pass molecule parsing error up to the user #40

mattwelborn opened this issue Feb 27, 2020 · 5 comments
Labels
bug Something isn't working tts Related to the time-to-solution webapp
Milestone

Comments

@mattwelborn
Copy link
Contributor

mattwelborn commented Feb 27, 2020

For example, "h2o" is not a valid chemical formula. This gives "Please enter required fields with valid values." if no predictions have been made before, or the previous prediction if a prediction has been made before.

I think we should give the user a message that says "Your molecule string could not be parsed. Don't forget to capitalize element symbols!"

@mattwelborn mattwelborn added bug Something isn't working tts Related to the time-to-solution webapp labels Feb 27, 2020
@mattwelborn mattwelborn added this to the TTS Alpha milestone Feb 27, 2020
@dgasmith
Copy link
Contributor

We should try to get a valid input by using by:

  1. Upper case everything
  2. Title case based on string split

@mattwelborn
Copy link
Contributor Author

  1. is a little tricky. Does naf == "NaF" or "NAf"? I know "Af" is not a legit chemical symbol, but now we have to try all the possibilities and compare against the periodic table.

@mattwelborn
Copy link
Contributor Author

Similar issue with 1. "ni" == "NI" or "Ni"?

@dgasmith
Copy link
Contributor

Something wacky I think:

formula = None
try:
    formula = parse_formula(string)
except:
    pass

if formula is None:
    try:
        formula = parse_formula(string.upper())
    except:
        pass

Not sure of a better control flow.

funcs = [lambda x: x, lambda x: x.upper(), lambda x: "".join(x.title() for x in num_split)]

for func in funcs:
    try:
        formula = parse_formula(string)
        break
     except:
        pass

@dgasmith
Copy link
Contributor

dgasmith commented Feb 27, 2020

I do want to come up with something clever in the future, but something to get over silly h20 errors. Everyone only cares about CHNOPS anyways right :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tts Related to the time-to-solution webapp
Projects
None yet
Development

No branches or pull requests

2 participants