moving window function for sentences