From 64f26d4a3b80969e08a607f80dde87d49ad5c2e3 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 3 Feb 2023 09:15:28 -0500 Subject: Added word frequency information --- lib/form.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'lib/form.h') diff --git a/lib/form.h b/lib/form.h index 39f53aa..fb6b733 100644 --- a/lib/form.h +++ b/lib/form.h @@ -82,6 +82,31 @@ namespace verbly { return length_; } + bool hasFrequency() const + { + if (!valid_) + { + throw std::domain_error("Bad access to uninitialized form"); + } + + return hasFreq_; + } + + bool getFrequency() const + { + if (!valid_) + { + throw std::domain_error("Bad access to uninitialized form"); + } + + if (!hasFreq_) + { + throw std::domain_error("Form does not have a frequency"); + } + + return frequency_; + } + const std::vector& getPronunciations() const { if (!valid_) @@ -109,6 +134,7 @@ namespace verbly { static const field complexity; static const field proper; static const field length; + static const field frequency; operator filter() const { @@ -149,6 +175,8 @@ namespace verbly { int complexity_; bool proper_; int length_; + bool hasFreq_ = false; + int frequency_; std::vector pronunciations_; }; -- cgit 1.4.1