birdingbuddy-mcp 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. birdingbuddy_mcp-0.2.2/LICENSE +21 -0
  2. birdingbuddy_mcp-0.2.2/MANIFEST.in +1 -0
  3. birdingbuddy_mcp-0.2.2/PKG-INFO +181 -0
  4. birdingbuddy_mcp-0.2.2/README.md +168 -0
  5. birdingbuddy_mcp-0.2.2/THIRD_PARTY_NOTICES.md +43 -0
  6. birdingbuddy_mcp-0.2.2/birdingbuddy/__init__.py +2 -0
  7. birdingbuddy_mcp-0.2.2/birdingbuddy/_species_compatibility.py +6 -0
  8. birdingbuddy_mcp-0.2.2/birdingbuddy/common_name_normalization.py +64 -0
  9. birdingbuddy_mcp-0.2.2/birdingbuddy/group_resolution.py +198 -0
  10. birdingbuddy_mcp-0.2.2/birdingbuddy/species_aliases.py +251 -0
  11. birdingbuddy_mcp-0.2.2/birdingbuddy/species_canonicalization.py +862 -0
  12. birdingbuddy_mcp-0.2.2/birdingbuddy/species_identity.py +713 -0
  13. birdingbuddy_mcp-0.2.2/birdingbuddy/taxonomy.py +276 -0
  14. birdingbuddy_mcp-0.2.2/birdingbuddy/telemetry.py +306 -0
  15. birdingbuddy_mcp-0.2.2/birdingbuddy/telemetry_attributes.py +351 -0
  16. birdingbuddy_mcp-0.2.2/birdingbuddy_mcp.egg-info/PKG-INFO +181 -0
  17. birdingbuddy_mcp-0.2.2/birdingbuddy_mcp.egg-info/SOURCES.txt +31 -0
  18. birdingbuddy_mcp-0.2.2/birdingbuddy_mcp.egg-info/dependency_links.txt +1 -0
  19. birdingbuddy_mcp-0.2.2/birdingbuddy_mcp.egg-info/entry_points.txt +4 -0
  20. birdingbuddy_mcp-0.2.2/birdingbuddy_mcp.egg-info/requires.txt +2 -0
  21. birdingbuddy_mcp-0.2.2/birdingbuddy_mcp.egg-info/top_level.txt +2 -0
  22. birdingbuddy_mcp-0.2.2/birdingbuddy_public/__init__.py +1 -0
  23. birdingbuddy_mcp-0.2.2/birdingbuddy_public/fake_gateway.py +207 -0
  24. birdingbuddy_mcp-0.2.2/birdingbuddy_public/live.py +483 -0
  25. birdingbuddy_mcp-0.2.2/birdingbuddy_public/stdio.py +89 -0
  26. birdingbuddy_mcp-0.2.2/birdingbuddy_public/taxonomy/README.md +9 -0
  27. birdingbuddy_mcp-0.2.2/birdingbuddy_public/taxonomy/chinese_species_mapping.json +10 -0
  28. birdingbuddy_mcp-0.2.2/birdingbuddy_public/taxonomy/chinese_taxonomy_coverage.json +3 -0
  29. birdingbuddy_mcp-0.2.2/birdingbuddy_public/taxonomy/chinese_wikidata_coverage_delta.json +3 -0
  30. birdingbuddy_mcp-0.2.2/birdingbuddy_public/taxonomy/chinese_wikidata_supplement.json +5 -0
  31. birdingbuddy_mcp-0.2.2/birdingbuddy_public/taxonomy/species_identity_expansion.json +14 -0
  32. birdingbuddy_mcp-0.2.2/pyproject.toml +45 -0
  33. birdingbuddy_mcp-0.2.2/setup.cfg +4 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 BirdingBuddy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ prune tests
@@ -0,0 +1,181 @@
1
+ Metadata-Version: 2.4
2
+ Name: birdingbuddy-mcp
3
+ Version: 0.2.2
4
+ Summary: BirdingBuddy public MCP stdio bridge and offline demo
5
+ License-Expression: MIT
6
+ Requires-Python: >=3.13
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ License-File: THIRD_PARTY_NOTICES.md
10
+ Requires-Dist: httpx2<3,>=2.13.1
11
+ Requires-Dist: mcp<3,>=2.2
12
+ Dynamic: license-file
13
+
14
+ # BirdingBuddy MCP
15
+
16
+ <!-- mcp-name: io.github.korsakowii/birdingbuddy-mcp-stdio -->
17
+
18
+ Plan birding outings using recent eBird evidence. Recent reports describe
19
+ where birds have been reported. They cannot predict a sighting.
20
+
21
+ This repository contains the open-source, MIT-licensed BirdingBuddy MCP Client.
22
+ It includes a stdio bridge for MCP hosts and a synthetic offline demo.
23
+ The closed-source [BirdingBuddy](https://birdingbuddy.app/) Hosted Server
24
+ provides the live tools and report generation as a separate service.
25
+
26
+ ## Quick start
27
+
28
+ **Remote MCP (recommended):** add this Streamable HTTP endpoint to a
29
+ compatible MCP host. No sign-in is required for the four public tools.
30
+
31
+ ```text
32
+ https://mcp.birdingbuddy.app/mcp
33
+ ```
34
+
35
+ **Stdio-only hosts:** use Python 3.13 or 3.14 and a current, patched uv.
36
+ When the matching Client version is available on PyPI, set the host command
37
+ to `uvx` with the arguments `--from`, `birdingbuddy-mcp@0.2.2`, and
38
+ `birdingbuddy-stdio` in that order. The package also exposes the
39
+ `birdingbuddy-mcp` command for tools that use the distribution name as
40
+ the executable. Tool inputs sent through the live bridge are handled
41
+ according to the [BirdingBuddy privacy policy](https://birdingbuddy.app/web/privacy).
42
+
43
+ To install from a source checkout:
44
+
45
+ ```sh
46
+ git clone https://github.com/korsakowii/birdingbuddy-mcp.git
47
+ cd birdingbuddy-mcp
48
+ uv sync --locked --no-editable
49
+ ```
50
+
51
+ Use the absolute path to the installed command in your host configuration.
52
+ For example, on macOS or Linux:
53
+
54
+ ```json
55
+ {
56
+ "mcpServers": {
57
+ "birdingbuddy": {
58
+ "command": "/absolute/path/to/birdingbuddy-mcp/.venv/bin/birdingbuddy-stdio"
59
+ }
60
+ }
61
+ }
62
+ ```
63
+
64
+ ### Client and server compatibility
65
+
66
+ Client v0.2.2 adds standard Python distribution packaging for the same
67
+ stdio bridge. Remote MCP continues to use the independent Hosted Server.
68
+
69
+ The Client and Hosted Server have independent versions. Client v0.2.1
70
+ documents the strict recent-target filter and optional time-zone credit in
71
+ Hosted Server v0.3.1 and adds relay test coverage. Existing Client v0.2.0
72
+ installations can use these hosted features without upgrading.
73
+
74
+ Both connection methods use the same hosted service and require internet
75
+ access. The stdio bridge relays the public tool schemas, results and card
76
+ resources; card rendering depends on the host. The bridge uses the legacy
77
+ handshake by default to give the hosted service more time to start. Set
78
+ `BIRDINGBUDDY_MCP_PROTOCOL=auto` in the local stdio process environment to try
79
+ modern MCP. The SDK gives modern discovery 10 seconds. The first auto
80
+ connection to an idle hosted service can time out because the service may
81
+ take about a minute to start. If that happens, wait about a minute and
82
+ reconnect manually, or keep the legacy default. Auto mode uses the legacy
83
+ handshake only after the upstream explicitly reports that discovery is
84
+ unsupported or advertises a compatible legacy version.
85
+
86
+ The bridge can relay three planning templates: plan a birding trip, find a
87
+ target species, and prepare a hotspot visit. Prompt discovery and rendering
88
+ require the hosted service to advertise prompts and allow anonymous prompt
89
+ access. Native prompt menus depend on the host.
90
+
91
+ With auto negotiation and a modern host that declares standard MCP Form
92
+ support, the bridge can relay a destination selection when the hosted
93
+ service offers one. A confirmed selection resumes the original request once.
94
+ With a legacy connection or a host that does not support forms, clarify
95
+ ambiguous places in conversation. Platform-specific forms and Tasks are
96
+ outside this bridge's supported feature set.
97
+
98
+ ## Public tools
99
+
100
+ | Tool | Purpose |
101
+ | --- | --- |
102
+ | `search_places` | Find supported birding destinations. |
103
+ | `resolve_targets` | Resolve bird names and target groups. |
104
+ | `check_species_evidence` | Check recent evidence for target birds. |
105
+ | `find_birding_opportunities` | Rank hotspots using recent evidence and planning preferences. |
106
+
107
+ Try: "Where should I go birding in East Bay today? Give me one
108
+ recommendation using reports from the last seven days." Supply an explicit trip
109
+ date as `YYYY-MM-DD`, or omit it for today's date at the destination. Ask for a
110
+ city or public landmark if no location was shared. For species evidence, try
111
+ American Coot in East Bay.
112
+
113
+ `find_birding_opportunities` accepts a request-scoped `life_list` and
114
+ `life_list_filter`: `all` (default), `new_only`, or `seen_only`.
115
+ The last two require a nonempty list. The bridge forwards the list for that
116
+ call without saving it. Consult the hosted tool schemas for supported inputs.
117
+
118
+ ### Require a recent report of a target bird
119
+
120
+ On the hosted service, set `require_recent_target` to `true` with
121
+ `goal: "closest"` and one entry in `targets` that resolves to a single
122
+ unambiguous species. The default is `false`. The service keeps only public
123
+ hotspots with a report of that species at the same hotspot in the requested
124
+ recent window, then ranks the remaining spots by Closest. Strict mode does
125
+ not support New/Seen or a maximum one-way driving time. If complete coverage
126
+ yields no matches, the result is empty. If coverage is incomplete or
127
+ unavailable, the service reports that it cannot verify the result.
128
+
129
+ ### Time-zone source credit
130
+
131
+ When the hosted report uses a coordinate lookup to determine the
132
+ destination's time zone, its result includes a report-level
133
+ `timezone_boundary_notice` crediting Timezone Boundary Builder and
134
+ OpenStreetMap contributors under ODbL 1.0. The credit can appear with an
135
+ explicit trip date or an empty result. The stdio bridge relays the optional
136
+ notice and card resources. Whether a host displays them depends on the host.
137
+
138
+ ## Offline demo
139
+
140
+ To try the synthetic demo, use the same stdio configuration with
141
+ `birdingbuddy-stdio-demo` as the executable instead. It starts a local
142
+ loopback gateway and uses invented taxonomy and evidence for Lantern Marsh.
143
+ No account or API key is needed. Call `find_birding_opportunities` with:
144
+
145
+ ```json
146
+ {"destination":"Lantern Marsh","requested_date":"2026-10-10","life_list":["Amber Lanternbird"],"life_list_filter":"new_only"}
147
+ ```
148
+
149
+ The demo returns Moss Lanternbird as `New for you`. With `seen_only`, it
150
+ returns Amber Lanternbird instead. Without a Life List, both birds appear.
151
+ The demo uses a fixed seven-day synthetic evidence window and defaults to the
152
+ fixture date `2026-10-10` when the trip date is omitted. It validates explicit
153
+ dates and returns at most one balanced recommendation. No recommendation is
154
+ returned if the filter leaves no evidence. The demo rejects `targets` and
155
+ `require_recent_target` and does not use geographic time-zone lookup.
156
+
157
+ The package also includes the species-name and identity validation library.
158
+ See the [synthetic taxonomy guide](birdingbuddy_public/taxonomy/README.md)
159
+ for configuring `BIRDINGBUDDY_TAXONOMY_DIR` before importing it.
160
+
161
+ ## Tests and limitations
162
+
163
+ After the initial dependency installation from PyPI, the demo and tests
164
+ can run without external network access:
165
+
166
+ ```sh
167
+ uv run --offline --locked --no-editable python -m pytest -q
168
+ ```
169
+
170
+ For live connections, shared rate and concurrency limits apply. For HTTP
171
+ 429, follow any supplied wait time before retrying manually. HTTP 403 can
172
+ come from the service or an intermediary; check host error details, stderr
173
+ and network or proxy settings if startup fails.
174
+
175
+ ## License, citation and support
176
+
177
+ The source is [MIT licensed](LICENSE). Live eBird data is not covered by
178
+ that license; see [third-party notices](THIRD_PARTY_NOTICES.md).
179
+ Use [CITATION.cff](CITATION.cff) to cite the software.
180
+ See [Contributing](CONTRIBUTING.md) and [Security](SECURITY.md) for feedback
181
+ and vulnerability reporting.
@@ -0,0 +1,168 @@
1
+ # BirdingBuddy MCP
2
+
3
+ <!-- mcp-name: io.github.korsakowii/birdingbuddy-mcp-stdio -->
4
+
5
+ Plan birding outings using recent eBird evidence. Recent reports describe
6
+ where birds have been reported. They cannot predict a sighting.
7
+
8
+ This repository contains the open-source, MIT-licensed BirdingBuddy MCP Client.
9
+ It includes a stdio bridge for MCP hosts and a synthetic offline demo.
10
+ The closed-source [BirdingBuddy](https://birdingbuddy.app/) Hosted Server
11
+ provides the live tools and report generation as a separate service.
12
+
13
+ ## Quick start
14
+
15
+ **Remote MCP (recommended):** add this Streamable HTTP endpoint to a
16
+ compatible MCP host. No sign-in is required for the four public tools.
17
+
18
+ ```text
19
+ https://mcp.birdingbuddy.app/mcp
20
+ ```
21
+
22
+ **Stdio-only hosts:** use Python 3.13 or 3.14 and a current, patched uv.
23
+ When the matching Client version is available on PyPI, set the host command
24
+ to `uvx` with the arguments `--from`, `birdingbuddy-mcp@0.2.2`, and
25
+ `birdingbuddy-stdio` in that order. The package also exposes the
26
+ `birdingbuddy-mcp` command for tools that use the distribution name as
27
+ the executable. Tool inputs sent through the live bridge are handled
28
+ according to the [BirdingBuddy privacy policy](https://birdingbuddy.app/web/privacy).
29
+
30
+ To install from a source checkout:
31
+
32
+ ```sh
33
+ git clone https://github.com/korsakowii/birdingbuddy-mcp.git
34
+ cd birdingbuddy-mcp
35
+ uv sync --locked --no-editable
36
+ ```
37
+
38
+ Use the absolute path to the installed command in your host configuration.
39
+ For example, on macOS or Linux:
40
+
41
+ ```json
42
+ {
43
+ "mcpServers": {
44
+ "birdingbuddy": {
45
+ "command": "/absolute/path/to/birdingbuddy-mcp/.venv/bin/birdingbuddy-stdio"
46
+ }
47
+ }
48
+ }
49
+ ```
50
+
51
+ ### Client and server compatibility
52
+
53
+ Client v0.2.2 adds standard Python distribution packaging for the same
54
+ stdio bridge. Remote MCP continues to use the independent Hosted Server.
55
+
56
+ The Client and Hosted Server have independent versions. Client v0.2.1
57
+ documents the strict recent-target filter and optional time-zone credit in
58
+ Hosted Server v0.3.1 and adds relay test coverage. Existing Client v0.2.0
59
+ installations can use these hosted features without upgrading.
60
+
61
+ Both connection methods use the same hosted service and require internet
62
+ access. The stdio bridge relays the public tool schemas, results and card
63
+ resources; card rendering depends on the host. The bridge uses the legacy
64
+ handshake by default to give the hosted service more time to start. Set
65
+ `BIRDINGBUDDY_MCP_PROTOCOL=auto` in the local stdio process environment to try
66
+ modern MCP. The SDK gives modern discovery 10 seconds. The first auto
67
+ connection to an idle hosted service can time out because the service may
68
+ take about a minute to start. If that happens, wait about a minute and
69
+ reconnect manually, or keep the legacy default. Auto mode uses the legacy
70
+ handshake only after the upstream explicitly reports that discovery is
71
+ unsupported or advertises a compatible legacy version.
72
+
73
+ The bridge can relay three planning templates: plan a birding trip, find a
74
+ target species, and prepare a hotspot visit. Prompt discovery and rendering
75
+ require the hosted service to advertise prompts and allow anonymous prompt
76
+ access. Native prompt menus depend on the host.
77
+
78
+ With auto negotiation and a modern host that declares standard MCP Form
79
+ support, the bridge can relay a destination selection when the hosted
80
+ service offers one. A confirmed selection resumes the original request once.
81
+ With a legacy connection or a host that does not support forms, clarify
82
+ ambiguous places in conversation. Platform-specific forms and Tasks are
83
+ outside this bridge's supported feature set.
84
+
85
+ ## Public tools
86
+
87
+ | Tool | Purpose |
88
+ | --- | --- |
89
+ | `search_places` | Find supported birding destinations. |
90
+ | `resolve_targets` | Resolve bird names and target groups. |
91
+ | `check_species_evidence` | Check recent evidence for target birds. |
92
+ | `find_birding_opportunities` | Rank hotspots using recent evidence and planning preferences. |
93
+
94
+ Try: "Where should I go birding in East Bay today? Give me one
95
+ recommendation using reports from the last seven days." Supply an explicit trip
96
+ date as `YYYY-MM-DD`, or omit it for today's date at the destination. Ask for a
97
+ city or public landmark if no location was shared. For species evidence, try
98
+ American Coot in East Bay.
99
+
100
+ `find_birding_opportunities` accepts a request-scoped `life_list` and
101
+ `life_list_filter`: `all` (default), `new_only`, or `seen_only`.
102
+ The last two require a nonempty list. The bridge forwards the list for that
103
+ call without saving it. Consult the hosted tool schemas for supported inputs.
104
+
105
+ ### Require a recent report of a target bird
106
+
107
+ On the hosted service, set `require_recent_target` to `true` with
108
+ `goal: "closest"` and one entry in `targets` that resolves to a single
109
+ unambiguous species. The default is `false`. The service keeps only public
110
+ hotspots with a report of that species at the same hotspot in the requested
111
+ recent window, then ranks the remaining spots by Closest. Strict mode does
112
+ not support New/Seen or a maximum one-way driving time. If complete coverage
113
+ yields no matches, the result is empty. If coverage is incomplete or
114
+ unavailable, the service reports that it cannot verify the result.
115
+
116
+ ### Time-zone source credit
117
+
118
+ When the hosted report uses a coordinate lookup to determine the
119
+ destination's time zone, its result includes a report-level
120
+ `timezone_boundary_notice` crediting Timezone Boundary Builder and
121
+ OpenStreetMap contributors under ODbL 1.0. The credit can appear with an
122
+ explicit trip date or an empty result. The stdio bridge relays the optional
123
+ notice and card resources. Whether a host displays them depends on the host.
124
+
125
+ ## Offline demo
126
+
127
+ To try the synthetic demo, use the same stdio configuration with
128
+ `birdingbuddy-stdio-demo` as the executable instead. It starts a local
129
+ loopback gateway and uses invented taxonomy and evidence for Lantern Marsh.
130
+ No account or API key is needed. Call `find_birding_opportunities` with:
131
+
132
+ ```json
133
+ {"destination":"Lantern Marsh","requested_date":"2026-10-10","life_list":["Amber Lanternbird"],"life_list_filter":"new_only"}
134
+ ```
135
+
136
+ The demo returns Moss Lanternbird as `New for you`. With `seen_only`, it
137
+ returns Amber Lanternbird instead. Without a Life List, both birds appear.
138
+ The demo uses a fixed seven-day synthetic evidence window and defaults to the
139
+ fixture date `2026-10-10` when the trip date is omitted. It validates explicit
140
+ dates and returns at most one balanced recommendation. No recommendation is
141
+ returned if the filter leaves no evidence. The demo rejects `targets` and
142
+ `require_recent_target` and does not use geographic time-zone lookup.
143
+
144
+ The package also includes the species-name and identity validation library.
145
+ See the [synthetic taxonomy guide](birdingbuddy_public/taxonomy/README.md)
146
+ for configuring `BIRDINGBUDDY_TAXONOMY_DIR` before importing it.
147
+
148
+ ## Tests and limitations
149
+
150
+ After the initial dependency installation from PyPI, the demo and tests
151
+ can run without external network access:
152
+
153
+ ```sh
154
+ uv run --offline --locked --no-editable python -m pytest -q
155
+ ```
156
+
157
+ For live connections, shared rate and concurrency limits apply. For HTTP
158
+ 429, follow any supplied wait time before retrying manually. HTTP 403 can
159
+ come from the service or an intermediary; check host error details, stderr
160
+ and network or proxy settings if startup fails.
161
+
162
+ ## License, citation and support
163
+
164
+ The source is [MIT licensed](LICENSE). Live eBird data is not covered by
165
+ that license; see [third-party notices](THIRD_PARTY_NOTICES.md).
166
+ Use [CITATION.cff](CITATION.cff) to cite the software.
167
+ See [Contributing](CONTRIBUTING.md) and [Security](SECURITY.md) for feedback
168
+ and vulnerability reporting.
@@ -0,0 +1,43 @@
1
+ # Third-party notices
2
+
3
+ ## Software and data
4
+
5
+ BirdingBuddy source in this slice is distributed under the MIT license. The
6
+ demo place, recommendation, and bundled taxonomy JSON fixtures are fictional.
7
+ The fixture README explains the source label used to exercise the supplemental
8
+ alias reader.
9
+
10
+ The shared source also contains hand-written language and taxonomic rules.
11
+ These include broad bird terms, the spelling and punctuation variant for
12
+ Long-tailed Jaeger, and four supported group queries built from standard bird
13
+ family names. The family names can be cross-checked in the
14
+ [IOC World Bird List family index](https://www.worldbirdnames.org/new/classification/family-index-2/).
15
+
16
+ The export ships empty production compatibility tables. Historical Life List
17
+ aliases, provider species-code equivalences, real production regression rows,
18
+ and eBird and Wikidata taxonomy files stay outside the export. The MIT license
19
+ covers the software. Live observations returned by the hosted service are
20
+ external data and are outside the software license. Data obtained from the eBird API remains
21
+ subject to the Cornell Lab's [API terms](https://www.birds.cornell.edu/home/ebird-api-terms-of-use/)
22
+ and [Data Access Terms](https://www.birds.cornell.edu/home/ebird-data-access-terms-of-use/).
23
+
24
+ ## Dependencies
25
+
26
+ The wheel does not bundle third-party libraries. The lock records the exact
27
+ Python dependencies and PyPI artifact hashes. Each dependency retains its
28
+ upstream license and any notices shipped with its distribution. For example,
29
+ typing-extensions is PSF-2.0 and cryptography offers Apache-2.0 or
30
+ BSD-3-Clause. These are installed as
31
+ separate packages.
32
+
33
+ | Direct dependency | Use | Upstream license |
34
+ | --- | --- | --- |
35
+ | [MCP Python SDK](https://pypi.org/project/mcp/) | MCP stdio and Streamable HTTP transports | MIT |
36
+ | [HTTPX2](https://pypi.org/project/httpx2/) | HTTP diagnostics for the MCP bridge | BSD-3-Clause |
37
+ | [setuptools](https://pypi.org/project/setuptools/) | Wheel build | MIT |
38
+ | [pytest](https://pypi.org/project/pytest/) | Test runner | MIT |
39
+
40
+ The optional GitHub workflow uses [checkout](https://github.com/actions/checkout)
41
+ and [setup-python](https://github.com/actions/setup-python) under MIT, and
42
+ [uv](https://github.com/astral-sh/uv) under MIT or Apache-2.0. Source and wheel
43
+ licenses do not grant rights to product marks or externally obtained datasets.
@@ -0,0 +1,2 @@
1
+ """BirdingBuddy v3.1 opportunity report package."""
2
+
@@ -0,0 +1,6 @@
1
+ """The exported package uses the bundled synthetic taxonomy for compatibility."""
2
+
3
+ LIFE_LIST_ALIASES = {}
4
+ EQUIVALENT_CODE_GROUPS = ()
5
+ HISTORICAL_ENGLISH_ALIASES = {}
6
+ PRODUCTION_REGRESSION_SAMPLES = ()
@@ -0,0 +1,64 @@
1
+ """Conservative common-name normalization for species matching."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import functools
6
+ import re
7
+ import unicodedata
8
+ from typing import FrozenSet
9
+
10
+ _PARENTHETICAL_RE = re.compile(r"\([^)]*\)")
11
+ _APOSTROPHES = "'\u2018\u2019\u02bc"
12
+ _SEPARATORS = "-\u2010\u2011\u2012\u2013\u2014/.,;:_"
13
+
14
+ _APOSTROPHES_TRANSLATE = {ord(ch): "" for ch in _APOSTROPHES}
15
+ _SEPARATORS_TRANSLATE = {ord(ch): " " for ch in _SEPARATORS}
16
+
17
+ # Regional colour-spelling synonyms. eBird never distinguishes two species by
18
+ # gray/grey spelling alone, so folding the standalone colour word is safe: it
19
+ # is applied symmetrically to both life-list entries and reported species, so a
20
+ # "Grey" entry matches a "Gray" report (and vice versa) without collapsing any
21
+ # distinct species.
22
+ _SPELLING_SYNONYMS = {"grey": "gray", "gray": "grey"}
23
+
24
+
25
+ @functools.lru_cache(maxsize=10240)
26
+ def normalize_common_name_token(value: str) -> str:
27
+ """Normalize a species common-name token for exact matching.
28
+
29
+ This intentionally does not do fuzzy or substring matching. It only folds
30
+ common punctuation and spacing variants that are not meaningful species
31
+ identity boundaries in eBird common names.
32
+ """
33
+ cleaned = unicodedata.normalize("NFKC", value or "").strip().lower()
34
+ if not cleaned:
35
+ return ""
36
+ cleaned = cleaned.translate(_APOSTROPHES_TRANSLATE)
37
+ cleaned = cleaned.translate(_SEPARATORS_TRANSLATE)
38
+ return " ".join(cleaned.split())
39
+
40
+
41
+ def _spelling_synonym_variant(normalized: str) -> str:
42
+ """Return ``normalized`` with standalone colour-spelling words folded.
43
+
44
+ Returns an empty string when no colour-spelling word is present so callers
45
+ can skip adding a duplicate variant.
46
+ """
47
+ if not normalized:
48
+ return ""
49
+ words = normalized.split()
50
+ if not any(word in _SPELLING_SYNONYMS for word in words):
51
+ return ""
52
+ return " ".join(_SPELLING_SYNONYMS.get(word, word) for word in words)
53
+
54
+
55
+ def common_name_token_variants(value: str) -> FrozenSet[str]:
56
+ """Return safe exact-match variants for common-name matching."""
57
+ variants = {normalize_common_name_token(value)}
58
+ without_parenthetical = _PARENTHETICAL_RE.sub(" ", value or "")
59
+ variants.add(normalize_common_name_token(without_parenthetical))
60
+ for normalized in list(variants):
61
+ folded = _spelling_synonym_variant(normalized)
62
+ if folded:
63
+ variants.add(folded)
64
+ return frozenset(token for token in variants if token)