How much two sentences overlap, 0 to 1.
(one: Set<string>, other: Set<string>)
| 148 | |
| 149 | /** How much two sentences overlap, 0 to 1. */ |
| 150 | function overlap(one: Set<string>, other: Set<string>): number { |
| 151 | if (one.size === 0 || other.size === 0) { |
| 152 | return one.size === other.size ? 1 : 0; |
| 153 | } |
| 154 | let shared = 0; |
| 155 | for (const word of one) { |
| 156 | if (other.has(word)) { |
| 157 | shared += 1; |
| 158 | } |
| 159 | } |
| 160 | return shared / (one.size + other.size - shared); |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * The order of the statements, checked where the facts cannot check it. |