ai-citation-map 0.1.0__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.
- ai_citation_map-0.1.0/.github/workflows/publish.yml +22 -0
- ai_citation_map-0.1.0/LICENSE +21 -0
- ai_citation_map-0.1.0/PKG-INFO +73 -0
- ai_citation_map-0.1.0/README.md +55 -0
- ai_citation_map-0.1.0/examples/citations.csv +4 -0
- ai_citation_map-0.1.0/pyproject.toml +30 -0
- ai_citation_map-0.1.0/src/ai_citation_map/__init__.py +5 -0
- ai_citation_map-0.1.0/src/ai_citation_map/cli.py +44 -0
- ai_citation_map-0.1.0/src/ai_citation_map/core.py +42 -0
- ai_citation_map-0.1.0/tests/test_core.py +19 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
test-build-publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
environment: pypi
|
|
11
|
+
permissions:
|
|
12
|
+
id-token: write
|
|
13
|
+
contents: read
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: "3.12"
|
|
19
|
+
- run: pip install build pytest
|
|
20
|
+
- run: pip install -e . && pytest -q
|
|
21
|
+
- run: python -m build
|
|
22
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 CiteProof
|
|
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,73 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ai-citation-map
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Rank the domains cited in AI answers (ChatGPT, Perplexity, Gemini) from a CSV.
|
|
5
|
+
Project-URL: Homepage, https://github.com/citeproof/ai-citation-map
|
|
6
|
+
Project-URL: Source, https://github.com/citeproof/ai-citation-map
|
|
7
|
+
Project-URL: Related tools, https://citeproof.co/tools/ai-citation-checker?utm_source=pypi&utm_medium=parasite&utm_campaign=ai-citation-map
|
|
8
|
+
Author-email: CiteProof <hello@citeproof.co>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: aeo,ai search,chatgpt,citations,llm,perplexity,seo
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
|
|
16
|
+
Requires-Python: >=3.8
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# ai-citation-map
|
|
20
|
+
|
|
21
|
+
Turn a CSV of URLs cited in AI answers (ChatGPT, Perplexity, Gemini, Claude, Google AI Overviews) into a ranked list of domains: how often each is cited, on how many distinct questions, and by which engines.
|
|
22
|
+
|
|
23
|
+
No dependencies. Python 3.8+.
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install ai-citation-map
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Use
|
|
32
|
+
|
|
33
|
+
Input: one row per cited URL.
|
|
34
|
+
|
|
35
|
+
```csv
|
|
36
|
+
question,engine,cited_url
|
|
37
|
+
best invoicing app for freelancers,chatgpt,https://www.g2.com/categories/invoicing
|
|
38
|
+
best invoicing app for freelancers,perplexity,https://www.reddit.com/r/freelance/comments/abc
|
|
39
|
+
best invoicing app for freelancers,gemini,https://zapier.com/blog/best-invoicing-software/
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
ai-citation-map citations.csv --top 25 --csv-out map.csv
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
domain cites questions engines
|
|
48
|
+
g2.com 1 1 chatgpt
|
|
49
|
+
reddit.com 1 1 perplexity
|
|
50
|
+
zapier.com 1 1 gemini
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
From Python:
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from ai_citation_map import build_map
|
|
57
|
+
for d in build_map(rows):
|
|
58
|
+
print(d.domain, d.cites, len(d.questions), sorted(d.engines))
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Reading the output
|
|
62
|
+
|
|
63
|
+
- Results are sorted by **distinct questions**, then citations: a domain cited once on each of eight questions matters more than one cited ten times on a single question.
|
|
64
|
+
- Domains cited by every engine are the safest targets; ones cited by a single engine may come and go.
|
|
65
|
+
- AI answers vary between runs and locations. Treat the map as a sample and re-run it with the same questions over time.
|
|
66
|
+
|
|
67
|
+
## Collecting the input
|
|
68
|
+
|
|
69
|
+
By hand (ask each question in each engine and log the cited links), or with CiteProof's free [AI citation checker](https://citeproof.co/tools/ai-citation-checker?utm_source=pypi&utm_medium=parasite&utm_campaign=ai-citation-map), which queries ChatGPT, Perplexity and Gemini and lists the domains each one cites.
|
|
70
|
+
|
|
71
|
+
More templates (robots.txt rules for AI crawlers, llms.txt, JSON-LD): [citeproof/ai-visibility-toolkit](https://github.com/citeproof/ai-visibility-toolkit).
|
|
72
|
+
|
|
73
|
+
MIT licensed. Maintained by [CiteProof](https://citeproof.co).
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# ai-citation-map
|
|
2
|
+
|
|
3
|
+
Turn a CSV of URLs cited in AI answers (ChatGPT, Perplexity, Gemini, Claude, Google AI Overviews) into a ranked list of domains: how often each is cited, on how many distinct questions, and by which engines.
|
|
4
|
+
|
|
5
|
+
No dependencies. Python 3.8+.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install ai-citation-map
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Use
|
|
14
|
+
|
|
15
|
+
Input: one row per cited URL.
|
|
16
|
+
|
|
17
|
+
```csv
|
|
18
|
+
question,engine,cited_url
|
|
19
|
+
best invoicing app for freelancers,chatgpt,https://www.g2.com/categories/invoicing
|
|
20
|
+
best invoicing app for freelancers,perplexity,https://www.reddit.com/r/freelance/comments/abc
|
|
21
|
+
best invoicing app for freelancers,gemini,https://zapier.com/blog/best-invoicing-software/
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
ai-citation-map citations.csv --top 25 --csv-out map.csv
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
domain cites questions engines
|
|
30
|
+
g2.com 1 1 chatgpt
|
|
31
|
+
reddit.com 1 1 perplexity
|
|
32
|
+
zapier.com 1 1 gemini
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
From Python:
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from ai_citation_map import build_map
|
|
39
|
+
for d in build_map(rows):
|
|
40
|
+
print(d.domain, d.cites, len(d.questions), sorted(d.engines))
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Reading the output
|
|
44
|
+
|
|
45
|
+
- Results are sorted by **distinct questions**, then citations: a domain cited once on each of eight questions matters more than one cited ten times on a single question.
|
|
46
|
+
- Domains cited by every engine are the safest targets; ones cited by a single engine may come and go.
|
|
47
|
+
- AI answers vary between runs and locations. Treat the map as a sample and re-run it with the same questions over time.
|
|
48
|
+
|
|
49
|
+
## Collecting the input
|
|
50
|
+
|
|
51
|
+
By hand (ask each question in each engine and log the cited links), or with CiteProof's free [AI citation checker](https://citeproof.co/tools/ai-citation-checker?utm_source=pypi&utm_medium=parasite&utm_campaign=ai-citation-map), which queries ChatGPT, Perplexity and Gemini and lists the domains each one cites.
|
|
52
|
+
|
|
53
|
+
More templates (robots.txt rules for AI crawlers, llms.txt, JSON-LD): [citeproof/ai-visibility-toolkit](https://github.com/citeproof/ai-visibility-toolkit).
|
|
54
|
+
|
|
55
|
+
MIT licensed. Maintained by [CiteProof](https://citeproof.co).
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
question,engine,cited_url
|
|
2
|
+
best invoicing app for freelancers,chatgpt,https://www.g2.com/categories/invoicing
|
|
3
|
+
best invoicing app for freelancers,perplexity,https://www.reddit.com/r/freelance/comments/abc
|
|
4
|
+
best invoicing app for freelancers,gemini,https://zapier.com/blog/best-invoicing-software/
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ai-citation-map"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Rank the domains cited in AI answers (ChatGPT, Perplexity, Gemini) from a CSV."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.8"
|
|
12
|
+
authors = [{ name = "CiteProof", email = "hello@citeproof.co" }]
|
|
13
|
+
keywords = ["seo", "aeo", "ai search", "chatgpt", "perplexity", "citations", "llm"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Environment :: Console",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Topic :: Internet :: WWW/HTTP :: Indexing/Search",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://github.com/citeproof/ai-citation-map"
|
|
23
|
+
Source = "https://github.com/citeproof/ai-citation-map"
|
|
24
|
+
"Related tools" = "https://citeproof.co/tools/ai-citation-checker?utm_source=pypi&utm_medium=parasite&utm_campaign=ai-citation-map"
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
ai-citation-map = "ai_citation_map.cli:main"
|
|
28
|
+
|
|
29
|
+
[tool.hatch.build.targets.wheel]
|
|
30
|
+
packages = ["src/ai_citation_map"]
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import csv
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
from .core import build_map, read_csv
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def main(argv=None) -> int:
|
|
9
|
+
p = argparse.ArgumentParser(
|
|
10
|
+
prog="ai-citation-map",
|
|
11
|
+
description="Rank the domains cited in AI answers (ChatGPT, Perplexity, Gemini...) from a CSV "
|
|
12
|
+
"with columns question, engine, cited_url.",
|
|
13
|
+
)
|
|
14
|
+
p.add_argument("csv", help="input CSV file")
|
|
15
|
+
p.add_argument("-n", "--top", type=int, default=25, help="how many domains to show (default 25)")
|
|
16
|
+
p.add_argument("--csv-out", help="also write the full map to this CSV file")
|
|
17
|
+
a = p.parse_args(argv)
|
|
18
|
+
|
|
19
|
+
try:
|
|
20
|
+
rows = read_csv(a.csv)
|
|
21
|
+
except FileNotFoundError:
|
|
22
|
+
print(f"File not found: {a.csv}", file=sys.stderr)
|
|
23
|
+
return 1
|
|
24
|
+
missing = {"question", "engine", "cited_url"} - set(rows[0].keys() if rows else [])
|
|
25
|
+
if missing:
|
|
26
|
+
print(f"Missing column(s): {', '.join(sorted(missing))}", file=sys.stderr)
|
|
27
|
+
return 1
|
|
28
|
+
|
|
29
|
+
result = build_map(rows)
|
|
30
|
+
print(f"{'domain':35} {'cites':>5} {'questions':>9} engines")
|
|
31
|
+
for s in result[: a.top]:
|
|
32
|
+
print(f"{s.domain:35} {s.cites:>5} {len(s.questions):>9} {', '.join(sorted(s.engines))}")
|
|
33
|
+
|
|
34
|
+
if a.csv_out:
|
|
35
|
+
with open(a.csv_out, "w", newline="", encoding="utf-8") as f:
|
|
36
|
+
w = csv.writer(f)
|
|
37
|
+
w.writerow(["domain", "cites", "questions", "engines"])
|
|
38
|
+
for s in result:
|
|
39
|
+
w.writerow([s.domain, s.cites, len(s.questions), " ".join(sorted(s.engines))])
|
|
40
|
+
return 0
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
if __name__ == "__main__":
|
|
44
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import csv
|
|
2
|
+
from collections import Counter, defaultdict
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
from typing import Iterable, List
|
|
5
|
+
from urllib.parse import urlparse
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def domain_of(url: str) -> str:
|
|
9
|
+
"""Return the host of a URL, lowercased, without a leading 'www.'."""
|
|
10
|
+
host = urlparse(url.strip()).netloc.lower()
|
|
11
|
+
return host[4:] if host.startswith("www.") else host
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass
|
|
15
|
+
class DomainStats:
|
|
16
|
+
domain: str
|
|
17
|
+
cites: int = 0
|
|
18
|
+
questions: set = field(default_factory=set)
|
|
19
|
+
engines: set = field(default_factory=set)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def build_map(rows: Iterable[dict]) -> List[DomainStats]:
|
|
23
|
+
"""Aggregate rows with 'question', 'engine' and 'cited_url' keys.
|
|
24
|
+
|
|
25
|
+
Sorted by number of distinct questions, then by number of citations.
|
|
26
|
+
"""
|
|
27
|
+
stats = {}
|
|
28
|
+
for row in rows:
|
|
29
|
+
url = (row.get("cited_url") or "").strip()
|
|
30
|
+
if not url:
|
|
31
|
+
continue
|
|
32
|
+
d = domain_of(url)
|
|
33
|
+
s = stats.setdefault(d, DomainStats(d))
|
|
34
|
+
s.cites += 1
|
|
35
|
+
s.questions.add((row.get("question") or "").strip())
|
|
36
|
+
s.engines.add((row.get("engine") or "").strip().lower())
|
|
37
|
+
return sorted(stats.values(), key=lambda s: (-len(s.questions), -s.cites, s.domain))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def read_csv(path: str) -> List[dict]:
|
|
41
|
+
with open(path, newline="", encoding="utf-8") as f:
|
|
42
|
+
return list(csv.DictReader(f))
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from ai_citation_map import build_map, domain_of
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def test_domain_of():
|
|
5
|
+
assert domain_of("https://www.G2.com/x") == "g2.com"
|
|
6
|
+
assert domain_of("http://reddit.com/r/a") == "reddit.com"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def test_build_map_orders_by_questions():
|
|
10
|
+
rows = [
|
|
11
|
+
{"question": "q1", "engine": "chatgpt", "cited_url": "https://a.com/1"},
|
|
12
|
+
{"question": "q1", "engine": "chatgpt", "cited_url": "https://a.com/2"},
|
|
13
|
+
{"question": "q1", "engine": "chatgpt", "cited_url": "https://a.com/3"},
|
|
14
|
+
{"question": "q1", "engine": "perplexity", "cited_url": "https://b.com"},
|
|
15
|
+
{"question": "q2", "engine": "gemini", "cited_url": "https://www.b.com"},
|
|
16
|
+
]
|
|
17
|
+
m = build_map(rows)
|
|
18
|
+
assert m[0].domain == "b.com" and len(m[0].questions) == 2
|
|
19
|
+
assert m[1].domain == "a.com" and m[1].cites == 3
|