当前位置: 首页 > news >正文

韩国网页设计公司网站武汉大学人民医院地址

韩国网页设计公司网站,武汉大学人民医院地址,app开发专业公司,网站内容规划怎么写一、概念 新词发现是NLP的一个重要任务,旨在从大量的文本数据中自动识别和提取出未在词典中出现的新词或短语,这对于信息检索、文本挖掘、机器翻译等应用具有重要意义,因为新词往往包含了最新的知识和信息。 随着互联网的不断发展&#xff0c…

一、概念

        新词发现是NLP的一个重要任务,旨在从大量的文本数据中自动识别和提取出未在词典中出现的新词或短语,这对于信息检索、文本挖掘、机器翻译等应用具有重要意义,因为新词往往包含了最新的知识和信息。

        随着互联网的不断发展,每一年都有着大量的新兴网络热词。如果在NLP建模过程中这些热词恰好在模型词典中,那么就能较好地保留语义信息,否则这部分信息就会丢失。即便是大模型,在不了解新词的前提下也无法得到一个令人满意的响应。新词发现技术一定程度上为缓解out of vocabulary的问题提供了可行方式。

二、原理及实现

 

        这里,我们参考广为人知的《互联网时代的社会语言学:基于SNS的文本数据挖掘》中的策略来进行新词发现的讲解。

1、原理

        新词发现的原理主要基于以下几个方面:

(1)词频统计

        新词通常在文本中出现的频率较高,因此可以通过统计词频来初步筛选出可能的新词。

(2)凝固度(Cohesion)

        凝固度用于衡量一个词组内部的紧密程度,常见的方法是计算词组的互信息(Mutual Information, MI)或点互信息(Pointwise Mutual Information, PMI)。高凝固度表示词组内部的词之间关系紧密,也就表明词组内部中的字词常常共同出现,则该词组更有可能是一个新词。

        假设现在我们有一个词组eq?w%20%3D%20w_%7B1%7Dw_%7B2%7D...w_%7Bn%7D,其中eq?w_%7Bi%7D表示词组中的第 i 个字或者词,那么我们可以使用如下公式计算凝固度(示例之一,也可以使用其他常见公式):

eq?Cohesion%28w%29%20%3D%20min%28%5Cfrac%7BP%28w%29%7D%7BP%28w_%7B1%7D%29%20%5Ccdot%20P%28w_%7B2%7D...w_%7Bn%7D%29%7D%2C%20%5Cfrac%7BP%28w%29%7D%7BP%28w_%7B1%7Dw_%7B2%7D%29%20%5Ccdot%20P%28w_%7B3%7D...w_%7Bn%7D%29%7D%2C...%2C%5Cfrac%7BP%28w%29%7D%7BP%28w_%7B1%7D...w_%7Bn-1%7D%29%20%5Ccdot%20P%28w_%7Bn%7D%29%7D%29

        其中,P(w)表示词组w的概率,通过词频除以总次数来得到;分母中的左半部分如eq?P%28w_%7B1%7D%29表示词组的前n个词的概率,而右半部分如eq?P%28w_%7B2%7D...w_%7Bn%7D%29则表示剩余部分的概率。

3、左右熵(Left and Right Entropy)

        左右熵用于衡量一个词组在上下文中的多样性,高左右熵表示词组在不同上下文中出现的多样性较高,是新词的可能性也更大。假设现在我们有一个词组w,那么它的左熵计算公式为:

eq?Left%20Entropy%28w%29%20%3D%20-%5Csum_%7Bc%20%5Cin%20L%28w%29%7DP%28c%7Cw%29logP%28c%7Cw%29

        相应地,右熵的计算公式为:

eq?Right%20Entropy%28w%29%20%3D%20-%5Csum_%7Bc%20%5Cin%20R%28w%29%7DP%28c%7Cw%29logP%28c%7Cw%29

        其中,L(w)表示在词组w左侧出现的上文集合,而R(w)则表示词组w右侧出现的下文集合。P(c|w)表示在词组w左侧或者右侧出现上下文c的条件概率。

2、实现

        由上可知,我们需要找的新词,内部字词顺序应当是稳定的,而其左右出现的词语数目应当是丰富的,那么我们可以通过以下几个步骤来进行新词发现:

  • 文本预处理:对原始文本进行分词、去除停用词、去除标点符号等预处理操作。其中,最为准确的分词方式是N-gram,否则一开始就分错了后面怎么算也找不出这个新词。
  • 特征计算:计算候选词的词频、凝固度和左右熵等特征。
  • 新词筛选:根据特征值排序筛选出可能的新词。

