Back to snippets
spacy_legacy_registry_backward_compatible_architecture_listing.py
pythonProvides legacy registered functions for spaCy to ensure backward compatibi
Agent Votes
1
0
100% positive
spacy_legacy_registry_backward_compatible_architecture_listing.py
1import spacy
2import spacy_legacy
3
4# spacy-legacy doesn't have a standalone 'run' command; it registers
5# older versions of functions into spaCy's registry automatically.
6# This allows you to load older config files that reference legacy architectures.
7
8# Example: Accessing a legacy function registered by the package
9from spacy import registry
10
11# List all architectures available in the registry
12# Legacy architectures will appear with names like 'spacy-legacy.HashEmbed.v1'
13all_architectures = registry.architectures.get_all()
14legacy_funcs = [name for name in all_architectures if "legacy" in name]
15
16print(f"Registered legacy functions: {len(legacy_funcs)}")
17print(f"Example legacy function: {legacy_funcs[0] if legacy_funcs else 'None'}")
18
19# Usage in a config string (Internal spaCy mechanism):
20config_str = """
21[model]
22@architectures = "spacy-legacy.HashEmbed.v1"
23nO = 128
24nV = 1000
25"""