cooperdk commited on
Commit
c89bb8d
·
verified ·
1 Parent(s): 89d403e

Upload folder using huggingface_hub

Browse files
linux/libtagforge.so CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:a981386bbe5ebe8bae36053dfa6adfc2dcd101a5fe0ffcc98d6b669ed11d023c
3
  size 22188168
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0b197d2c24b05378f0ae3b0d121817f013582d4c401d80cc066c7d781a1437a4
3
  size 22188168
linux/tagforge_native.py ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """tagforge_native.py — ctypes wrapper for the compiled CLASSIFY engine.
2
+ Ship this next to the platform binary (libtagforge.so / tagforge.dll / libtagforge.dylib).
3
+ The taxonomy is inside the binary; this file is just glue and is safe to ship readable.
4
+
5
+ from tagforge_native import classify
6
+ classify(["1girl", "blonde_hair", "censored", "holding", "knife"])
7
+ # -> {"SUBJECT":["1girl"], "HAIR":["blonde_hair"], "CENSOR":["censored"],
8
+ # "HANDS":["knife"], "ACTION":["holding"], ...}
9
+ """
10
+ import ctypes, json, os, platform
11
+
12
+ _LIBNAME = {
13
+ "Linux": "libtagforge.so",
14
+ "Windows": "tagforge.dll",
15
+ "Darwin": "libtagforge.dylib",
16
+ }[platform.system()]
17
+
18
+ _lib = ctypes.CDLL(os.path.join(os.path.dirname(os.path.abspath(__file__)), _LIBNAME))
19
+ _lib.tagforge_classify.restype = ctypes.c_void_p # void* so we can free the exact ptr
20
+ _lib.tagforge_classify.argtypes = [ctypes.c_char_p]
21
+ _lib.tagforge_free.argtypes = [ctypes.c_void_p]
22
+ _lib.tagforge_tier.restype = ctypes.c_char_p
23
+
24
+ # Optional newer exports (version + zone search). Guarded so an older binary that
25
+ # predates them still loads (version -> "", search -> []).
26
+ try:
27
+ _lib.tagforge_version.restype = ctypes.c_char_p
28
+ _lib.tagforge_search.restype = ctypes.c_void_p
29
+ _lib.tagforge_search.argtypes = [ctypes.c_char_p, ctypes.c_char_p]
30
+ _lib.tagforge_styles.restype = ctypes.c_char_p
31
+ _HAS_SEARCH = True
32
+ except AttributeError:
33
+ _HAS_SEARCH = False
34
+
35
+ # tagforge_police is newer still — guard separately so a search-capable binary that predates
36
+ # the content wall still loads.
37
+ try:
38
+ _lib.tagforge_police.restype = ctypes.c_void_p
39
+ _lib.tagforge_police.argtypes = [ctypes.c_char_p]
40
+ _HAS_POLICE = True
41
+ except AttributeError:
42
+ _HAS_POLICE = False
43
+
44
+
45
+ def styles():
46
+ """Grouped style menu (tier-gated; a free DLL embeds only free styles). {} if unavailable."""
47
+ if not _HAS_SEARCH:
48
+ return {}
49
+ try:
50
+ return json.loads((_lib.tagforge_styles() or b"{}").decode("utf-8"))
51
+ except Exception:
52
+ return {}
53
+
54
+
55
+ def version():
56
+ """Embedded taxonomy/data version, e.g. '0.8.0' ('' on older binaries)."""
57
+ if not _HAS_SEARCH:
58
+ return ""
59
+ try:
60
+ return (_lib.tagforge_version() or b"").decode("utf-8")
61
+ except Exception:
62
+ return ""
63
+
64
+
65
+ def search(zone, query=""):
66
+ """Search the embedded (tier-gated) taxonomy: tags in `zone` matching `query`.
67
+ Returns up to 30 tag strings, count-desc. [] if unavailable."""
68
+ if not _HAS_SEARCH:
69
+ return []
70
+ ptr = _lib.tagforge_search(str(zone).encode("utf-8"), str(query).encode("utf-8"))
71
+ if not ptr:
72
+ return []
73
+ try:
74
+ return json.loads(ctypes.cast(ptr, ctypes.c_char_p).value.decode("utf-8"))
75
+ finally:
76
+ _lib.tagforge_free(ptr)
77
+
78
+
79
+ def tier():
80
+ """'full' (paid: outfit+sexual embedded) or 'free'. Node uses this to self-configure:
81
+ on 'free', lock the assisted clothing generation."""
82
+ return _lib.tagforge_tier().decode("utf-8")
83
+
84
+
85
+ def police(tags):
86
+ """Free-tier content wall (compiled, untouchable): drop explicit/sexual (blocklisted) tags
87
+ and clamp an explicit rating 'e' -> 'q'. Run on the FINAL tag list right before BOTH the
88
+ sampler input and the structured_tags output pin. The full build returns the tags unchanged.
89
+ If the binary predates police(), returns the input unchanged (older binaries have no wall)."""
90
+ if not _HAS_POLICE:
91
+ return list(tags)
92
+ ptr = _lib.tagforge_police(json.dumps(list(tags)).encode("utf-8"))
93
+ if not ptr:
94
+ return list(tags)
95
+ try:
96
+ return json.loads(ctypes.cast(ptr, ctypes.c_char_p).value.decode("utf-8"))
97
+ finally:
98
+ _lib.tagforge_free(ptr)
99
+
100
+
101
+ def classify(tags):
102
+ """tags: list[str] -> dict{zone: [tags]}. Faithful: only reorganizes the input."""
103
+ ptr = _lib.tagforge_classify(json.dumps(list(tags)).encode("utf-8"))
104
+ if not ptr:
105
+ return {}
106
+ try:
107
+ return json.loads(ctypes.cast(ptr, ctypes.c_char_p).value.decode("utf-8"))
108
+ finally:
109
+ _lib.tagforge_free(ptr)
macos-arm64/libtagforge.dylib CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:36b04edd3a38bb1e8d6b839b1235f9caf127277ca18623db93aca044cf948351
3
  size 22295728
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1e8912de1899e36ed2594d61c589cf0d626e0e092f3e440b2b3daaf42e997d30
3
  size 22295728