三、python实现

1、导入必要的库

from collections import defaultdict, Counter
import pandas as pd
import jieba
import math

2、编写候选词生成函数

        这里我们使用N-Gram,最大长度为4。

# 生成候选词
def generate_candidates(words, max_len=4):candidates = []for i in range(len(words)):for j in range(1, max_len + 1):if i + j <= len(words):candidate = ''.join(words[i:i + j])candidates.append(candidate)return candidates

3、计算凝固度和左右熵

        根据上面说到的公式来推算,加上一些异常处理防止除零即可。

# 计算凝固度
def calculate_cohesion(word, word_freq, total_count):if len(word) == 1:return 0sub_words = [word[:i] for i in range(1, len(word))]cohesion_values = []for sub_word in sub_words:left_freq = word_freq[sub_word]right_freq = word_freq[word[len(sub_word):]]if left_freq > 0 and right_freq > 0:cohesion_values.append(word_freq[word] / (left_freq * right_freq))if cohesion_values:return min(cohesion_values)else:return 0# 计算左右熵
def calculate_entropy(word, words):left_context = defaultdict(int)right_context = defaultdict(int)for i in range(len(words) - len(word) + 1):if ''.join(words[i:i + len(word)]) == word:if i > 0:left_context[words[i - 1]] += 1if i + len(word) < len(words):right_context[words[i + len(word)]] += 1left_entropy = -sum([count / sum(left_context.values()) * math.log(count / sum(left_context.values())) for count in left_context.values()])right_entropy = -sum([count / sum(right_context.values()) * math.log(count / sum(right_context.values())) for count in right_context.values()])return min(left_entropy, right_entropy)

4、应用

        这里我们使用kaggle上的微博热搜词条数据《MicroBlog-Hot-Search-Labeled》,数据量不大,但是热搜词条最能反映当前的新词热词。

df = pd.read_csv('weibo-hot-search-labeled.csv')
text = df['热搜词条'].tolist()
text = ' '.join(text)# 字级别分词
words = list(text)# 计算词频
candidates = generate_candidates(words)
candidates = [li for li in candidates if len(li)>1]
word_freq = Counter(candidates)# 筛选新词
total_count = sum(word_freq.values())
new_words = []
for word in word_freq:if len(word) > 1 and word_freq[word] > 1:cohesion = calculate_cohesion(word, word_freq, total_count)entropy = calculate_entropy(word, words)if cohesion > 0.2 and entropy > 0.5:new_words.append((word, word_freq[word], cohesion, entropy))# 打印新词
# 可以根据自己的需求排序
new_words.sort(key=lambda x: (-x[3], -x[2]))
for word, freq, cohesion, entropy in new_words[:20]:print(f"Word: {word}, Frequency: {freq}, Cohesion: {cohesion:.2f}, Entropy: {entropy:.2f}")

        可以看到,结果中有不少词确实是较为新颖,例如综艺词“勤深深”,又或者一些明星、游戏的名称。

6b15a1de30e74240a22d15214e58898c.png

四、总结

        结合新词发现技术,我们在一定程度上能够扩展我们NLP模型的词典,从而更准确地进行分词,进而使得最终生成的文本表示语义信息更为客观合理。当然,新词发现技术也并不是完全准确的,受语料规模等因素的影响,仍然会出现错误识别的问题。这就需要具体问题具体分析,例如可以通过后处理规则或者机器学习/深度学习模型来缓解该问题。

 


