25 references to TryGetValue
Microsoft.ML.Tokenizers (25)
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)
1551
if (_vocab.
TryGetValue
(token, out (int Id, string Token) value))
1556
if (_specialTokens is not null && _specialTokens.
TryGetValue
(token, out (int Id, string Token) specialToken))
1681
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\SentencePieceTokenizer.cs (13)
288
if (_specialTokens!.
TryGetValue
(text.Slice(Offset, Length), out int id))
333
if (_vocab.
TryGetValue
(text.Slice(symbols[index].pieceSpan.Index, symbols[index].pieceSpan.Length), out (int Id, float Score, byte Type) tokenInfo))
427
if (!_vocab.
TryGetValue
(text.Slice(pieceSpan.Index, pieceSpan.Length), out (int Id, float Score, byte Type) id))
619
if (idsCount < maxTokens && _specialTokens!.
TryGetValue
(text.Slice(Offset, Length), out int id))
682
if (_vocab.
TryGetValue
(text.Slice(symbols[index].pieceSpan.Index, symbols[index].pieceSpan.Length), out (int Id, float Score, byte Type) tokenInfo))
804
if (!_vocab.
TryGetValue
(text.Slice(pieceSpan.Index, pieceSpan.Length), out (int Id, float Score, byte Type) id))
952
if (idsCount < maxTokens && _specialTokens!.
TryGetValue
(text.Slice(Offset, Length), out int id))
1006
if (_vocab.
TryGetValue
(text.Slice(symbols[index].pieceSpan.Index, symbols[index].pieceSpan.Length), out (int Id, float Score, byte Type) tokenInfo))
1119
if (!_vocab.
TryGetValue
(text.Slice(pieceSpan.Index, pieceSpan.Length), out (int Id, float Score, byte Type) id))
1325
if (_specialTokens!.
TryGetValue
(text.Slice(current.Offset, current.Length), out int id))
1386
if (_vocab.
TryGetValue
(text.Slice(symbols[index].pieceSpan.Index, symbols[index].pieceSpan.Length), out (int Id, float Score, byte Type) tokenInfo))
1499
if (!_vocab.
TryGetValue
(text.Slice(pieceSpan.Index, pieceSpan.Length), out (int Id, float Score, byte Type) id))
2241
if (!_vocab.
TryGetValue
(textSpan.Slice(symbols[left].pieceSpan.Index, pieceLength), out (int Id, float Score, byte Type) leftId))
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 _))