Skip to content

Public API

This page lists exported symbols of CTBase.Descriptions.


From CTBase.Descriptions

CTBase.Descriptions [Module]

CTBase.Descriptions Module
julia
Descriptions

Description management utilities for CTBase.

This module provides types and functions for working with symbolic descriptions, including type aliases, manipulation functions, and completion utilities.

Organization

The Descriptions module is organized into thematic submodules:

  • types.jl: Core type definitions (DescVarArg, Description)

  • similarity.jl: Similarity computation and intelligent suggestions

  • display.jl: Display utilities for descriptions

  • catalog.jl: Catalog management functions (add, remove)

  • complete.jl: Description completion utilities

Public API

Exported Types

  • DescVarArg: Variable number of symbols type alias

  • Description: Tuple of symbols type alias

Exported Functions

  • add: Add descriptions to a catalog

  • complete: Find matching descriptions with intelligent suggestions

  • remove: Remove symbols from descriptions

DescVarArg [Constant]

CTBase.Descriptions.DescVarArg Constant

A type alias representing a variable number of Symbols.

Example

julia
julia> using CTBase

julia> CTBase.DescVarArg
Vararg{Symbol}

See also: CTBase.Descriptions.Description

Description [Struct]

CTBase.Descriptions.Description Type
julia
struct Tuple{Vararg{Symbol}}

A description is a tuple of symbols, used to declaratively encode algorithms or configurations.

Example

Base.show is overloaded for descriptions, so tuples of descriptions are printed one per line:

julia
julia> using CTBase

julia> display(((:a, :b), (:b, :c)))
(:a, :b)
(:b, :c)

See also: CTBase.Descriptions.DescVarArg

add [Function]

CTBase.Descriptions.add Function
julia
add(
    _::Tuple{},
    y::Tuple{Vararg{Symbol}}
) -> Tuple{Tuple{Vararg{Symbol}}}

Initialize a new description catalog with a single description y.

Arguments

  • y::Description: The initial description to add.

Returns

  • Tuple{Vararg{Description}}: A one-element tuple containing y.

Throws

  • (none)

Example

julia
julia> using CTBase

julia> descriptions = ()
julia> descriptions = CTBase.add(descriptions, (:a,))
(:a,)
julia> print(descriptions)
((:a,),)
julia> descriptions[1]
(:a,)

See also: CTBase.Descriptions.Description, CTBase.Descriptions.complete, CTBase.Descriptions.remove

julia
add(
    x::Tuple{Vararg{Tuple{Vararg{Symbol}}}},
    y::Tuple{Vararg{Symbol}}
) -> Tuple{Tuple{Vararg{Symbol}}}

Add the description y to the catalog x if it is not already present.

Arguments

  • x::Tuple{Vararg{Description}}: Existing description catalog

  • y::Description: Specific description to add

Returns

  • Tuple{Vararg{Description}}: The updated catalog with y appended

Throws

  • IncorrectArgument: If the description y is already contained in x

Example

julia
julia> using CTBase

julia> descriptions = ()
julia> descriptions = CTBase.add(descriptions, (:a,))
(:a,)
julia> descriptions = CTBase.add(descriptions, (:b,))
(:a,)
(:b,)
julia> descriptions = CTBase.add(descriptions, (:b,))
ERROR: IncorrectArgument: the description (:b,) is already in ((:a,), (:b,))
       Got: (:b,)
       Expected: a unique description not in the catalog
       Suggestion: Check existing descriptions before adding, or use a different description
       Context: description catalog management

See also: CTBase.Descriptions.complete, CTBase.Descriptions.remove

complete [Function]

CTBase.Descriptions.complete Function
julia
complete(list::Symbol...; descriptions)

Select the most matching description from a catalog based on a partial list of symbols.

If multiple descriptions contain all the symbols in list, the one with the largest intersection is selected. If multiple descriptions have the same intersection size, the first one in the catalog wins (priority is top-to-bottom).

Arguments

  • list::Symbol...: A variable number of symbols representing a partial description

Keyword Arguments

  • descriptions::Tuple{Vararg{Description}}: A catalog of candidate descriptions

Returns

  • Description: The best-matching description from the catalog

Throws

  • AmbiguousDescription: If the catalog is empty or if no description contains all symbols in list.

Example

julia
julia> using CTBase

julia> D = ((:a, :b), (:a, :b, :c), (:b, :c), (:a, :c))
(:a, :b)
(:b, :c)
(:a, :c)
julia> CTBase.complete(:a; descriptions=D)
(:a, :b)
julia> CTBase.complete(:a, :c; descriptions=D)
(:a, :b, :c)
julia> CTBase.complete((:a, :c); descriptions=D)
(:a, :b, :c)
julia> CTBase.complete(:f; descriptions=D)
ERROR: AmbiguousDescription: the description (:f,) is ambiguous / incorrect
       Description: (:f,)
       Valid candidates:
       - (:a, :b)
       - (:a, :b, :c)
       - (:b, :c)
       - (:a, :c)
       Suggestion: Available descriptions: (:a, :b), (:a, :b, :c), (:b, :c), (:a, :c)
       Context: description completion

See also: CTBase.Descriptions._compute_similarity, CTBase.Descriptions._find_similar_descriptions, CTBase.Descriptions._format_description_candidates, CTBase.Exceptions.AmbiguousDescription

julia
complete(list::Tuple{Vararg{Symbol}}; descriptions)

Convenience overload of complete for tuple inputs.

This method is equivalent to complete(list...; descriptions=descriptions).

Arguments

  • list::Tuple{Vararg{Symbol}}: A tuple of symbols representing a partial description.

Keyword Arguments

  • descriptions::Tuple{Vararg{Description}}: Candidate descriptions used for completion.

Returns

  • Description: A description from descriptions that contains all symbols in list.

Throws

See also: CTBase.Descriptions.complete, CTBase.Exceptions.AmbiguousDescription

remove [Function]

CTBase.Descriptions.remove Function
julia
remove(
    x::Tuple{Vararg{Symbol}},
    y::Tuple{Vararg{Symbol}}
) -> Tuple{Vararg{Symbol}}

Remove symbols from a description tuple.

Arguments

  • x::Description: The source description.

  • y::Description: The symbols to remove from x.

Returns

  • Tuple{Vararg{Symbol}}: The set difference of x and y as a tuple (symbols in x not in y).

Example

julia
julia> using CTBase

julia> CTBase.remove((:a, :b, :c), (:a,))
(:b, :c)

See also: CTBase.Descriptions.add, CTBase.Descriptions.complete