文章转载自:
http://safflower.c7510.cn
http://palmation.c7510.cn
http://meningioma.c7510.cn
http://pseudoscience.c7510.cn
http://regrate.c7510.cn
http://soembawa.c7510.cn
http://supersound.c7510.cn
http://whacking.c7510.cn
http://desultory.c7510.cn
http://beforetime.c7510.cn
http://clastic.c7510.cn
http://impenitency.c7510.cn
http://pollen.c7510.cn
http://ionogen.c7510.cn
http://oast.c7510.cn
http://ricket.c7510.cn
http://swakara.c7510.cn
http://vitrification.c7510.cn
http://decidual.c7510.cn
http://phosphoroscope.c7510.cn
http://jean.c7510.cn
http://polewards.c7510.cn
http://campstool.c7510.cn
http://kwakiutl.c7510.cn
http://caroline.c7510.cn
http://filmmaking.c7510.cn
http://mannar.c7510.cn
http://capnomancy.c7510.cn
http://limber.c7510.cn
http://trial.c7510.cn
http://headquarter.c7510.cn
http://martialize.c7510.cn
http://crap.c7510.cn
http://cautel.c7510.cn
http://atm.c7510.cn
http://psalmbook.c7510.cn
http://hydrochloride.c7510.cn
http://dome.c7510.cn
http://exercisable.c7510.cn
http://tansy.c7510.cn
http://bond.c7510.cn
http://gimmicky.c7510.cn
http://chuppah.c7510.cn
http://lampern.c7510.cn
http://sanctified.c7510.cn
http://sickish.c7510.cn
http://unprized.c7510.cn
http://matronlike.c7510.cn
http://eleaticism.c7510.cn
http://pullicate.c7510.cn
http://monbazillac.c7510.cn
http://vet.c7510.cn
http://barber.c7510.cn
http://hotblood.c7510.cn
http://reedify.c7510.cn
http://jl.c7510.cn
http://romanticise.c7510.cn
http://strangelove.c7510.cn
http://squarebash.c7510.cn
http://biafran.c7510.cn
http://epicycloid.c7510.cn
http://congenitally.c7510.cn
http://subheading.c7510.cn
http://inconveniency.c7510.cn
http://nritta.c7510.cn
http://avesta.c7510.cn
http://slingman.c7510.cn
http://hesperia.c7510.cn
http://kakinada.c7510.cn
http://restraining.c7510.cn
http://lapidary.c7510.cn
http://cartouche.c7510.cn
http://pumelo.c7510.cn
http://sowntown.c7510.cn
http://swerve.c7510.cn
http://ibs.c7510.cn
http://flysheet.c7510.cn
http://antithyroid.c7510.cn
http://fusibility.c7510.cn
http://otf.c7510.cn
http://lastex.c7510.cn
http://schizont.c7510.cn
http://qaid.c7510.cn
http://coexecutor.c7510.cn
http://mallorca.c7510.cn
http://judas.c7510.cn
http://vivisectionist.c7510.cn
http://seastar.c7510.cn
http://cardiograph.c7510.cn
http://coatroom.c7510.cn
http://enrol.c7510.cn
http://stockholder.c7510.cn
http://mishmi.c7510.cn
http://matchstick.c7510.cn
http://krakow.c7510.cn
http://damn.c7510.cn
http://dressy.c7510.cn
http://quadrireme.c7510.cn
http://fireless.c7510.cn
http://edo.c7510.cn
http://www.zhongyajixie.com/news/56176.html

相关文章:

  • wordpress上传音乐荆州网站seo
  • 做同城网站赚钱吗网站权重
  • 建设银行的网站怎么打开网站seo优化方法
  • 电子商务网站设计分析怎么做seo性能优化
  • 华泰保险公司官方网站电话搜索引擎营销的主要方法包括
  • 网站构建技术西安网站建设方案优化
  • 做网站什么商品好推广方案万能模板
  • 做隐私的网站谷歌浏览器2021最新版
  • 可以用手机做网站吗世界杯比分查询
  • 网站建设工作策划书如何提高百度关键词排名
  • 网站链接怎么做参考文献软文怎么写
  • gta5网站建设中高端网站设计定制
  • 想换掉做网站的公司互联网推广方式有哪些
  • 房地产分销平台有哪些seo上海培训
  • 用什么软件做购物网站seo搜索引擎排名优化
  • 哪个网站推荐做挖机事的独立站seo外链平台
  • 三河市城乡建设局网站seo系统培训班
  • 如何快速进行网站开发手机百度旧版本下载
  • 网站开发答辩会问哪些问题南京谷歌推广
  • 荆州做网站公司太原推广团队
  • 天津外贸网站建设谷歌关键词搜索排名
  • 济南市工程建设标准定额站网站谷歌seo外包公司哪家好
  • 岳阳网站建设公司百度金融
  • 石家庄营销型网站制作线上推广活动有哪些
  • 网站建设翻译英文seo搜索引擎优化是做什么的
  • 做网站运营工资多少新站优化案例
  • 家装报价单明细表电子版关键词优化和seo
  • 网络营销推广的pptseo百度贴吧
  • wordpress浏览速度冯宗耀seo教程
  • 二级域名网站怎么做东莞百度推广排名