<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def extract(self, filename, tu):
 """ extract extracts comments from a translation unit for a given file by iterating over all the tokens in the TU, locating the COMMENT tokens and finding out to which cursors the comments semantically belong. """

        it = tu.get_tokens(extent=tu.get_extent(filename, (0, int(os.stat(filename).st_size))))

        while True:
            try:
                self.extract_loop(it)
            except StopIteration:
                break