def minimumFactor(sentence1, sentence2, n): if (n == 1): car1 = cardinality.softCardinality1(sentence1) car2 = cardinality.softCardinality1(sentence2) return min(car1, car2) if (n == 2): car1 = cardinality.softCardinality2(sentence1) car2 = cardinality.softCardinality2(sentence2) return min(car1, car2) elif (n == 3): car1 = cardinality.softCardinality3(sentence1) car2 = cardinality.softCardinality3(sentence2) return min(car1, car2)
def unionFactor(sentence1, sentence2, n): if (n == 1): ans += cardinality.softCardinality1(sentence1) ans += cardinality.softCardinality1(sentence2) ans += intersectionFactor(sentence1, sentence2) return ans elif (n == 2): ans += cardinality.softCardinality2(sentence1) ans += cardinality.softCardinality2(sentence2) ans += intersectionFactor(sentence1, sentence2) return ans elif (n == 3): ans += cardinality.softCardinality3(sentence1) ans += cardinality.softCardinality3(sentence2) ans += intersectionFactor(sentence1, sentence2) return ans
def fourthMeanFactor(sentence1, sentence2, n): if (n == 1): car1 = cardinality.softCardinality1(sentence1) car2 = cardinality.softCardinality2(sentence2) return (0.5 * (car1**4 + car2**4))**(1 / 4.0) if (n == 2): car1 = cardinality.softCardinality2(sentence1) car2 = cardinality.softCardinality2(sentence2) return (0.5 * (car1**4 + car2**4))**(1 / 4.0) elif (n == 3): car1 = cardinality.softCardinality3(sentence1) car2 = cardinality.softCardinality3(sentence2) return (0.5 * (car1**4 + car2**4))**(1 / 4.0)
def cubicMeanFactor(sentence1, sentence2, n): if (n == 1): car1 = cardinality.softCardinality1(sentence1) car2 = cardinality.softCardinality2(sentence2) return (0.5 * (car1**3 + car2**3))**(1 / 3.0) if (n == 2): car1 = cardinality.softCardinality2(sentence1) car2 = cardinality.softCardinality2(sentence2) return (0.5 * (car1**3 + car2**3))**(1 / 3.0) elif (n == 3): car1 = cardinality.softCardinality3(sentence1) car2 = cardinality.softCardinality3(sentence2) return (0.5 * (car1**3 + car2**3))**(1 / 3.0)
def quadriticMeanFactor(sentence1, sentence2, n): if (n == 1): car1 = cardinality.softCardinality1(sentence1) car2 = cardinality.softCardinality2(sentence2) return math.sqrt(0.5 * (car1**2 + car2**2)) if (n == 2): car1 = cardinality.softCardinality2(sentence1) car2 = cardinality.softCardinality2(sentence2) return math.sqrt(0.5 * (car1**2 + car2**2)) elif (n == 3): car1 = cardinality.softCardinality3(sentence1) car2 = cardinality.softCardinality3(sentence2) return math.sqrt(0.5 * (car1**2 + car2**2))
def geometricMeanFactor(sentence1, sentence2, n): if (n == 1): car1 = cardinality.softCardinality1(sentence1) car2 = cardinality.softCardinality2(sentence2) return math.sqrt(car1 * car2) if (n == 2): car1 = cardinality.softCardinality2(sentence1) car2 = cardinality.softCardinality2(sentence2) return math.sqrt(car1 * car2) elif (n == 3): car1 = cardinality.softCardinality3(sentence1) car2 = cardinality.softCardinality3(sentence2) return math.sqrt(car1 * car2)
def meanFactor(sentence1, sentence2, n): if (n == 1): car1 = cardinality.softCardinality1(sentence1) car2 = cardinality.softCardinality2(sentence2) return 0.5 * (car1 + car2) if (n == 2): car1 = cardinality.softCardinality2(sentence1) car2 = cardinality.softCardinality2(sentence2) return 0.5 * (car1 + car2) elif (n == 3): car1 = cardinality.softCardinality3(sentence1) car2 = cardinality.softCardinality3(sentence2) return 0.5 * (car1 + car2)