From 281779b16fda676865ba61c5882a9fd8806ca7e5 Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Sat, 14 Nov 2026 16:59:40 +0000 Subject: [PATCH 1/3] Test that the IP Intelligence examples show each value's weighting --- .../examples/shared/PropertyHelperTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/examples/ip-intelligence/shared/src/test/java/fiftyone/ipintelligence/examples/shared/PropertyHelperTest.java b/examples/ip-intelligence/shared/src/test/java/fiftyone/ipintelligence/examples/shared/PropertyHelperTest.java index 705ceff72..4a7bb9e65 100644 --- a/examples/ip-intelligence/shared/src/test/java/fiftyone/ipintelligence/examples/shared/PropertyHelperTest.java +++ b/examples/ip-intelligence/shared/src/test/java/fiftyone/ipintelligence/examples/shared/PropertyHelperTest.java @@ -22,11 +22,15 @@ package fiftyone.ipintelligence.examples.shared; +import fiftyone.pipeline.core.data.IWeightedValue; +import fiftyone.pipeline.core.data.WeightedValue; import fiftyone.pipeline.engines.data.AspectPropertyValue; import fiftyone.pipeline.engines.data.AspectPropertyValueDefault; import org.junit.Test; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.List; import static org.junit.Assert.*; @@ -60,4 +64,25 @@ public void testAsNoValue() { AspectPropertyValue> test = new AspectPropertyValueDefault<>(); assertTrue(PropertyHelper.asString(test).startsWith("Unknown")); } + + /** + * Each weighted value is shown with its weighting, as the IP + * Intelligence examples must show both. A raw weighting of 65535 is a + * weighting of 1. + */ + @Test + public void testWeightedValuesShowTheirWeighting() { + AspectPropertyValue>> one = + new AspectPropertyValueDefault<>(Collections.singletonList( + new WeightedValue<>(65535, "Japan"))); + assertEquals("Japan (weighting 1.00)", PropertyHelper.asString(one)); + + AspectPropertyValue>> two = + new AspectPropertyValueDefault<>(Arrays.asList( + new WeightedValue<>(49151, "Tokyo"), + new WeightedValue<>(16384, "Osaka"))); + assertEquals( + "Tokyo (weighting 0.75), Osaka (weighting 0.25)", + PropertyHelper.asString(two)); + } } \ No newline at end of file From b9eabc377fa46879cf06c4d0587f3635b4b38e6a Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Sat, 14 Nov 2026 17:00:09 +0000 Subject: [PATCH 2/3] Show each IP Intelligence value's weighting in the examples --- .../examples/shared/PropertyHelper.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/examples/ip-intelligence/shared/src/main/java/fiftyone/ipintelligence/examples/shared/PropertyHelper.java b/examples/ip-intelligence/shared/src/main/java/fiftyone/ipintelligence/examples/shared/PropertyHelper.java index 68b45b83b..71a7e5aad 100644 --- a/examples/ip-intelligence/shared/src/main/java/fiftyone/ipintelligence/examples/shared/PropertyHelper.java +++ b/examples/ip-intelligence/shared/src/main/java/fiftyone/ipintelligence/examples/shared/PropertyHelper.java @@ -32,6 +32,7 @@ import java.util.Arrays; import java.util.List; +import java.util.Locale; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Supplier; import java.util.stream.Collectors; @@ -60,6 +61,8 @@ public class PropertyHelper { * List<IWeightedValue<T>> even when the declared type is T). * For single-element lists, returns just the value. * For multi-element lists, returns values joined with ", ". + * A weighted value is followed by its weighting, as in + * "Japan (weighting 1.00)". * @param value the raw value from AspectPropertyValue.getValue() * @return the unwrapped string representation */ @@ -73,8 +76,16 @@ private static String unwrapValue(Object value) { return list.stream() .map(item -> { if (item instanceof IWeightedValue) { - Object inner = ((IWeightedValue) item).getValue(); - return inner != null ? inner.toString() : "Unknown"; + // An IP Intelligence value comes with the + // weighting the data gives it, which is 1 for + // a property with one answer. + IWeightedValue weighted = (IWeightedValue) item; + Object inner = weighted.getValue(); + return String.format( + Locale.ROOT, + "%s (weighting %.2f)", + inner != null ? inner.toString() : "Unknown", + weighted.getWeighting()); } return item != null ? item.toString() : "Unknown"; }) From 0eb562fc58e9f177f49e9488cc3edf189f2c6cbc Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Sat, 14 Nov 2026 17:01:46 +0000 Subject: [PATCH 3/3] Say in AGENTS.md that each IP Intelligence value is shown with its weighting --- AGENTS.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index df51ec15e..293b4d5fa 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -157,8 +157,9 @@ expected with the Lite file. The exit code is 0. The IP Intelligence example looks up `116.154.188.222`, `45.236.48.61` and an IPv6 address. For each it prints `Input values:` with `query.client-ip`, then `Results:` with a line for each property, from `RegisteredName` to -`TimeZoneOffset`. The Lite file has RegisteredCountry, RegisteredName and -RegisteredOwner, so a line for a property it does not have reads +`TimeZoneOffset`. Each value is followed by its weighting, as in +`Japan (weighting 1.00)`. The Lite file has RegisteredCountry, RegisteredName +and RegisteredOwner, so a line for a property it does not have reads `Unknown. The property '' is not available in this data file.` followed by a link, and the first such line also logs a warning that some properties need a paid subscription. It then logs the data file in the same way, and