pmp 成本估算准确高_如何更准确地估算JavaScript中文章的阅读时间

pmp 成本估算准确高

by Pritish Vaidya

通过Pritish Vaidya

准确估算JavaScript中篇文章的阅读时间 (Accurate estimation of read time for Medium articles in JavaScript)

介绍 (Introduction)

Read Time Estimate is the estimation of the time taken by the reader to read an article. It has been a part of Medium’s core features since it launched in 2013.

阅读时间估算是读者阅读文章所花费时间的估算。 自2013年推出以来,它一直是Medium核心功能的一部分。

As explained in the New Yorker:

《纽约客》中所述

The more we know about something — including precisely how much time it will consume — the greater the chance we will commit to it.
我们对某事了解得越多-确切地包括它将消耗多少时间-我们致力于该事的机会就越大。

Knowing in advance how long an article will take to read helps with better time management by allowing us to plan further ahead.

提前知道一篇文章将花费多长时间,可以使我们提前计划,从而有助于更好地管理时间。

为什么要使用新脚本? (Why should I use a new script?)

Yes, there are many open source libraries available on npm but they contain several flaws.

是的, npm上有很多开源库 但它们包含一些缺陷。

Before that, let’s take a look at these two articles on Medium.

在此之前,让我们看一下有关Medium的这两篇文章。

  • Read Time — Medium Support

    读取时间-中度支持

  • Read Time and You

    阅读时间和你

The above two articles have the following key features

上面的两篇文章具有以下主要功能

  • Average Read Time (English) — 265 Words per min

    平均阅读时间(英语)—每分钟265个单词
  • Average Read Time (Chinese, Japanese and Korean) — 500 Characters/min

    平均阅读时间(中文,日文和韩文)-500个字符/分钟
  • Image Read Time — 12 seconds for the first image, 11 for the second, and minus an additional second for each subsequent image. Other images counted at 3 seconds.

    图像读取时间-第一张图像12秒钟,第二张图像11秒钟,每个后续图像再减去一秒钟。 其他图像计数为3秒。

Most of the libraries don’t account for the above features completely. They use HTML strings as is without omitting its tag names which increases the deviation of estimation from the original value.

大多数库并未完全说明上述功能。 他们按原样使用HTML字符串,而不会省略其标签名 ,这会增加估计值与原始值的偏差。

(Code)

The code can be split into three parts:

该代码可以分为三部分:

  • Constants

    常数
  • Utility

    效用
  • Main

    主要

常数 (Constants)

The constants can be used as defaults to the main function. The image tag has its own use which will be defined later.

常量可以用作主函数的默认值。 image标签有其自己的用途,稍后将进行定义。

实用功能 (Utility Functions)

  1. Strip WhiteSpace

    带空格

It is a simple utility function to remove all leading and trailing whitespace from the string provided.

这是一个简单的实用程序函数,可从提供的字符串中删除所有前导和尾随空格。

2. Image Read Time

2.图像读取时间

It parses the string, looks for any HTML image tags based on the defaults provided in the constants and returns the count.

它解析该字符串,根据常量中提供的默认值查找任何HTML图像标签,然后返回计数。

If the image count is greater than 10, we calculate the image read time of the first 10 images in decreasing arithmetic progression starting from 12 sec / customReadTime provided by the user using the simple formula n * (a+b) / 2 and 3 sec for the remaining images.

如果图像数量大于10,我们将使用简单的公式n * (a+b) / 2和3秒,从12秒/用户提供的customReadTime开始,以递减的算术级数计算前10张图像的图像读取时间。剩下的图像。

3. Strip Tags

3.剥离标签

Next, we check for any HTML tags (both) in the string and remove it to extract only the words from it.

接下来,我们检查字符串中是否有HTML标记(均为HTML标记),并将其删除以仅提取其中的单词。

4. Words Read Time

4.单词阅读时间

This utility function calculates the words count and Chinese / Korean and Japanese characters using the different Unicode character range.

该实用程序功能使用不同的Unicode字符范围来计算单词数以及中文/韩文和日文字符。

The time is calculated by dividing it with the constants defined above.

通过将时间除以上面定义的常数来计算时间。

