Skip to content Skip to sidebar Skip to footer

Python Re Match, Findall Or Search And Then Nlp (what To Do With It?)

I am starting to write code that would capture part of sentence 'types' and if they match a criteria, start a specific python script that deals with the 'type.' I am 'finding':) th

Solution 1:

The reason why m.match() fails is that it expects the match to start at the beginning of the string.

findall() makes sense if you expect more than one (non-overlapping) match in your string. Otherwise, use the search() method (which will return the first match it finds).

This is all well covered in the docs.

Solution 2:

From my knowledge of search interfaces, it seems like you'd need an awful lot of regular expressions to capture the great variety of ways in which people express themselves. For a feeling for just how many, see this writeup on "the vocabulary problem".

So, if you're just doing date/time stuff, and you're tying very specific actions to them that it would suck to get wrong, then RE's seem like a good way to go. On the other hand, if you're just trying to detect a "date" expression vs. e.g. an "email" expression or a "note" expression, then perhaps it might be worth a try to POS-tag the sentences using NLTK and match patterns on the part of speech level.

Post a Comment for "Python Re Match, Findall Or Search And Then Nlp (what To Do With It?)"