I am trying to search for a word or multiple words out of the given text. How could i assign different words to each principles so if the word searched for is amongst the assigned text that particular paragraph will be triggered.
Any help will be greatly appriciated.
import re patterns = [ 'work' ] text = """\ 1. Principle of Segmentation: a) Divide an object into independent parts - Replace a large truck by a truck and trailer. - Use a work breakdown structure for a large project. - Sequential novel turn into movies b) Make an object easy to disassemble. - Bicycle disassembling (saddle, wheels) - Furniture (sofas, table) - Crib c) Increase the degree of fragmentation or segmentation. - Replace solid shades with Venetian blinds - Computer covers with holes for ventilation - Multi blade cartridge Razor 4. Principle of Asymmetry: a. If an object is symmetrical, change its shape to irregular. -Asymmetric paddles mix -cement -truck -blender -cake mixer 7. Principle of Nesting: a. Place an object inside another one, which, in turn, is placed inside a third object, etc. -Russian dolls -Measuring cup and spoon -Folder inside Folders (computers) b. Arrange an object to pass through a hole or a cavity of another object. -Zoom lens (on a camera) -Extending radio antenna """ for pattern in patterns: print 'Looking for "%s" in "%s" ->' % (pattern, text), if re.search(pattern, text): print 'found a match!' else: print 'no match'