MCPcopy Create free account
hub / github.com/THUDM/GLM / sentence_tokenize

Method sentence_tokenize

data_utils/datasets.py:937–942  ·  view source on GitHub ↗

tokenize sentence and get token types

(self, sent, sentence_num=0, beginning=False, ending=False)

Source from the content-addressed store, hash-verified

935 return rtn
936
937 def sentence_tokenize(self, sent, sentence_num=0, beginning=False, ending=False):
938 """tokenize sentence and get token types"""
939 tokens = self.tokenizer.EncodeAsIds(sent).tokenization
940 str_type = 'str' + str(sentence_num)
941 token_types = [self.tokenizer.get_type(str_type).Id] * len(tokens)
942 return tokens, token_types
943
944 def get_doc(self, idx):
945 """gets text of document corresponding to idx"""

Callers 1

Calls 2

get_typeMethod · 0.80
EncodeAsIdsMethod · 0.45

Tested by

no test coverage detected