ValeMetricsInfo
The ValeMetricsInfo class represents a list of counts for the prose in a document.
2 minute read
Definition
Source Code
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
using module .\ValeMetricsHeadingCount.psm1
class ValeMetricsInfo {
[System.IO.FileInfo] $FileInfo
[int] $CharacterCount
[int] $ComplexWordCount
[ValeMetricsHeadingCount] $HeadingCounts
[int] $ListBlockCount
[int] $LongWordCount
[int] $ParagraphCount
[int] $PolysyllabicWordCount
[int] $SentenceCount
[int] $SyllableCount
[int] $WordCount
# Default Constructor
ValeMetricsInfo() {
$this.HeadingCounts = [ValeMetricsHeadingCount]::new()
}
# From PSCustomObject, as with Invoke-Vale
ValeMetricsInfo([hashtable]$Info) {
$this.SetFromMetricInfo($Info)
}
# From PSCustomObject with known file info
ValeMetricsInfo([hashtable]$Info, [System.IO.FileInfo]$File) {
$this.SetFromMetricInfo($Info)
$this.FileInfo = $File
}
# Reusable method for converting from JSON properties to class properties
hidden [void] SetFromMetricInfo([hashtable]$Info) {
$this.HeadingCounts = [ValeMetricsHeadingCount]::new()
$this.CharacterCount = $Info.characters
$this.ComplexWordCount = $info.complex_words
$this.HeadingCounts.H1 = $info.heading_h1
$this.HeadingCounts.H2 = $info.heading_h2
$this.HeadingCounts.H3 = $info.heading_h3
$this.HeadingCounts.H4 = $info.heading_h4
$this.HeadingCounts.H5 = $info.heading_h5
$this.HeadingCounts.H6 = $info.heading_h6
$this.ListBlockCount = $info.list
$this.LongWordCount = $info.long_words
$this.ParagraphCount = $info.paragraphs
$this.PolysyllabicWordCount = $info.polysyllabic_words
$this.SentenceCount = $info.sentences
$this.SyllableCount = $info.syllables
$this.WordCount = $info.words
}
}
An instance of the ValeMetricsInfo class represents a list of counts for the prose in a
document as returned by the Get-ProseMetric
command.
Examples
1. Checking the metrics for a document
This example shows the metrics returned for a Markdown document.
get-proseMetric -Path ./README.md
Get-ProseMetric -Path ./README.md | Format-List
FileInfo WordCount SentenceCount ParagraphCount
-------- --------- ------------- --------------
C:\code\pwsh\Documentarian\README.md 416 38 29
FileInfo : C:\code\pwsh\Documentarian\README.md
CharacterCount : 2175
ComplexWordCount : 81
HeadingCounts : ValeMetricsHeadingCount
ListBlockCount : 7
LongWordCount : 139
ParagraphCount : 29
PolysyllabicWordCount : 94
SentenceCount : 38
SyllableCount : 748
WordCount : 416
Constructors
ValeMetricsInfo()
- Initializes a new instance of the ValeMetricsInfo class.
ValeMetricsInfo(System.Collections.Hashtable)
- Initializes a new instance of the ValeMetricsInfo class from the output of
vale ls-metrics
ValeMetricsInfo(System.Collections.Hashtable, System.IO.FileInfo)
- Initializes a new instance of the ValeMetricsInfo class from the output of
vale ls-metrics
and the file’s information.
Properties
- CharacterCount
- Represents the number of characters in the document.
- ComplexWordCount
- Represents the number of polysyllabic words without common suffixes in the document.
- FileInfo
- Represents the file the metrics are for.
- HeadingCounts
- Represents the counts for the headings in the document.
- ListBlockCount
- Represents the number of ordered and unordered lists in the document.
- LongWordCount
- Represents the number of words with more than 6 characters in the document.
- ParagraphCount
- Represents the number of paragraphs in the document.
- PolysyllabicWordCount
- Represents the number of words with more than two syllables in the document.
- SentenceCount
- Represents the number of sentences in the document.
- SyllableCount
- Represents the number of syllables in the document.
- WordCount
- Represents the number of words in the document.
Last modified March 10, 2023: (GH-71) Document Vale classes (ad1e42a)