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