• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python nlp_utils._tokenize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utils.nlp_utils._tokenize函数的典型用法代码示例。如果您正苦于以下问题:Python _tokenize函数的具体用法?Python _tokenize怎么用?Python _tokenize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了_tokenize函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: transform_one

 def transform_one(self, obs, target, id):
     obs_tokens = nlp_utils._tokenize(obs, token_pattern)
     target_tokens = nlp_utils._tokenize(target, token_pattern)
     obs_ngrams = ngram_utils._ngrams(obs_tokens, self.ngram)
     target_ngrams = ngram_utils._ngrams(target_tokens, self.ngram)
     pos_list = _inter_norm_pos_list(obs_ngrams, target_ngrams)
     return pos_list
开发者ID:amsqr,项目名称:Kaggle_HomeDepot,代码行数:7,代码来源:feature_intersect_position.py


示例2: transform_one

 def transform_one(self, obs, target, id):
     obs_tokens = nlp_utils._tokenize(obs, token_pattern)
     target_tokens = nlp_utils._tokenize(target, token_pattern)
     obs_ngrams = ngram_utils._ngrams(obs_tokens, self.ngram)
     target_ngrams = ngram_utils._ngrams(target_tokens, self.ngram)
     s = 0.
     for w1 in obs_ngrams:
         for w2 in target_ngrams:
             if dist_utils._is_str_match(w1, w2, self.str_match_threshold):
                 s += 1.
     return np_utils._try_divide(s, len(obs_ngrams)*len(target_ngrams))
开发者ID:MrSnark,项目名称:Kaggle_HomeDepot,代码行数:11,代码来源:feature_intersect_count.py


示例3: transform_one

 def transform_one(self, obs, target, id):
     obs_tokens = nlp_utils._tokenize(obs, token_pattern)
     target_tokens = nlp_utils._tokenize(target, token_pattern)
     obs_ngrams = ngram_utils._ngrams(obs_tokens, self.ngram)
     target_ngrams = ngram_utils._ngrams(target_tokens, self.ngram)
     val_list = []
     for w1 in obs_ngrams:
         s = 0.
         for w2 in target_ngrams:
             if dist_utils._is_str_match(w1, w2, self.str_match_threshold):
                 s += 1.
         val_list.append(np_utils._try_divide(s, len(target_ngrams)))
     if len(val_list) == 0:
         val_list = [config.MISSING_VALUE_NUMERIC]
     return val_list
开发者ID:amsqr,项目名称:Kaggle_HomeDepot,代码行数:15,代码来源:feature_stat_cooc_tfidf.py


示例4: transform_one

 def transform_one(self, obs, target, id):
     df = self.dfTrain[self.dfTrain["search_term"] == obs].copy()
     val_list = [config.MISSING_VALUE_NUMERIC]
     if df is not None:
         df = df[df["id"] != id].copy()
         df = df[df["relevance"] == self.relevance].copy()
         if df is not None and df.shape[0] > 0:
             target_tokens = nlp_utils._tokenize(target, token_pattern)
             target_ngrams = ngram_utils._ngrams(target_tokens, self.ngram)
             val_list = []
             for x in df[self.target_field]:
                 x_tokens = nlp_utils._tokenize(x, token_pattern)
                 x_ngrams = ngram_utils._ngrams(x_tokens, self.ngram)
                 val_list.append(dist_utils._jaccard_coef(x_ngrams, target_ngrams))
     return val_list
开发者ID:MrSnark,项目名称:Kaggle_HomeDepot,代码行数:15,代码来源:feature_group_distance.py


示例5: transform_one

 def transform_one(self, obs, target, id):
     obs_tokens = nlp_utils._tokenize(obs, token_pattern)
     counter = Counter(obs_tokens)
     count = np.asarray(list(counter.values()))
     proba = count/np.sum(count)
     entropy = -np.sum(proba*np.log(proba))
     return entropy
开发者ID:amsqr,项目名称:Kaggle_HomeDepot,代码行数:7,代码来源:feature_basic.py


示例6: _get_avg_ngram_doc_len

 def _get_avg_ngram_doc_len(self):
     lst = []
     for target in self.target_corpus:
         target_tokens = nlp_utils._tokenize(target, token_pattern)
         target_ngrams = ngram_utils._ngrams(target_tokens, self.ngram)
         lst.append(len(target_ngrams))
     return np.mean(lst)
开发者ID:amsqr,项目名称:Kaggle_HomeDepot,代码行数:7,代码来源:feature_stat_cooc_tfidf.py


