ticker_sniffer/
types.rs

1use std::collections::HashMap;
2
3// Types listed here are either shared across multiple files and/or exposed via the library.
4
5/// Represents a token as an owned `String`. Tokens are the basic units used for processing text.
6pub type Token = String;
7
8/// Represents a borrowed view of a token as a `str`. This is used when ownership is not required.
9pub type TokenRef = str;
10
11/// Represents the numeric Unicode scalar value (`char`) of a token's character.
12///
13/// Each character in a token is converted to its corresponding Unicode scalar
14/// value (`char`), which is stored as a `u32`. This type is used for better
15/// semantic clarity in representing character codes of tokens.
16pub type TokenCharCode = u32;
17
18/// A vector of token character codes, represented as `u32` values.
19pub type TokenVector = Vec<TokenCharCode>;
20
21/// A unique identifier for a token, represented as a `usize`. This identifier is
22/// used for a static mapping between a token (e.g., a word or symbol) and its
23/// associated data in structures like `HashMap` or `Vec`.
24///
25/// Unlike a query token index, which refers to a position-based index during
26/// runtime queries, a `TokenId` is a persistent, position-independent value
27/// that serves as a reference to a specific token. It does not imply or rely
28/// on index positioning within any particular data structure.
29pub type TokenId = usize;
30
31/// Represents the name of a company as an owned `String`.
32pub type CompanyName = String;
33
34/// Represents an alternate name for a company as an owned `String`. These are used to match
35/// variations in naming conventions or aliases for companies.
36pub type AlternateCompanyName = String;
37
38/// A list of company symbols, where each entry includes:
39/// - `TickerSymbol`: The company's stock ticker.
40/// - `Option<CompanyName>`: The company's primary name (optional if not available).
41/// - `Vec<AlternateCompanyName>`: A list of alternate names or aliases for the company.
42pub type CompanySymbolList = Vec<(TickerSymbol, Option<CompanyName>, Vec<AlternateCompanyName>)>;
43
44/// Represents a ticker symbol (e.g., stock ticker) as an owned `String`.
45pub type TickerSymbol = String;
46
47/// Represents the total number occurrences of a ticker symbol within a text document.
48pub type TickerSymbolFrequency = usize;
49
50/// Represents a map of ticker symbols to their frequency counts within a text document.
51/// The key is the `TickerSymbol`, and the value is the `TickerSymbolFrequency`.
52pub type TickerSymbolFrequencyMap = HashMap<TickerSymbol, TickerSymbolFrequency>;
53
54/// Represents a word number in a text document after non-sequence words have been filtered out.
55pub type QueryTokenIndex = usize;
56
57// Represents a sequence number of a company name or alias.
58pub type CompanySequenceIndex = usize;
59
60// Represents a word number in a company name or alias.
61pub type CompanySequenceTokenIndex = usize;
62
63// Represents the token ID of a ticker symbol.
64pub type TickerSymbolTokenId = TokenId;