compromise
compromise copied to clipboard
Feature request: parse doublet, triplet, etc. as numbers with compromise-numbers
This could be very useful in a lot of contexts, especially in science texts.
Hey @schneiderfelipe i may need an example to understand the feature request. Doublets mean a lot of things1 Cheers
Hi @spencermountain I had spectroscopy in mind, but there might be other fields using this nomenclature as well. An example:
In spectroscopy and quantum chemistry, the multiplicity of an energy level is defined as 2S+1, where S is the total spin angular momentum.[1][2][3] States with multiplicity 1, 2, 3, 4, 5 are respectively called singlets, doublets, triplets, quartets and quintets.[2] The multiplicity is also equal to the number of unpaired electrons plus one.[4]
Emphasis mine. From here.
hey @schneiderfelipe you could support this by adding a regex to a match command, as specified here
doc.match('/[1-9]S\+[1-9]/').tag('#Doublet') // finds '2S+1'
then you can do something like:
let found = doc.match('the spin of Boron is [#Doublet]', 0)
although this example may be obscure, I'd love to support basic chemistry nomenclature, through a cool regex or something. If you wanted to work on a chemistry-plugin, I'd be happy to collaborate cheers
hey @schneiderfelipe you could support this by adding a regex to a match command, as specified here
doc.match('/[1-9]S\+[1-9]/').tag('#Doublet') // finds '2S+1'
then you can do something like:
let found = doc.match('the spin of Boron is [#Doublet]', 0)
@spencermountain Nice! A question: does this parse mathematical expressions? (I.e., does "3" matches "2S + 1"? Is there a way to match the "S" of "3" if I know it should be "2S + 1"?)
although this example may be obscure, I'd love to support basic chemistry nomenclature, through a cool regex or something. If you wanted to work on a chemistry-plugin, I'd be happy to collaborate
That's awesome, I'm interested. I'll start something and let you know.
hey, yep you can play with the regex to have it perform as you'd like see here for example.
parsing mathematical expressions is something I've shied-away from, but I know some libraries have had some success. Things get tricky pretty-fast.
if you have more examples for parsing multiplicity, I'm happy to help. I was thinking chemical formulae like CH4S2
would be fun to parse because there's a limited number of elements, and combinations.
cheers