29 references to TryGetValue
Microsoft.ML.Tokenizers (29)
Model\BPETokenizer.cs (4)
589
private int? MapTokenToId(ReadOnlySpan<char> token) => _vocab.
TryGetValue
(token, out int value) ? value : null;
983
if (_specialTokens?.
TryGetValue
(text, out (int specialTokenId, string specialToken) value) is true)
1057
if (_specialTokens?.
TryGetValue
(text, out (int specialTokenId, string specialToken) value) is true && maxTokens > 0)
1092
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))
1684
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)
169
if (InternalSpecialTokens!.
TryGetValue
(text.Slice(Offset, Length), out int id))
214
if (_vocab.
TryGetValue
(text.Slice(symbols[index].pieceSpan.Index, symbols[index].pieceSpan.Length), out (int Id, float Score, byte Type) tokenInfo))
308
if (!_vocab.
TryGetValue
(text.Slice(pieceSpan.Index, pieceSpan.Length), out (int Id, float Score, byte Type) id))
429
if (idsCount < maxTokens && InternalSpecialTokens!.
TryGetValue
(text.Slice(Offset, Length), out int id))
492
if (_vocab.
TryGetValue
(text.Slice(symbols[index].pieceSpan.Index, symbols[index].pieceSpan.Length), out (int Id, float Score, byte Type) tokenInfo))
614
if (!_vocab.
TryGetValue
(text.Slice(pieceSpan.Index, pieceSpan.Length), out (int Id, float Score, byte Type) id))
706
if (idsCount < maxTokens && InternalSpecialTokens!.
TryGetValue
(text.Slice(Offset, Length), out int id))
760
if (_vocab.
TryGetValue
(text.Slice(symbols[index].pieceSpan.Index, symbols[index].pieceSpan.Length), out (int Id, float Score, byte Type) tokenInfo))
873
if (!_vocab.
TryGetValue
(text.Slice(pieceSpan.Index, pieceSpan.Length), out (int Id, float Score, byte Type) id))
976
if (InternalSpecialTokens!.
TryGetValue
(text.Slice(current.Offset, current.Length), out int id))
1036
if (_vocab.
TryGetValue
(text.Slice(symbols[index].pieceSpan.Index, symbols[index].pieceSpan.Length), out (int Id, float Score, byte Type) tokenInfo))
1149
if (!_vocab.
TryGetValue
(text.Slice(pieceSpan.Index, pieceSpan.Length), out (int Id, float Score, byte Type) id))
1244
if (!_vocab.
TryGetValue
(textSpan.Slice(symbols[left].pieceSpan.Index, pieceLength), out (int Id, float Score, byte Type) leftId))
Model\SentencePieceUnigramModel.cs (4)
285
if (InternalSpecialTokens!.
TryGetValue
(text.Slice(Offset, Length), out int id))
718
if (InternalSpecialTokens!.
TryGetValue
(text.Slice(Offset, Length), out int id))
1089
if (InternalSpecialTokens!.
TryGetValue
(text.Slice(Offset, Length), out int id))
1356
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 _))