106 """ |
106 """ |
107 Return a static text analysation function that |
107 Return a static text analysation function that |
108 returns float values. |
108 returns float values. |
109 """ |
109 """ |
110 def text_analyse(text): |
110 def text_analyse(text): |
111 rv = f(text) |
111 try: |
|
112 rv = f(text) |
|
113 except Exception: |
|
114 return 0.0 |
112 if not rv: |
115 if not rv: |
113 return 0.0 |
116 return 0.0 |
114 return min(1.0, max(0.0, float(rv))) |
117 try: |
|
118 return min(1.0, max(0.0, float(rv))) |
|
119 except (ValueError, TypeError): |
|
120 return 0.0 |
115 text_analyse.__doc__ = f.__doc__ |
121 text_analyse.__doc__ = f.__doc__ |
116 return staticmethod(text_analyse) |
122 return staticmethod(text_analyse) |
117 |
123 |
118 |
124 |
119 def shebang_matches(text, regex): |
125 def shebang_matches(text, regex): |