當前位置: 首頁>>代碼示例>>Python>>正文


Python tokenization._is_punctuation方法代碼示例

本文整理匯總了Python中tokenization._is_punctuation方法的典型用法代碼示例。如果您正苦於以下問題:Python tokenization._is_punctuation方法的具體用法?Python tokenization._is_punctuation怎麽用?Python tokenization._is_punctuation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tokenization的用法示例。


在下文中一共展示了tokenization._is_punctuation方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_is_punctuation

# 需要導入模塊: import tokenization [as 別名]
# 或者: from tokenization import _is_punctuation [as 別名]
def test_is_punctuation(self):
        self.assertTrue(tokenization._is_punctuation(u"-"))
        self.assertTrue(tokenization._is_punctuation(u"$"))
        self.assertTrue(tokenization._is_punctuation(u"`"))
        self.assertTrue(tokenization._is_punctuation(u"."))

        self.assertFalse(tokenization._is_punctuation(u"A"))
        self.assertFalse(tokenization._is_punctuation(u" ")) 
開發者ID:Socialbird-AILab,項目名稱:BERT-Classification-Tutorial,代碼行數:10,代碼來源:tokenization_test.py

示例2: test_is_punctuation

# 需要導入模塊: import tokenization [as 別名]
# 或者: from tokenization import _is_punctuation [as 別名]
def test_is_punctuation(self):
    self.assertTrue(tokenization._is_punctuation(u"-"))
    self.assertTrue(tokenization._is_punctuation(u"$"))
    self.assertTrue(tokenization._is_punctuation(u"`"))
    self.assertTrue(tokenization._is_punctuation(u"."))

    self.assertFalse(tokenization._is_punctuation(u"A"))
    self.assertFalse(tokenization._is_punctuation(u" ")) 
開發者ID:Nagakiran1,項目名稱:Extending-Google-BERT-as-Question-and-Answering-model-and-Chatbot,代碼行數:10,代碼來源:tokenization_test.py

示例3: customize_tokenizer

# 需要導入模塊: import tokenization [as 別名]
# 或者: from tokenization import _is_punctuation [as 別名]
def customize_tokenizer(text, do_lower_case=False):
  tokenizer = tokenization.BasicTokenizer(do_lower_case=do_lower_case)
  temp_x = ""
  text = tokenization.convert_to_unicode(text)
  for c in text:
    if tokenizer._is_chinese_char(ord(c)) or tokenization._is_punctuation(c) or tokenization._is_whitespace(c) or tokenization._is_control(c):
      temp_x += " " + c + " "
    else:
      temp_x += c
  if do_lower_case:
    temp_x = temp_x.lower()
  return temp_x.split()

# 
開發者ID:ymcui,項目名稱:Cross-Lingual-MRC,代碼行數:16,代碼來源:run_clmrc.py


注:本文中的tokenization._is_punctuation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。