mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-04 13:29:13 -04:00
feat(Text Statistics): add more stats
Sentences, Words with punctuations, Chars by type (upper, lower, digits, puncts...)
This commit is contained in:
parent
2d87aaf484
commit
af1013da36
2 changed files with 23 additions and 7 deletions
2
components.d.ts
vendored
2
components.d.ts
vendored
|
@ -144,7 +144,9 @@ declare module '@vue/runtime-core' {
|
|||
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
||||
NMenu: typeof import('naive-ui')['NMenu']
|
||||
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
||||
NSpace: typeof import('naive-ui')['NSpace']
|
||||
NSpin: typeof import('naive-ui')['NSpin']
|
||||
NStatistic: typeof import('naive-ui')['NStatistic']
|
||||
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
|
||||
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
|
||||
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
|
||||
|
|
|
@ -1,19 +1,33 @@
|
|||
<script setup lang="ts">
|
||||
import { getStringSizeInBytes } from './text-statistics.service';
|
||||
import { getStringSizeInBytes, textStatistics } from './text-statistics.service';
|
||||
import { formatBytes } from '@/utils/convert';
|
||||
|
||||
const text = ref('');
|
||||
const stats = computed(() => textStatistics(text.value));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<c-card>
|
||||
<c-input-text v-model:value="text" multiline placeholder="Your text..." rows="5" />
|
||||
|
||||
<div mt-5 flex>
|
||||
<n-statistic label="Character count" :value="text.length" flex-1 />
|
||||
<n-statistic label="Word count" :value="text === '' ? 0 : text.split(/\s+/).length" flex-1 />
|
||||
<n-statistic label="Line count" :value="text === '' ? 0 : text.split(/\r\n|\r|\n/).length" flex-1 />
|
||||
<n-statistic label="Byte size" :value="formatBytes(getStringSizeInBytes(text))" flex-1 />
|
||||
</div>
|
||||
<n-space mt-3>
|
||||
<n-statistic label="Character count" :value="stats.chars" />
|
||||
<n-statistic label="Word count" :value="stats.words" />
|
||||
<n-statistic label="Sentences count" :value="stats.sentences" />
|
||||
<n-statistic label="Line count" :value="stats.lines" />
|
||||
<n-statistic label="Byte size" :value="formatBytes(getStringSizeInBytes(text))" />
|
||||
</n-space>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<n-space>
|
||||
<n-statistic label="Chars (no spaces)" :value="stats.chars_no_spaces" />
|
||||
<n-statistic label="Uppercase chars" :value="stats.chars_upper" />
|
||||
<n-statistic label="Lowercase chars" :value="stats.chars_lower" />
|
||||
<n-statistic label="Digit chars" :value="stats.chars_digits" />
|
||||
<n-statistic label="Punctuations" :value="stats.chars_puncts" />
|
||||
<n-statistic label="Spaces chars" :value="stats.chars_spaces" />
|
||||
<n-statistic label="Word count (no punct)" :value="stats.words_no_puncs" />
|
||||
</n-space>
|
||||
</c-card>
|
||||
</template>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue