The error is an indication of what the problem is. 'NumExprFilter' object has no attribute 'top' means that a filter object doesn't have a 'top' method. The problem is in the two lines
longs = n_longs.top(10)
shorts = n_shorts.bottom(5)
Both 'n_longs' and 'n_shorts' are filters. Basically they are collections of securities which pass all the constraints. They don't have any intrinsic order so the concept of 'top' or 'bottom' doesn't mean anything. One can only apply 'top' and 'bottom' to factors. Factors have values and therefore can be ordered by that value and return the highest (ie top) and lowest (ie bottom) securities. The result is a filter or collection of securities and NOT a factor.
So, the first step is to determine what factor one wishes to rank the results by. Does one want the highest and lowest ROE? ROA? PE_RATIO? Simply use that factor with a mask. Something like this (I randomly chose the latest close price)
ranking_factor = USEquityPricing.close.latest
longs = ranking_factor.top(10, mask=n_longs)
shorts = ranking_factor.bottom(5, mask=n_shorts)
Note that the ranking_factor could also be a calculated value based upon several other factors.
ranking_factor = factor1 + factor2 + (2*factor3)
Good luck.