def split_dot(words): dots=[',','.','!','?'] str_data = [] for w in words: ##*****——请在下方补充代码——***** ##*****——请在上方补充代码——***** return(str_data) def get_eng_dicts(datas): w_all_dict = {} for sample in datas: for token in sample.split(" "): ##*****——请在下方补充代码——***** ##*****——请在上方补充代码——***** sort_w_list = sorted(w_all_dict.items(), key=lambda d: d[1], reverse=True) w_keys = [x for x,_ in sort_w_list[:7000-2]] w_keys.insert(0,"<PAD>") w_keys.insert(0,"<UNK>") w_dict = { x:i for i,x in enumerate(w_keys) } i_dict = { i:x for i,x in enumerate(w_keys) } return w_dict,i_dict
时间: 2024-01-17 13:12:49 浏览: 28
split_dot函数中的代码应该是:
```
if w[-1] in dots:
if len(w) == 1:
continue
str_data.append(w[:-1])
str_data.append(w[-1])
else:
str_data.append(w)
```
get_eng_dicts函数中的代码应该是:
```
if token in w_all_dict:
w_all_dict[token] += 1
else:
w_all_dict[token] = 1
```
相关问题
使用Python完善以下代码def split_dot(words): dots=[',','.','!','?'] str_data = [] for w in words: ##*****——请在下方补充代码——***** #如果句末含有四个英文标点符号中的一个,用空格隔开,如果没有则忽略。 if w in dots:
str_data.append(' ') else: str_data.append(w) return ''.join(str_data)
可以使用该函数对字符串进行处理,将句末的英文标点符号与前面的单词分开,便于后续的处理和分析。具体来说,该函数的作用是将传入的字符串 words 中,如果句末含有四个英文标点符号中的一个,用空格隔开,如果没有则忽略。例如:
```python
>>> words = "Hello, world! How are you?"
>>> split_dot(words)
'Hello, world ! How are you ? '
```
在上面的例子中,函数将字符串中的 `,` 和 `!` 和 `?` 判别为句尾标点符号,将其与前面的单词用空格隔开。
swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000"
在微信小程序中,使用swiper组件可以实现轮播图的效果。通过设置swiper的属性,可以控制轮播图的一些行为和样式。在你提供的引用中,swiper组件的属性为:indicator-dots="true",autoplay="true",interval="3000",duration="1000"。其中,indicator-dots表示是否显示面板指示点,将其设置为true时,会在轮播图下方显示小圆点表示当前显示的图片。autoplay表示是否自动切换,设置为true时,轮播图会自动切换图片。interval表示自动切换的时间间隔,单位为毫秒,这里设置为3000,即3秒。duration表示滑动动画的时长,单位为毫秒,这里设置为1000,即1秒。通过设置这些属性,你可以实现indicator-dots为true,autoplay为true,interval为3000,duration为1000的轮播图效果。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [微信小程序 swiper组件轮播图详解及实例](https://download.csdn.net/download/weixin_38747818/13974864)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [微信小程序 swiper组件详解及实例代码](https://download.csdn.net/download/weixin_38624519/13974717)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [自定义修改微信小程序swiper的面板指示点样式(indicator-dots)](https://blog.csdn.net/weixin_44902450/article/details/117367438)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
相关推荐
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)