示例7: __iter__

 def __iter__(self):
     for column in self.columns:
         for sentence in self.df[column]:
             if not sentence in self.sent_label:
                 self.cnt += 1
                 self.sent_label[sentence] = "SENT_%d"%self.cnt
             tokens = nlp_utils._tokenize(sentence, token_pattern)
             yield LabeledSentence(words=tokens, tags=[self.sent_label[sentence]])
开发者ID:Anhmike,项目名称:Kaggle_HomeDepot,代码行数:8,代码来源:embedding_trainer.py


示例8: transform_one

 def transform_one(self, obs, target, id):
     obs_tokens = nlp_utils._tokenize(obs, token_pattern)
     target_tokens = nlp_utils._tokenize(target, token_pattern)
     obs_ngrams = ngram_utils._ngrams(obs_tokens, self.ngram)
     target_ngrams = ngram_utils._ngrams(target_tokens, self.ngram)
     val_list = []
     for w1 in obs_ngrams:
         _val_list = []
         for w2 in target_ngrams:
             s = dist_utils._edit_dist(w1, w2)
             _val_list.append(s)
         if len(_val_list) == 0:
             _val_list = [ config.MISSING_VALUE_NUMERIC ]
         val_list.append( _val_list )
     if len(val_list) == 0:
         val_list = [ [config.MISSING_VALUE_NUMERIC] ]
     return val_list
开发者ID:Anhmike,项目名称:Kaggle_HomeDepot,代码行数:17,代码来源:feature_distance.py


示例9: transform_one

 def transform_one(self, obs, target, id):
     obs_tokens = nlp_utils._tokenize(obs, token_pattern)
     target_tokens = nlp_utils._tokenize(target, token_pattern)
     obs_synset_list = [wn.synsets(obs_token) for obs_token in obs_tokens]
     target_synset_list = [wn.synsets(target_token) for target_token in target_tokens]
     val_list = []
     for obs_synset in obs_synset_list:
         _val_list = []
         for target_synset in target_synset_list:
             _s = self._maximum_similarity_for_two_synset_list(obs_synset, target_synset)
             _val_list.append(_s)
         if len(_val_list) == 0:
             _val_list = [config.MISSING_VALUE_NUMERIC]
         val_list.append( _val_list )
     if len(val_list) == 0:
         val_list = [[config.MISSING_VALUE_NUMERIC]]
     return val_list
开发者ID:amsqr,项目名称:Kaggle_HomeDepot,代码行数:17,代码来源:feature_wordnet_similarity.py


示例10: transform_one

 def transform_one(self, obs, target, id):
     val_list = []
     obs_tokens = nlp_utils._tokenize(obs, token_pattern)
     target_tokens = nlp_utils._tokenize(target, token_pattern)
     for obs_token in obs_tokens:
         _val_list = []
         if obs_token in self.model:
             for target_token in target_tokens:
                 if target_token in self.model:
                     sim = dist_utils._cosine_sim(self.model[obs_token], self.model[target_token]) 
                     _val_list.append(sim)
         if len(_val_list) == 0:
             _val_list = [config.MISSING_VALUE_NUMERIC]
         val_list.append( _val_list )
     if len(val_list) == 0:
         val_list = [[config.MISSING_VALUE_NUMERIC]]
     return val_list
开发者ID:Anhmike,项目名称:Kaggle_HomeDepot,代码行数:17,代码来源:feature_word2vec.py


示例11: _get_df_dict

 def _get_df_dict(self):
     # smoothing
     d = defaultdict(lambda : 1)
     for target in self.target_corpus:
         target_tokens = nlp_utils._tokenize(target, token_pattern)
         target_ngrams = ngram_utils._ngrams(target_tokens, self.ngram)
         for w in set(target_ngrams):
             d[w] += 1
     return d
开发者ID:amsqr,项目名称:Kaggle_HomeDepot,代码行数:9,代码来源:feature_stat_cooc_tfidf.py


示例12: transform_one

 def transform_one(self, obs, target, id):
     obs_tokens = nlp_utils._tokenize(obs, token_pattern)
     target_tokens = nlp_utils._tokenize(target, token_pattern)
     obs_ngrams = ngram_utils._ngrams(obs_tokens, self.ngram)
     target_ngrams = ngram_utils._ngrams(target_tokens, self.ngram)
     return np_utils._try_divide(self._get_match_count(obs_ngrams, target_ngrams, self.idx), len(target_ngrams))
开发者ID:amsqr,项目名称:Kaggle_HomeDepot,代码行数:6,代码来源:feature_first_last_ngram.py



注:本文中的utils.nlp_utils._tokenize函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python on_error.report函数代码示例发布时间:2022-05-26
下一篇:
Python ngram_utils._ngrams函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap