Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

tanli-github/homework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

2 Commits

Repository files navigation

homework

from IPython.core.display import HTML import jieba

def word_match(words, title): ifmatch = True keyword_ = ' '.join(jieba.cut(words)) for word in keyword_.split(): if word != ' 'and word not in title: ifmatch = False return ifmatch

query = '苹果 and (芯片 or 高通)' query_new_parts = [] for part in list(jieba.cut(query)): if part == '(' or part == ')': query_new_parts.append(part) elif part in ('and', 'AND', 'or', 'OR', 'NOT', 'not', ' '): query_new_parts.append(part.lower()) else: query_new_parts.append("word_match('{}',title)".format(part)) query_new = ''.join(query_new_parts)

for title in title_list: if eval(query_new): for part in list(jieba.cut(query)): if part not in ('(',')','and', 'AND', 'or', 'OR', 'NOT', 'not', ' '): title = title.replace(part, '{}'.format(part)) display(HTML(title))

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

AltStyle によって変換されたページ (->オリジナル) /