5. Humanize Time

5.人性化的时间

Based on the distance of time in words, we can calculate and return the humanized duration of the time taken to read.

根据时间(以字为单位)的距离 ,我们可以计算并返回读取时间的人性化持续时间。

主要 (Main)

The main function only consolidates all the utility methods in the correct order.

main函数仅以正确的顺序合并所有实用程序方法。

这个脚本的准确性如何? (How accurate is this script?)

Taking the tests on the HTML string (from the Chrome inspector) before this article section.

在本文开始之前 ,请对HTML字符串(来自Chrome检查器) 进行测试。

The tests and the Pages clearly give the correct estimate about the total words from the parsed HTML and the number of images.

测试和页面清楚地给出了来自解析HTML的单词总数和图像数量的正确估计。

I’ve consolidated the complete code on GitHub. It is also available as an npm package read-time-estimate.

我已经在GitHub上整合了完整的代码。 它也可以作为npm包read-time-estimate提供 。

More of the cool stuff can be found on my StackOverflow and GitHub profiles.

在我的StackOverflowGitHub个人资料中可以找到更多有趣的东西。

Follow me on LinkedIn, Medium, Twitter for further update new articles.

LinkedInMediumTwitter上关注我,以获取更多更新的新文章。

One clap, two claps, three claps, forty?

一拍,两拍,三拍,四十?

Originally published at blog.pritishvaidya.com on January 30, 2019.

最初于2019年1月30日发布在blog.pritishvaidya.com上。

翻译自: https://www.freecodecamp.org/news/how-to-more-accurately-estimate-read-time-for-medium-articles-in-javascript-fb563ff0282a/

pmp 成本估算准确高

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/392304.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Android数据适配-ExpandableListView

Android中ListView的用法基本上学的时候都会使用,其中可以使用ArrayAdapter,SimpleAdapter,BaseAdapter去实现,这次主要使用的ExpandableListView展示一种两层的效果,ExpandableListView是android中可以实现下拉list的…

JavaWeb 命名规则

命名规范命名规范命名规范命名规范 本规范主要针对java开发制定的规范项目命名项目命名项目命名项目命名 项目创建,名称所有字母均小写,组合方式为:com.company.projectName.component.hiberarchy。1. projectName:项目名称2. com…

多元概率密度_利用多元论把握事件概率

多元概率密度Humans have plenty of cognitive strengths, but one area that most of us struggle with is estimating, explaining and preparing for improbable events. This theme underpins two of Nassim Taleb’s major works: Fooled by Randomness and The Black Swa…

nginx php访问日志配置,nginx php-fpm 输出php错误日志的配置方法

由于nginx仅是一个web服务器,因此nginx的access日志只有对访问页面的记录,不会有php 的 error log信息。nginx把对php的请求发给php-fpm fastcgi进程来处理,默认的php-fpm只会输出php-fpm的错误信息,在php-fpm的errors log里也看不…

阿里的技术愿景_技术技能的另一面:领域知识和长期愿景

阿里的技术愿景by Sihui Huang黄思慧 技术技能的另一面:领域知识和长期愿景 (The other side of technical skill: domain knowledge and long-term vision) When we first start our careers as software engineers, we tend to focus on improving our coding sk…

leetcode 721. 账户合并(并查集)

给定一个列表 accounts,每个元素 accounts[i] 是一个字符串列表,其中第一个元素 accounts[i][0] 是 名称 (name),其余元素是 emails 表示该账户的邮箱地址。 现在,我们想合并这些账户。如果两个账户都有一些共同的邮箱地址&#…

es6重点笔记:数值,函数和数组

本篇全是重点,捡常用的怼,数值的扩展比较少,所以和函数放一起: 一,数值 1,Number.EPSILON:用来检测浮点数的计算,如果误差小于这个,就无误 2,Math.trunc()&am…

SMSSMS垃圾邮件检测器的专业攻击

Note: The methodology behind the approach discussed in this post stems from a collaborative publication between myself and Irene Anthi.注意: 本文讨论的方法背后的方法来自 我本人和 Irene Anthi 之间 的 合作出版物 。 介绍 (INTRODUCTION) Spam SMS te…

