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的单词总数和图像数量的正确估计。

链接 (Links)

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 成本估算准确高

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

  1. java excel行高_使用apache poi在excel中使用行高调整图像高度

    也许这是一个愚蠢的问题,但我找不到解决方案 如何根据图像高度设置行高? 这是我的代码的一部分: int pictureIdx = workBook.addPicture(bytes, Workbook ...

  2. video 微信 标签层级过高_标签Tag在用户决策中的作用

    2020.11.27更新: 以下内容纯属胡说八道 2020.10.16 一.标签是什么? 这里的标签指的是Tag而非表单中的Label,它有语境相关和帮助决策的两个特点. 语境相关:标签都是与内容强相 ...

  3. c++ 数组截取_【学习教程】JavaScript中原生Array数组方法详解

    来源 | http://www.fly63.com/article/detial/9692 JS中,数组可以通过阵列构造函数或[]字面量的方式创建.数组是一个特殊的对象,继承自对象原型,但用typeo ...

  4. js向上向下取整_你可能不知道的 JavaScript 中数字取整:向上取整,向下取整,四舍五入,舍去小数...

    网上方法很多,标题党一下,勿拍 ^_^!实际开发过程中经常遇到数字取整问题,所以这篇文章收集了一些方法,以备查询. 常用的直接取整方法 直接取整就是舍去小数部分. 1.parseInt() parse ...

  5. js判断是否为数字_第23题:JavaScript 中如何判断变量是否为数字 ?

    在JavaScript中,诸如NaN,Infinity(正无穷)和-Infinity(负无穷)之类的特殊值也是数字类型的. 判断方法3中: Number.isFinite() Number.isNaN ...

  6. vj节点_创意编码—如何在JavaScript中创建VJ引擎

    vj节点 by George Gally 通过乔治·加利 创意编码-如何在JavaScript中创建VJ引擎 (Creative Coding - How to create a VJ engine ...

  7. 选择嵌套_如何优雅地在JavaScript中访问嵌套对象

    在JavaScript中访问嵌套对象 以超酷的方式安全地访问JavaScript中的嵌套对象 JavaScript是惊人的,我们都知道.但是JavaScript中的一些东西真的很奇怪,它们让我们大开眼 ...

  8. javascript毫秒计时器_如何在倒数计时器javascript中显示毫秒

    我重写了代码以包含毫秒.还要确保setTimer设置正确. var mins var secs; var ms; function cd() { mins = 1 * m("05" ...

  9. java如何让线程休眠一分钟_如何使线程在java中休眠特定的时间?

    当你的线程被中断击中时,它将进入InterruptedException catch块.然后,您可以检查线程花费了多少时间睡觉,并计算出睡眠时间.最后,不要吞咽异常,恢复中断状态是很好的做法,以便调用 ...

最新文章

  1. 官方抓虫,PyTorch 新版本修复 13 项 Bug
  2. android 上传html文件大小,浅谈关于Android WebView上传文件的解决方案
  3. 疫情下的情人节怎么过?Serverless在线课堂来支招
  4. 树莓派4b ros镜像 网盘_树莓派4B的入手操作
  5. 非大学生学计算机,浅谈非计算机专业大学生的计算机教学
  6. mysql数据库管理系统模式_MYSQL命令行模式管理MySql的一点心得
  7. “等等党”的春天到了?高端显卡暴降35% 华强北商家:还会继续降
  8. 摘录:《晨间日记的奇迹》
  9. autocad 注册表
  10. 微位科技李子阳:哈耶克—未来的价值单位
  11. HTML5 弹性布局
  12. 【苹果手机登录163邮箱】
  13. g5500服务器装系统,联想G50笔记本U盘重装win10系统教程
  14. Unity2019版本打包一直停留在 detecting current sdk tools version的解决方案
  15. VUE组件日时分秒倒计时
  16. SLAM导航机器人零基础实战系列:(三)感知与大脑——5.机器人大脑嵌入式主板性能对比...
  17. 数据校验validation
  18. 用DC-DC 升压降压以及产生负电压的原理及应用
  19. 国仁老猫:视频号“混剪玩法”还能玩吗?有人已经月入2W。
  20. 将STemWin526_CM3_Keil.lib更换成STemWin V5.44版本

热门文章

  1. 我了解到的面试的一些小内幕!附面试题答案
  2. ad09只在一定范围内查找相似对象_23、面向对象编程
  3. powerCat进行常规tcp端口转发
  4. New Distinct Substrings(后缀数组)
  5. Django之model补充:一对多、跨表操作
  6. 手机web网页制作的认识(有关meta标签)
  7. MySQL中CREATE DATABASE和CREATE SCHEMA区别(转)
  8. 洛谷-求同构数的个数-NOIP2013提高组复赛
  9. 学习笔记-----fputs与printf
  10. 扩展 CommandField 类别 - Header 加入新增钮