macos-arm64/tagforge_native.py ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """tagforge_native.py — ctypes wrapper for the compiled CLASSIFY engine.
2
+ Ship this next to the platform binary (libtagforge.so / tagforge.dll / libtagforge.dylib).
3
+ The taxonomy is inside the binary; this file is just glue and is safe to ship readable.
4
+
5
+ from tagforge_native import classify
6
+ classify(["1girl", "blonde_hair", "censored", "holding", "knife"])
7
+ # -> {"SUBJECT":["1girl"], "HAIR":["blonde_hair"], "CENSOR":["censored"],
8
+ # "HANDS":["knife"], "ACTION":["holding"], ...}
9
+ """
10
+ import ctypes, json, os, platform
11
+
12
+ _LIBNAME = {
13
+ "Linux": "libtagforge.so",
14
+ "Windows": "tagforge.dll",
15
+ "Darwin": "libtagforge.dylib",
16
+ }[platform.system()]
17
+
18
+ _lib = ctypes.CDLL(os.path.join(os.path.dirname(os.path.abspath(__file__)), _LIBNAME))
19
+ _lib.tagforge_classify.restype = ctypes.c_void_p # void* so we can free the exact ptr
20
+ _lib.tagforge_classify.argtypes = [ctypes.c_char_p]
21
+ _lib.tagforge_free.argtypes = [ctypes.c_void_p]
22
+ _lib.tagforge_tier.restype = ctypes.c_char_p
23
+
24
+ # Optional newer exports (version + zone search). Guarded so an older binary that
25
+ # predates them still loads (version -> "", search -> []).
26
+ try:
27
+ _lib.tagforge_version.restype = ctypes.c_char_p
28
+ _lib.tagforge_search.restype = ctypes.c_void_p
29
+ _lib.tagforge_search.argtypes = [ctypes.c_char_p, ctypes.c_char_p]
30
+ _lib.tagforge_styles.restype = ctypes.c_char_p
31
+ _HAS_SEARCH = True
32
+ except AttributeError:
33
+ _HAS_SEARCH = False
34
+
35
+ # tagforge_police is newer still — guard separately so a search-capable binary that predates
36
+ # the content wall still loads.
37
+ try:
38
+ _lib.tagforge_police.restype = ctypes.c_void_p
39
+ _lib.tagforge_police.argtypes = [ctypes.c_char_p]
40
+ _HAS_POLICE = True
41
+ except AttributeError:
42
+ _HAS_POLICE = False
43
+
44
+
45
+ def styles():
46
+ """Grouped style menu (tier-gated; a free DLL embeds only free styles). {} if unavailable."""
47
+ if not _HAS_SEARCH:
48
+ return {}
49
+ try:
50
+ return json.loads((_lib.tagforge_styles() or b"{}").decode("utf-8"))
51
+ except Exception:
52
+ return {}
53
+
54
+
55
+ def version():
56
+ """Embedded taxonomy/data version, e.g. '0.8.0' ('' on older binaries)."""
57
+ if not _HAS_SEARCH:
58
+ return ""
59
+ try:
60
+ return (_lib.tagforge_version() or b"").decode("utf-8")
61
+ except Exception:
62
+ return ""
63
+
64
+
65
+ def search(zone, query=""):
66
+ """Search the embedded (tier-gated) taxonomy: tags in `zone` matching `query`.
67
+ Returns up to 30 tag strings, count-desc. [] if unavailable."""
68
+ if not _HAS_SEARCH:
69
+ return []
70
+ ptr = _lib.tagforge_search(str(zone).encode("utf-8"), str(query).encode("utf-8"))
71
+ if not ptr:
72
+ return []
73
+ try:
74
+ return json.loads(ctypes.cast(ptr, ctypes.c_char_p).value.decode("utf-8"))
75
+ finally:
76
+ _lib.tagforge_free(ptr)
77
+
78
+
79
+ def tier():
80
+ """'full' (paid: outfit+sexual embedded) or 'free'. Node uses this to self-configure:
81
+ on 'free', lock the assisted clothing generation."""
82
+ return _lib.tagforge_tier().decode("utf-8")
83
+
84
+
85
+ def police(tags):
86
+ """Free-tier content wall (compiled, untouchable): drop explicit/sexual (blocklisted) tags
87
+ and clamp an explicit rating 'e' -> 'q'. Run on the FINAL tag list right before BOTH the
88
+ sampler input and the structured_tags output pin. The full build returns the tags unchanged.
89
+ If the binary predates police(), returns the input unchanged (older binaries have no wall)."""
90
+ if not _HAS_POLICE:
91
+ return list(tags)
92
+ ptr = _lib.tagforge_police(json.dumps(list(tags)).encode("utf-8"))
93
+ if not ptr:
94
+ return list(tags)
95
+ try:
96
+ return json.loads(ctypes.cast(ptr, ctypes.c_char_p).value.decode("utf-8"))
97
+ finally:
98
+ _lib.tagforge_free(ptr)
99
+
100
+
101
+ def classify(tags):
102
+ """tags: list[str] -> dict{zone: [tags]}. Faithful: only reorganizes the input."""
103
+ ptr = _lib.tagforge_classify(json.dumps(list(tags)).encode("utf-8"))
104
+ if not ptr:
105
+ return {}
106
+ try:
107
+ return json.loads(ctypes.cast(ptr, ctypes.c_char_p).value.decode("utf-8"))
108
+ finally:
109
+ _lib.tagforge_free(ptr)
macos-x64/libtagforge.dylib CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:eeff448ca0ba0e2da3fef0a27e94a3dcb7a47ca0b9e8c6aaf6ba9998fa8ce24a
3
  size 22131264
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f2345e8c4aa0a050a5517a6b80be1020d598f87d4d875f6262b0fc5ecc3bf6e0
3
  size 22131264