php pdo 缓冲,PDO支持数据缓存_PHP教程

/*** 作者:初十* QQ:345610000*/class myPDO extends PDO{public $cache_Dir null; //缓存目录public $cache_expireTime 7200; //缓存时间,默认两小时//带缓存的查询public function cquery($sql){//缓存存放总目录if ($this->cache_Di…

mooc课程下载_如何使用十大商学院的免费课程制作MOOC“ MBA”

mooc课程下载by Laurie Pickard通过劳里皮卡德(Laurie Pickard) 如何使用十大商学院的免费课程制作MOOC“ MBA” (How to make a MOOC “MBA” using free courses from Top 10 business schools) Back when massive open online courses (MOOCs) were new, I started a proje…

leetcode 1584. 连接所有点的最小费用(并查集)

给你一个points 数组,表示 2D 平面上的一些点,其中 points[i] [xi, yi] 。 连接点 [xi, yi] 和点 [xj, yj] 的费用为它们之间的 曼哈顿距离 :|xi - xj| |yi - yj| ,其中 |val| 表示 val 的绝对值。 请你返回将所有点连接的最小…

Nagios学习实践系列

其实上篇Nagios学习实践系列——基本安装篇只是安装了Nagios基本组件,虽然能够打开主页,但是如果不配置相关配置文件文件,那么左边菜单很多页面都打不开,相当于只是一个空壳子。接下来,我们来学习研究一下Nagios的配置…

在Salesforce中处理Email的发送

在Salesforce中可以用自带的 Messaging 的 sendEmail 方法去处理Email的发送 请看如下一段简单代码: public boolean TextFormat {get;set;} public string EmailTo {get;set;} public string EmailCC {get;set;} public string EmailBCC {get;set;} public string …

kvm vnc的使用,鼠标漂移等

1.宿主机的vnc(virtual Network Computing)配置 安装rpm包 yum install tigervnc-server -y 为了防止干扰直接关闭防火墙和selinux /etc/init.d/iptables stop setenforce 0 配置vnc密码和启动vncserver服务 vncpasswd vncserver 2.客户机的vnc 在qemu…

php深浅拷贝,JavaScript 中的深浅拷贝

工作中经常会遇到需要复制 JavaScript 数据的时候,遇到 bug 时实在令人头疼;面试中也经常会被问到如何实现一个数据的深浅拷贝,但是你对其中的原理清晰吗?一起来看一下吧!一、为什么会有深浅拷贝想要更加透彻的理解为什…

使用Python进行地理编码和反向地理编码

Geocoding is the process of taking input text, such as an address or the name of a place, and returning a latitude/longitude location. To put it simply, Geocoding is converting physical address to latitude and longitude.地理编码是获取输入文本(例如地址或地点…

java开发简历编写_如何通过几个简单的步骤编写出色的初级开发人员简历

java开发简历编写So you’ve seen your dream junior developer role advertised, and are thinking about applying. It’s time to write that Resume! Nothing better than sitting down to a blank piece of paper and not knowing how to start, right?因此,您…

leetcode 628. 三个数的最大乘积(排序)

给定一个整型数组,在数组中找出由三个数组成的最大乘积,并输出这个乘积。 示例 1: 输入: [1,2,3] 输出: 6 解题思路 最大的乘积可能有两种情况 1.两个最小负数和一个最大正数 2.三个最大正数 代码 class Solution {public int maximumProduct(int[…

[Object-C语言随笔之三] 类的创建和实例化以及函数的添加和调用!

上一小节的随笔写了常用的打印以及很基础的数据类型的定义方式,今天就来一起学习下如何创建类与函数的一些随笔; 首先类的创建:在Xcode下,菜单File-New File,然后出现选择class模板,如下图&…

2024-AI人工智能学习-安装了pip install pydot但是还是报错

2024-AI人工智能学习-安装了pip install pydot但是还是报错 出现这样子的错误: /usr/local/bin/python3.11 /Users/wangyang/PycharmProjects/studyPython/tf_model.py 2023-12-24 22:59:02.238366: I tensorflow/core/platform/cpu_feature_guard.cc:182] This …