DIMAP/NODE and ODE each contain six senses; organization and wording is slightly different; I have followed ODE as usual.
Notes from the spreadsheet:
I have not added new senses. However, ODE’s inventory is not fully coherent: it makes distinctions where they are not really needed, and fails to make them where they would be useful. The main case in point: the core sense, 1(1) is very general: “inside (something).” Since inside has 5 senses, the implication is that within can substitute for any of them. The ODE example, however, suggests a narrower range of meaning: “within the building.” I have taken the example, rather than the broadly worded definition, as the main limiting factor for this sense, but it is still fairly broad.
ODE’s inventory doesn’t have a clear slot for one of the most common uses of within: that is, to denote abstract entities that are conceived, figuratively and conveniently, to have boundaries that separate what happens inside them from what happens outside them – institutions, for example. Consider these two sentences:
Most people would agree these illustrate the same sense. It is sensible to assign sentence No. 1 to ODE sense 1, since we can conceive of the body as having a physical boundary that separates the outside from the inside. It is harder to assign sentence 2 to this same sense, however, because the nature of the boundary that defines the industry is quite different than the one that defines the person.
I have assigned all such sentences to sense 1(1), with the proviso that there is no distinction between things with literal and figurative boundaries. A more thoughtfully worded definition could probably encompass them both.
Other instances of within that may deserve idiomatic treatment:
Many stock phrases are within PPs and most of them parse according to defined senses, though some contain figurative language, e.g., within a hair’s breadth, within an inch of your life, etc. Others in this general category are within an ace/inch of doing sth, within a stone’s throw, within shouting distance, within reason, within sb’s reach/grasp/means.
Digits and cardinal number words are frequent in the 1R position after within. These will usually be either sense 5(2) or 6(3); the following noun should usually sort out which it is: a temporal or a spatial (i.e., distance) expression.