macos-x64/tagforge_native.py ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """tagforge_native.py — ctypes wrapper for the compiled CLASSIFY engine.
2
+ Ship this next to the platform binary (libtagforge.so / tagforge.dll / libtagforge.dylib).
3
+ The taxonomy is inside the binary; this file is just glue and is safe to ship readable.
4
+
5
+ from tagforge_native import classify
6
+ classify(["1girl", "blonde_hair", "censored", "holding", "knife"])
7
+ # -> {"SUBJECT":["1girl"], "HAIR":["blonde_hair"], "CENSOR":["censored"],
8
+ # "HANDS":["knife"], "ACTION":["holding"], ...}
9
+ """
10
+ import ctypes, json, os, platform
11
+
12
+ _LIBNAME = {
13
+ "Linux": "libtagforge.so",
14
+ "Windows": "tagforge.dll",
15
+ "Darwin": "libtagforge.dylib",
16
+ }[platform.system()]
17
+
18
+ _lib = ctypes.CDLL(os.path.join(os.path.dirname(os.path.abspath(__file__)), _LIBNAME))
19
+ _lib.tagforge_classify.restype = ctypes.c_void_p # void* so we can free the exact ptr
20
+ _lib.tagforge_classify.argtypes = [ctypes.c_char_p]
21
+ _lib.tagforge_free.argtypes = [ctypes.c_void_p]
22
+ _lib.tagforge_tier.restype = ctypes.c_char_p
23
+
24
+ # Optional newer exports (version + zone search). Guarded so an older binary that
25
+ # predates them still loads (version -> "", search -> []).
26
+ try:
27
+ _lib.tagforge_version.restype = ctypes.c_char_p
28
+ _lib.tagforge_search.restype = ctypes.c_void_p
29
+ _lib.tagforge_search.argtypes = [ctypes.c_char_p, ctypes.c_char_p]
30
+ _lib.tagforge_styles.restype = ctypes.c_char_p
31
+ _HAS_SEARCH = True
32
+ except AttributeError:
33
+ _HAS_SEARCH = False
34
+
35
+ # tagforge_police is newer still — guard separately so a search-capable binary that predates
36
+ # the content wall still loads.
37
+ try:
38
+ _lib.tagforge_police.restype = ctypes.c_void_p
39
+ _lib.tagforge_police.argtypes = [ctypes.c_char_p]
40
+ _HAS_POLICE = True
41
+ except AttributeError:
42
+ _HAS_POLICE = False
43
+
44
+
45
+ def styles():
46
+ """Grouped style menu (tier-gated; a free DLL embeds only free styles). {} if unavailable."""
47
+ if not _HAS_SEARCH:
48
+ return {}
49
+ try:
50
+ return json.loads((_lib.tagforge_styles() or b"{}").decode("utf-8"))
51
+ except Exception:
52
+ return {}
53
+
54
+
55
+ def version():
56
+ """Embedded taxonomy/data version, e.g. '0.8.0' ('' on older binaries)."""
57
+ if not _HAS_SEARCH:
58
+ return ""
59
+ try:
60
+ return (_lib.tagforge_version() or b"").decode("utf-8")
61
+ except Exception:
62
+ return ""
63
+
64
+
65
+ def search(zone, query=""):
66
+ """Search the embedded (tier-gated) taxonomy: tags in `zone` matching `query`.
67
+ Returns up to 30 tag strings, count-desc. [] if unavailable."""
68
+ if not _HAS_SEARCH:
69
+ return []
70
+ ptr = _lib.tagforge_search(str(zone).encode("utf-8"), str(query).encode("utf-8"))
71
+ if not ptr:
72
+ return []
73
+ try:
74
+ return json.loads(ctypes.cast(ptr, ctypes.c_char_p).value.decode("utf-8"))
75
+ finally:
76
+ _lib.tagforge_free(ptr)
77
+
78
+
79
+ def tier():
80
+ """'full' (paid: outfit+sexual embedded) or 'free'. Node uses this to self-configure:
81
+ on 'free', lock the assisted clothing generation."""
82
+ return _lib.tagforge_tier().decode("utf-8")
83
+
84
+
85
+ def police(tags):
86
+ """Free-tier content wall (compiled, untouchable): drop explicit/sexual (blocklisted) tags
87
+ and clamp an explicit rating 'e' -> 'q'. Run on the FINAL tag list right before BOTH the
88
+ sampler input and the structured_tags output pin. The full build returns the tags unchanged.
89
+ If the binary predates police(), returns the input unchanged (older binaries have no wall)."""
90
+ if not _HAS_POLICE:
91
+ return list(tags)
92
+ ptr = _lib.tagforge_police(json.dumps(list(tags)).encode("utf-8"))
93
+ if not ptr:
94
+ return list(tags)
95
+ try:
96
+ return json.loads(ctypes.cast(ptr, ctypes.c_char_p).value.decode("utf-8"))
97
+ finally:
98
+ _lib.tagforge_free(ptr)
99
+
100
+
101
+ def classify(tags):
102
+ """tags: list[str] -> dict{zone: [tags]}. Faithful: only reorganizes the input."""
103
+ ptr = _lib.tagforge_classify(json.dumps(list(tags)).encode("utf-8"))
104
+ if not ptr:
105
+ return {}
106
+ try:
107
+ return json.loads(ctypes.cast(ptr, ctypes.c_char_p).value.decode("utf-8"))
108
+ finally:
109
+ _lib.tagforge_free(ptr)
version.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ 0.4.2
windows/tagforge.dll CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:889a39387e182bb1c6d68a44eae7b4bc60e0c19c8ca1195c0fe3f4a3d933f588
3
  size 22171648
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ab7284bcc0464510411321842420d5fff0d75a9f2f1dc8873f3cf451f44efc61
3
  size 22171648
