Class: Autotype::HeuristicCapabilityNamer
- Inherits:
-
Object
- Object
- Autotype::HeuristicCapabilityNamer
- Defined in:
- lib/autotype/engine.rb
Overview
Deterministic, LLM-free naming. Names are derived from the capability shape itself: a Ruby-vocabulary table for common messages, snake_case morphology for the rest, and a detail-escalation ladder that resolves collisions by folding in more of the shape (all sends, then result types, then argument types, then a full injective mangle of the definition).
Constant Summary collapse
- MAX_LEVEL =
5- GREEK_WORDS =
/(?:Alpha|Beta|Gamma|Delta|Epsilon|Zeta|Eta|Theta|Iota|Kappa|Lambda|Mu|Nu|Xi|Omicron|Pi|Rho|Sigma|Tau|Upsilon|Phi|Chi|Psi|Omega)(?=[A-Z]|$)/- KNOWN =
{ "to_s" => "Stringifiable", "to_str" => "Stringifiable", "inspect" => "Inspectable", "to_i" => "IntegerConvertible", "to_int" => "IntegerConvertible", "to_f" => "FloatConvertible", "to_h" => "HashConvertible", "to_a" => "ArrayConvertible", "to_sym" => "Symbolizable", "to_json" => "JsonSerializable", "to_set" => "SetConvertible", "to_proc" => "ProcConvertible", "each" => "Enumerable", "each_with_index" => "IndexEnumerable", "each_with_object" => "ObjectEnumerable", "each_pair" => "PairEnumerable", "each_key" => "KeyEnumerable", "each_value" => "ValueEnumerable", "map" => "Mappable", "collect" => "Mappable", "flat_map" => "FlatMappable", "filter_map" => "FilterMappable", "select" => "Selectable", "filter" => "Filterable", "reject" => "Rejectable", "reduce" => "Reducible", "inject" => "Reducible", "sum" => "Summable", "find" => "Findable", "detect" => "Findable", "include?" => "MembershipTestable", "size" => "Sizable", "length" => "Measurable", "count" => "Countable", "call" => "Callable", "new" => "Instantiable", "create" => "Creatable", "build" => "Buildable", "[]" => "Indexable", "[]=" => "IndexWritable", "<<" => "Appendable", "push" => "Pushable", "+" => "Addable", "-" => "Subtractable", "*" => "Multipliable", "/" => "Divisible", "%" => "Modulable", "**" => "Exponentiable", "==" => "Equatable", "!=" => "Equatable", "eql?" => "Equatable", "equal?" => "Equatable", "<=>" => "Comparable", "<" => "Comparable", ">" => "Comparable", "<=" => "Comparable", ">=" => "Comparable", "=~" => "Matchable", "match" => "Matchable", "match?" => "Matchable", "!" => "Negatable", "&" => "Conjoinable", "|" => "Disjoinable", "^" => "ExclusiveDisjoinable", "nil?" => "NilTestable", "empty?" => "EmptinessTestable", "any?" => "AnyTestable", "all?" => "AllTestable", "present?" => "PresenceTestable", "blank?" => "BlankTestable", "presence" => "PresenceReadable", "dup" => "Duplicable", "clone" => "Clonable", "freeze" => "Freezable", "frozen?" => "FrozenTestable", "tap" => "Tappable", "then" => "Chainable", "yield_self" => "Chainable", "itself" => "IdentityReadable", "fetch" => "Fetchable", "dig" => "Diggable", "key?" => "KeyTestable", "has_key?" => "KeyTestable", "keys" => "KeysReadable", "values" => "ValuesReadable", "merge" => "Mergeable", "merge!" => "Mergeable", "join" => "Joinable", "split" => "Splittable", "strip" => "Strippable", "chomp" => "Chompable", "gsub" => "GlobalSubstitutable", "sub" => "Substitutable", "downcase" => "Downcaseable", "upcase" => "Upcaseable", "capitalize" => "Capitalizable", "start_with?" => "PrefixTestable", "end_with?" => "SuffixTestable", "first" => "FirstReadable", "last" => "LastReadable", "min" => "MinReadable", "max" => "MaxReadable", "compact" => "Compactable", "flatten" => "Flattenable", "uniq" => "Uniquable", "sort" => "Sortable", "sort_by" => "KeySortable", "group_by" => "Groupable", "reverse" => "Reversible", "raise" => "Raisable", "emit" => "Emittable", "respond_to?" => "RespondTestable", "send" => "MessageSendable", "public_send" => "MessageSendable" }.freeze
Instance Method Summary collapse
-
#initialize(registry) ⇒ HeuristicCapabilityNamer
constructor
A new instance of HeuristicCapabilityNamer.
- #name! ⇒ Object
Constructor Details
#initialize(registry) ⇒ HeuristicCapabilityNamer
Returns a new instance of HeuristicCapabilityNamer.
4030 4031 4032 |
# File 'lib/autotype/engine.rb', line 4030 def initialize(registry) @registry = registry end |
Instance Method Details
#name! ⇒ Object
4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 |
# File 'lib/autotype/engine.rb', line 4034 def name! levels = Hash.new(1) names = {} (MAX_LEVEL * 4).times do names = @registry.definitions.to_h do |definition| [definition.fetch(:id), name_for(definition, levels[definition.fetch(:id)])] end clusters = @registry.definitions .group_by { |definition| @registry.normalize_semantic_name(names[definition.fetch(:id)]) } .select { |_, members| members.length > 1 } break if clusters.empty? progressed = false clusters.each_value do |members| members.sort_by { |definition| [-definition.fetch(:uses), definition.fetch(:id)] }.drop(1).each do |definition| id = definition.fetch(:id) next unless levels[id] < MAX_LEVEL levels[id] += 1 progressed = true end end break unless progressed end names = de_greek_names!(names) @registry.apply_names!(names) names end |