查看: 3969| 回复: 17
跳转到指定楼层
上一主题 下一主题
收起左侧

[入门|算法|数据结构] UCSD OOP in Java 第二门课第一周作业请教

全局:
公开课
学校名称: UCSD
Unit号: 1
开课时间: 2015-10-26
课程全名: Data structures: Measuring and Optimizing Performance
平台: Coursera

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
怎么用正则表达式来求得音节数呢?public int getNumSyllables()

This method counts and returns the total number of syllables in the document (the stored text). To count the number of syllables in a word, you should use the rule that every contiguous sequence of one or more vowels, except for a lone “e” at the end of a word if the word has another vowel or set of contiguous vowels, makes up one syllable. You should consider y a vowel. Under these rules the words “the”, “fly”, “yes”, “cave” and “double” all have 1 syllable, but "segue" has two syllables. Notice that this isn’t exactly correct (“double” actually has 2 syllables), but it’s close enough for our purposes. Here are some more examples with the number of syllables your method should return to help you: "contiguous" (3 syllables), "sleepy" (2 syllables), "obvious" (2 syllables), "toga" (2 syllables). Notice that our rules get a lot wrong, especially when you have more than 2 vowels in a row, but these are the rules we will test you against.



评分

参与人数 1大米 +1 收起 理由
bibn610 + 1 微信Q997579679办文凭毕业证成绩单学历认证

查看全部评分


上一篇:Hadoop course by UCSD Week 1
下一篇:学algorithm的quiz做不出来呀
推荐
hsj920408 2015-10-31 15:43:03 | 只看该作者
全局:
vowel 用regex 就可以表示了。作业还没做,不过可以大概说一下。
match 一下[a|e|i|o|u]+ 看返回多少个token 就是有多少个syllables, 当然还有一些edge case, 比如题目说的lone "e" at the end。这些edge case 楼主自己加下就好。
作业被锁太差了,感觉coursera 想赚钱想疯了...
回复

使用道具 举报

推荐
zequan 2015-11-3 04:28:11 | 只看该作者
全局:
liusicong999 发表于 2015-11-2 13:23
你能说说你是怎么做的嘛。。

我就说我是学生,很穷,没钱交学费,一定会认真上课,和同学互帮互助。。。
差不多这样,就是瞎扯。
一提交就显示已经enroll了,完全不用等。 不知懂这算是申请成功了吗?反正我也不在乎有没有证书
回复

使用道具 举报

推荐
nwzqx0815 2015-11-3 04:43:23 | 只看该作者
全局:
zequan 发表于 2015-11-3 04:21
没交钱是怎么enroll的?
我是申请financial aid的,可以提交。很容易申请。。我总共写了不到10句话。

不交钱就能enroll,没有任何问题。我从来都是到完成所有作业,确定分数够通过再交钱买证书的
回复

使用道具 举报

🔗
cynthiazp 2015-10-30 12:16:46 | 只看该作者
全局:
作业被锁了,无法提交
回复

使用道具 举报

🔗
 楼主| liusicong999 2015-10-30 12:44:24 | 只看该作者
全局:
cynthiazp 发表于 2015-10-30 12:16
作业被锁了,无法提交

你是怎么做的呢?能否详细交流
回复

使用道具 举报

🔗
 楼主| liusicong999 2015-10-31 22:47:14 | 只看该作者
全局:
hsj920408 发表于 2015-10-31 15:43
vowel 用regex 就可以表示了。作业还没做,不过可以大概说一下。
match 一下[a|e|i|o|u]+ 看返回多少个to ...

没有被锁啊,还是可以提交啊
回复

使用道具 举报

🔗
hsj920408 2015-11-1 06:11:51 | 只看该作者
全局:
liusicong999 发表于 2015-10-31 22:47
没有被锁啊,还是可以提交啊

没交钱好像是不能submiy了
回复

使用道具 举报

🔗
zequan 2015-11-3 04:21:20 | 只看该作者
全局:
hsj920408 发表于 2015-10-31 15:11
没交钱好像是不能submiy了

没交钱是怎么enroll的?
我是申请financial aid的,可以提交。很容易申请。。我总共写了不到10句话。
回复

使用道具 举报

🔗
 楼主| liusicong999 2015-11-3 04:23:34 | 只看该作者
全局:
zequan 发表于 2015-11-3 04:21
没交钱是怎么enroll的?
我是申请financial aid的,可以提交。很容易申请。。我总共写了不到10句话。

你能说说你是怎么做的嘛。。
回复

使用道具 举报

🔗
nwzqx0815 2015-11-3 04:42:05 | 只看该作者
全局:
1. 匹配每个单词里所有的aeiouy,并且记录匹配出的个数count
2. 如果这个单词字母个数>1 && count>1 && 最后一个字母是e && 倒数第二个字母不是aeiouy,count--
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表