windows/tagforge_native.py ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """tagforge_native.py — ctypes wrapper for the compiled CLASSIFY engine.
2
+ Ship this next to the platform binary (libtagforge.so / tagforge.dll / libtagforge.dylib).
3
+ The taxonomy is inside the binary; this file is just glue and is safe to ship readable.
4
+
5
+ from tagforge_native import classify
6
+ classify(["1girl", "blonde_hair", "censored", "holding", "knife"])
7
+ # -> {"SUBJECT":["1girl"], "HAIR":["blonde_hair"], "CENSOR":["censored"],
8
+ # "HANDS":["knife"], "ACTION":["holding"], ...}
9
+ """
10
+ import ctypes, json, os, platform
11
+
12
+ _LIBNAME = {
13
+ "Linux": "libtagforge.so",
14
+ "Windows": "tagforge.dll",
15
+ "Darwin": "libtagforge.dylib",
16
+ }[platform.system()]
17
+
18
+ _lib = ctypes.CDLL(os.path.join(os.path.dirname(os.path.abspath(__file__)), _LIBNAME))
19
+ _lib.tagforge_classify.restype = ctypes.c_void_p # void* so we can free the exact ptr
20
+ _lib.tagforge_classify.argtypes = [ctypes.c_char_p]
21
+ _lib.tagforge_free.argtypes = [ctypes.c_void_p]
22
+ _lib.tagforge_tier.restype = ctypes.c_char_p
23
+
24
+ # Optional newer exports (version + zone search). Guarded so an older binary that
25
+ # predates them still loads (version -> "", search -> []).
26
+ try:
27
+ _lib.tagforge_version.restype = ctypes.c_char_p
28
+ _lib.tagforge_search.restype = ctypes.c_void_p
29
+ _lib.tagforge_search.argtypes = [ctypes.c_char_p, ctypes.c_char_p]
30
+ _lib.tagforge_styles.restype = ctypes.c_char_p
31
+ _HAS_SEARCH = True
32
+ except AttributeError:
33
+ _HAS_SEARCH = False
34
+
35
+ # tagforge_police is newer still — guard separately so a search-capable binary that predates
36
+ # the content wall still loads.
37
+ try:
38
+ _lib.tagforge_police.restype = ctypes.c_void_p
39
+ _lib.tagforge_police.argtypes = [ctypes.c_char_p]
40
+ _HAS_POLICE = True
41
+ except AttributeError:
42
+ _HAS_POLICE = False
43
+
44
+
45
+ def styles():
46
+ """Grouped style menu (tier-gated; a free DLL embeds only free styles). {} if unavailable."""
47
+ if not _HAS_SEARCH:
48
+ return {}
49
+ try:
50
+ return json.loads((_lib.tagforge_styles() or b"{}").decode("utf-8"))
51
+ except Exception:
52
+ return {}
53
+
54
+
55
+ def version():
56
+ """Embedded taxonomy/data version, e.g. '0.8.0' ('' on older binaries)."""
57
+ if not _HAS_SEARCH:
58
+ return ""
59
+ try:
60
+ return (_lib.tagforge_version() or b"").decode("utf-8")
61
+ except Exception:
62
+ return ""
63
+
64
+
65
+ def search(zone, query=""):
66
+ """Search the embedded (tier-gated) taxonomy: tags in `zone` matching `query`.
67
+ Returns up to 30 tag strings, count-desc. [] if unavailable."""
68
+ if not _HAS_SEARCH:
69
+ return []
70
+ ptr = _lib.tagforge_search(str(zone).encode("utf-8"), str(query).encode("utf-8"))
71
+ if not ptr:
72
+ return []
73
+ try:
74
+ return json.loads(ctypes.cast(ptr, ctypes.c_char_p).value.decode("utf-8"))
75
+ finally:
76
+ _lib.tagforge_free(ptr)
77
+
78
+
79
+ def tier():
80
+ """'full' (paid: outfit+sexual embedded) or 'free'. Node uses this to self-configure:
81
+ on 'free', lock the assisted clothing generation."""
82
+ return _lib.tagforge_tier().decode("utf-8")
83
+
84
+
85
+ def police(tags):
86
+ """Free-tier content wall (compiled, untouchable): drop explicit/sexual (blocklisted) tags
87
+ and clamp an explicit rating 'e' -> 'q'. Run on the FINAL tag list right before BOTH the
88
+ sampler input and the structured_tags output pin. The full build returns the tags unchanged.
89
+ If the binary predates police(), returns the input unchanged (older binaries have no wall)."""
90
+ if not _HAS_POLICE:
91
+ return list(tags)
92
+ ptr = _lib.tagforge_police(json.dumps(list(tags)).encode("utf-8"))
93
+ if not ptr:
94
+ return list(tags)
95
+ try:
96
+ return json.loads(ctypes.cast(ptr, ctypes.c_char_p).value.decode("utf-8"))
97
+ finally:
98
+ _lib.tagforge_free(ptr)
99
+
100
+
101
+ def classify(tags):
102
+ """tags: list[str] -> dict{zone: [tags]}. Faithful: only reorganizes the input."""
103
+ ptr = _lib.tagforge_classify(json.dumps(list(tags)).encode("utf-8"))
104
+ if not ptr:
105
+ return {}
106
+ try:
107
+ return json.loads(ctypes.cast(ptr, ctypes.c_char_p).value.decode("utf-8"))
108
+ finally:
109
+ _lib.tagforge_free(ptr)