29 references to TryGetValue
Microsoft.ML.Tokenizers (29)
Model\BPETokenizer.cs (4)
741private int? MapTokenToId(ReadOnlySpan<char> token) => _vocab.TryGetValue(token, out int value) ? value : null; 1305if (_specialTokens?.TryGetValue(text, out (int specialTokenId, string specialToken) value) is true) 1414if (_specialTokens?.TryGetValue(text, out (int specialTokenId, string specialToken) value) is true && maxTokens > 0) 1496if (_specialTokens?.TryGetValue(text, out (int specialTokenId, string specialToken) value) is true && maxTokens > 0)
Model\CodeGenTokenizer.cs (3)
1554if (_vocab.TryGetValue(token, out (int Id, string Token) value)) 1559if (_specialTokens is not null && _specialTokens.TryGetValue(token, out (int Id, string Token) specialToken)) 1663if (_vocab.TryGetValue(text.Slice(symbols[index].pieceSpan.Index, symbols[index].pieceSpan.Length), out (int Id, string Token) value))
Model\EnglishRobertaTokenizer.cs (1)
757private int? MapTokenToId(ReadOnlySpan<char> token) => _vocab.TryGetValue(token, out int value) ? value : null;
Model\SentencePieceBpeModel.cs (13)
123if (InternalSpecialTokens!.TryGetValue(text.Slice(Offset, Length), out int id)) 168if (_vocab.TryGetValue(text.Slice(symbols[index].pieceSpan.Index, symbols[index].pieceSpan.Length), out (int Id, float Score, byte Type) tokenInfo)) 262if (!_vocab.TryGetValue(text.Slice(pieceSpan.Index, pieceSpan.Length), out (int Id, float Score, byte Type) id)) 383if (idsCount < maxTokens && InternalSpecialTokens!.TryGetValue(text.Slice(Offset, Length), out int id)) 446if (_vocab.TryGetValue(text.Slice(symbols[index].pieceSpan.Index, symbols[index].pieceSpan.Length), out (int Id, float Score, byte Type) tokenInfo)) 568if (!_vocab.TryGetValue(text.Slice(pieceSpan.Index, pieceSpan.Length), out (int Id, float Score, byte Type) id)) 660if (idsCount < maxTokens && InternalSpecialTokens!.TryGetValue(text.Slice(Offset, Length), out int id)) 714if (_vocab.TryGetValue(text.Slice(symbols[index].pieceSpan.Index, symbols[index].pieceSpan.Length), out (int Id, float Score, byte Type) tokenInfo)) 827if (!_vocab.TryGetValue(text.Slice(pieceSpan.Index, pieceSpan.Length), out (int Id, float Score, byte Type) id)) 930if (InternalSpecialTokens!.TryGetValue(text.Slice(current.Offset, current.Length), out int id)) 990if (_vocab.TryGetValue(text.Slice(symbols[index].pieceSpan.Index, symbols[index].pieceSpan.Length), out (int Id, float Score, byte Type) tokenInfo)) 1103if (!_vocab.TryGetValue(text.Slice(pieceSpan.Index, pieceSpan.Length), out (int Id, float Score, byte Type) id)) 1198if (!_vocab.TryGetValue(textSpan.Slice(symbols[left].pieceSpan.Index, pieceLength), out (int Id, float Score, byte Type) leftId))
Model\SentencePieceUnigramModel.cs (4)
235if (InternalSpecialTokens!.TryGetValue(text.Slice(Offset, Length), out int id)) 668if (InternalSpecialTokens!.TryGetValue(text.Slice(Offset, Length), out int id)) 1039if (InternalSpecialTokens!.TryGetValue(text.Slice(Offset, Length), out int id)) 1306if (InternalSpecialTokens!.TryGetValue(text.Slice(current.Offset, current.Length), out int id))
Model\TiktokenTokenizer.cs (4)
317if (_vocab.TryGetValue(text, out (int Id, string Token) mappedId)) 433if (_vocab.TryGetValue(text, out (int Id, string Token) mappedId)) 599if (_vocab.TryGetValue(text, out _)) 725if (_vocab.TryGetValue(text, out _))