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.pswp.cn/news/392304.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/392304.shtml
英文地址,請注明出處:http://en.pswp.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 …