Skip to content

Commit

Permalink
options menu almost complete
Browse files Browse the repository at this point in the history
  • Loading branch information
lavedon committed Apr 29, 2021
1 parent bb94ef9 commit b5b7bfb
Show file tree
Hide file tree
Showing 26 changed files with 713 additions and 74 deletions.
6 changes: 6 additions & 0 deletions ConsoleUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ static void MainMenu(CurrentQuery query)
Console.WriteLine("Quotations - Q");
Console.WriteLine("-------------------------");
Console.WriteLine("New Word (start over) - N");
Console.WriteLine("Options - O");
Console.WriteLine("Export Results - E");
Console.WriteLine("Exit - X");
Console.WriteLine("Please make a selection and press enter");
Expand Down Expand Up @@ -94,6 +95,11 @@ static void MainMenu(CurrentQuery query)
Trace.WriteLine(query.Definition);
break;

case ("o" or "options" or "option"):
Trace.WriteLine("Options menu selected.");
OptionsMenu.StartOptionsMenu(query);
break;

case ("s" or "senses"):
Trace.WriteLine("Get senses selected.");
query.QueryMode = Modes.Senses;
Expand Down
14 changes: 11 additions & 3 deletions CurrentQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@ public enum Modes
Senses,
Quotations
}
class CurrentQuery : IDisposable
public class CurrentQuery : IDisposable
{
public bool HasLookedUpWord { get; set; }
public string WordID { get; set; }
// Create the object the same time the user looks up a word
public string UserEnteredWord { get; set; }
public string Definition { get; set; }
public string[] SenseIDs { get; set; }
public string Lamma { get; set; }
public int NumberOfQuotes { get; set; }
public string Quote { get; set; }


Expand All @@ -34,10 +32,20 @@ class CurrentQuery : IDisposable

public Modes QueryMode { get; set; }

public bool HasLookedUpWord { get; set; }
public bool IncludeObsolete { get; set; }

public int NumberOfQuotes { get; set; }
public int StartYear { get; set; }
public int EndYear { get; set; }

public CurrentQuery() {
this.HasLookedUpWord = false;
this.IncludeObsolete = true;
this.Quotes = new List<Quote>();
this.Senses = new List<Sense>();
this.StartYear = 0;
this.EndYear = 0;
}
public string Source { get; set; }

Expand Down
114 changes: 114 additions & 0 deletions OptionsMenu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
using System;
using System.Diagnostics;
using System.Linq;

namespace OxfordV2
{
public static class OptionsMenu
{
private static string yesNo = "";
private static bool running = false;

public static void StartOptionsMenu(CurrentQuery query)
{
running = true;
while (running) {
ShowOptionsMenu(query);
}
}

public static void ShowOptionsMenu(CurrentQuery query)
{

Console.WriteLine("-------------------------");
Console.WriteLine("Options Menu:");
Console.WriteLine("-------------------------");

if (query.IncludeObsolete == true)
{
yesNo = "Yes";
}
else {
yesNo = "No";
}
Console.WriteLine($"Include obsolete usage?: {yesNo}");
if (query.StartYear == 0 || query.EndYear == 0)
{
yesNo = "No";
}
else {
yesNo = "Yes";
}

Console.WriteLine($"Is a date range set?: {yesNo}");
if (yesNo == "Yes")
{
Console.WriteLine($"Year Range: {query.StartYear} - {query.EndYear}");
}

Console.WriteLine("-------------------------");
Console.WriteLine("Toggle obsolete usage - O");
Console.WriteLine("Set date range: - D");
Console.WriteLine("Exit to main menu - X");
var input = Console.ReadLine().Trim().ToLower();
switch (input)
{
case ("o" or "obsolete" or "ob"):
Console.WriteLine("Toggle Obsolete");
query.IncludeObsolete = false;
break;
case ("d" or "date" or "date range"):
Console.WriteLine("Enter Date Range");
SetYears();
break;
case ("x" or "e" or "exit"):
Console.WriteLine("Exiting back to main menu.");
running = false;
break;

default:
Console.WriteLine("Did not recognize input");
break;
}

static (int startYear, int endYear) SetYears()
{
int startYearInt = 0;
int endYearInt = 0;

var setYearsRunning = true;
while (setYearsRunning)
{
Console.WriteLine("Only get results within this date range:");
Console.WriteLine("Starting Year:");
string startYear = Console.ReadLine().Trim().ToLower();
if (validate(startYear)) {
startYearInt = Int16.Parse(startYear);
} else {
break;
}
Console.WriteLine("Ending Year:");

string endYear = Console.ReadLine().Trim().ToLower();
if (validate(endYear)) {
endYearInt = Int16.Parse(endYear);
} else {
break;
}

static bool validate(string year) {
if (year.Length <= 4 || year.All(char.IsDigit)) {
return true;
} else {
Console.WriteLine("Invalid Year.");
Console.WriteLine("Please enter a 3 digit or 4 digit year.");
return false;
}
}
}
return (startYearInt, endYearInt);

}
}
}
}
Binary file modified bin/Debug/net5.0/OxfordV2.dll
Binary file not shown.
Binary file modified bin/Debug/net5.0/OxfordV2.pdb
Binary file not shown.
Binary file modified bin/Debug/net5.0/ref/OxfordV2.dll
Binary file not shown.
40 changes: 40 additions & 0 deletions logs/Log_OxfordApplication_20210429-1716.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Leaving Main method.
Starting Main Menu
In MainMenu()
Automatically looking up user entered word:
computer
Found that QueryMode is set to words.
Looking up the word:
computer
Now to call the words endpoint.
Getting request keys
resetHeaders called.
App Id is:
4ebc819b
Key is:
b6b1ca0e4e766b222d56c20f43c2396f
Here are the request Headers...
Accept: application/json
app_id: 4ebc819b
app_key: b6b1ca0e4e766b222d56c20f43c2396f

Calling the API
Called callWordsAPI
Making the request
Got responses.
Set JSONResponse to the response.
Left getWords task with the JSONResponse.
Parsing JSON
We now have the data as a string.
[{"id": "computer_nn01", "band": 9, "meta": {"created": 1891, "revised": true, "updated": 2008}, "lemma": "computer", "oed_url": "https://www.oed.com/view/Entry/37975#eid8618136", "daterange": {"end": null, "start": 1613, "obsolete": false, "rangestring": "1613\u2014"}, "etymology": {"etymons": [{"word": "compute", "language": "English", "target_id": "compute_vb01", "part_of_speech": "VB"}, {"word": "-er", "language": "English", "target_id": "er_su01", "part_of_speech": "SUFFIX"}], "etymology_type": "derivative", "etymon_language": [["English"]], "source_language": [["European languages", "Italic", "Latin"]], "etymology_summary": "Formed within English, by derivation."}, "first_use": "\u2018R. B.\u2019", "frequency": [[1750, 0.21], [1760, 0.18], [1770, 0.17], [1780, 0.16], [1790, 0.15], [1800, 0.14], [1810, 0.083], [1820, 0.077], [1830, 0.086], [1840, 0.086], [1850, 0.093], [1860, 0.11], [1870, 0.13], [1880, 0.16], [1890, 0.18], [1900, 0.21], [1910, 0.24], [1920, 0.45], [1930, 2.1], [1940, 10], [1950, 17], [1960, 40], [1970, 77], [1980, 110], [1990, 120], [2000, 120], [2010, 120]], "sense_ids": ["computer_nn01-8618138", "computer_nn01-8618177", "computer_nn01-130514973", "computer_nn01-130514976"], "definition": "An electronic device (or system of devices) which is used to store, manipulate, and communicate information, perform complex calculations, or control or regulate other devices or machines, and is capable of receiving information (data) and of processing it in accordance with variable procedural instructions (programs or software); esp. a small, self-contained one for individual use in the home or workplace, used esp. for handling text, images, music, and video, accessing and using the internet\u2026", "main_entry": true, "inflections": [{"region": "British", "inflections": [{"form": "computer", "part_of_speech": "NN"}, {"form": "computers", "part_of_speech": "NNS"}]}, {"region": "US", "inflections": [{"form": "computer", "part_of_speech": "NN"}, {"form": "computers", "part_of_speech": "NNS"}]}], "frequency_id": "computer_nn01-fq", "oed_reference": "computer, n.", "pronunciations": [{"ipa": ["k\u0259m\u02c8pju\u02d0t\u0259"], "region": "British"}, {"ipa": ["k\u0259m\u02c8pjud\u0259r"], "region": "US"}], "parts_of_speech": ["NN"], "primary_sense_id": "computer_nn01-130514973"}]
Extracted definition.
Set definition to query object.
Now to get and set the word ID.
The wordID was grabbed as:
computer_nn01The user's input was read as:
o
Options menu selected.
In MainMenu()
The user's input was read as:
x
Exit selected.
40 changes: 40 additions & 0 deletions logs/Log_OxfordApplication_20210429-1720.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Leaving Main method.
Starting Main Menu
In MainMenu()
Automatically looking up user entered word:
o
Found that QueryMode is set to words.
Looking up the word:
o
Now to call the words endpoint.
Getting request keys
resetHeaders called.
App Id is:
4ebc819b
Key is:
b6b1ca0e4e766b222d56c20f43c2396f
Here are the request Headers...
Accept: application/json
app_id: 4ebc819b
app_key: b6b1ca0e4e766b222d56c20f43c2396f

Calling the API
Called callWordsAPI
Making the request
Got responses.
Set JSONResponse to the response.
Left getWords task with the JSONResponse.
Parsing JSON
We now have the data as a string.
[{"id": "o_rb01", "band": 13, "meta": {"created": 1902, "revised": true, "updated": 2004}, "lemma": "o", "oed_url": "https://www.oed.com/view/Entry/129449#eid34019973", "daterange": {"end": 1591, "start": 925, "obsolete": true, "rangestring": "eOE\u20141591"}, "etymology": {"etymons": [], "etymology_type": "inherited", "etymon_language": [["European languages", "Germanic", "West Germanic"]], "source_language": [["European languages", "Germanic"]], "etymology_summary": "A word inherited from Germanic."}, "first_use": "Acct. Voy. Ohthere & Wulfstan", "frequency": null, "sense_ids": ["o_rb01-34019975"], "definition": "Ever; always; throughout eternity.", "main_entry": true, "inflections": [{"region": "British", "inflections": [{"form": "o", "part_of_speech": "RB"}]}, {"region": "US", "inflections": [{"form": "o", "part_of_speech": "RB"}]}], "frequency_id": null, "oed_reference": "o, adv.", "pronunciations": [], "parts_of_speech": ["RB"], "primary_sense_id": "o_rb01-34019975"}]
Extracted definition.
Set definition to query object.
Now to get and set the word ID.
The wordID was grabbed as:
o_rb01The user's input was read as:
options
Options menu selected.
In MainMenu()
The user's input was read as:
x
Exit selected.
40 changes: 40 additions & 0 deletions logs/Log_OxfordApplication_20210429-1725.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Leaving Main method.
Starting Main Menu
In MainMenu()
Automatically looking up user entered word:
computer
Found that QueryMode is set to words.
Looking up the word:
computer
Now to call the words endpoint.
Getting request keys
resetHeaders called.
App Id is:
4ebc819b
Key is:
b6b1ca0e4e766b222d56c20f43c2396f
Here are the request Headers...
Accept: application/json
app_id: 4ebc819b
app_key: b6b1ca0e4e766b222d56c20f43c2396f

Calling the API
Called callWordsAPI
Making the request
Got responses.
Set JSONResponse to the response.
Left getWords task with the JSONResponse.
Parsing JSON
We now have the data as a string.
[{"id": "computer_nn01", "band": 9, "meta": {"created": 1891, "revised": true, "updated": 2008}, "lemma": "computer", "oed_url": "https://www.oed.com/view/Entry/37975#eid8618136", "daterange": {"end": null, "start": 1613, "obsolete": false, "rangestring": "1613\u2014"}, "etymology": {"etymons": [{"word": "compute", "language": "English", "target_id": "compute_vb01", "part_of_speech": "VB"}, {"word": "-er", "language": "English", "target_id": "er_su01", "part_of_speech": "SUFFIX"}], "etymology_type": "derivative", "etymon_language": [["English"]], "source_language": [["European languages", "Italic", "Latin"]], "etymology_summary": "Formed within English, by derivation."}, "first_use": "\u2018R. B.\u2019", "frequency": [[1750, 0.21], [1760, 0.18], [1770, 0.17], [1780, 0.16], [1790, 0.15], [1800, 0.14], [1810, 0.083], [1820, 0.077], [1830, 0.086], [1840, 0.086], [1850, 0.093], [1860, 0.11], [1870, 0.13], [1880, 0.16], [1890, 0.18], [1900, 0.21], [1910, 0.24], [1920, 0.45], [1930, 2.1], [1940, 10], [1950, 17], [1960, 40], [1970, 77], [1980, 110], [1990, 120], [2000, 120], [2010, 120]], "sense_ids": ["computer_nn01-8618138", "computer_nn01-8618177", "computer_nn01-130514973", "computer_nn01-130514976"], "definition": "An electronic device (or system of devices) which is used to store, manipulate, and communicate information, perform complex calculations, or control or regulate other devices or machines, and is capable of receiving information (data) and of processing it in accordance with variable procedural instructions (programs or software); esp. a small, self-contained one for individual use in the home or workplace, used esp. for handling text, images, music, and video, accessing and using the internet\u2026", "main_entry": true, "inflections": [{"region": "British", "inflections": [{"form": "computer", "part_of_speech": "NN"}, {"form": "computers", "part_of_speech": "NNS"}]}, {"region": "US", "inflections": [{"form": "computer", "part_of_speech": "NN"}, {"form": "computers", "part_of_speech": "NNS"}]}], "frequency_id": "computer_nn01-fq", "oed_reference": "computer, n.", "pronunciations": [{"ipa": ["k\u0259m\u02c8pju\u02d0t\u0259"], "region": "British"}, {"ipa": ["k\u0259m\u02c8pjud\u0259r"], "region": "US"}], "parts_of_speech": ["NN"], "primary_sense_id": "computer_nn01-130514973"}]
Extracted definition.
Set definition to query object.
Now to get and set the word ID.
The wordID was grabbed as:
computer_nn01The user's input was read as:
o
Options menu selected.
In MainMenu()
The user's input was read as:
x
Exit selected.
40 changes: 40 additions & 0 deletions logs/Log_OxfordApplication_20210429-1726.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Leaving Main method.
Starting Main Menu
In MainMenu()
Automatically looking up user entered word:
apple
Found that QueryMode is set to words.
Looking up the word:
apple
Now to call the words endpoint.
Getting request keys
resetHeaders called.
App Id is:
4ebc819b
Key is:
b6b1ca0e4e766b222d56c20f43c2396f
Here are the request Headers...
Accept: application/json
app_id: 4ebc819b
app_key: b6b1ca0e4e766b222d56c20f43c2396f

Calling the API
Called callWordsAPI
Making the request
Got responses.
Set JSONResponse to the response.
Left getWords task with the JSONResponse.
Parsing JSON
We now have the data as a string.
[{"id": "apple_nn01", "band": 6, "meta": {"created": 1885, "revised": true, "updated": 2008}, "lemma": "apple", "oed_url": "https://www.oed.com/view/Entry/9678#eid340737", "daterange": {"end": null, "start": 895, "obsolete": false, "rangestring": "eOE\u2014"}, "etymology": {"etymons": [], "etymology_type": "inherited", "etymon_language": [["European languages", "Germanic", "West Germanic"]], "source_language": [["European languages", "Germanic"]], "etymology_summary": "A word inherited from Germanic."}, "first_use": "King Alfred", "frequency": [[1750, 7.7], [1760, 8.2], [1770, 8.8], [1780, 9.0], [1790, 9.9], [1800, 10], [1810, 10], [1820, 11], [1830, 12], [1840, 12], [1850, 13], [1860, 14], [1870, 14], [1880, 16], [1890, 17], [1900, 19], [1910, 19], [1920, 20], [1930, 20], [1940, 18], [1950, 16], [1960, 13], [1970, 13], [1980, 14], [1990, 15], [2000, 15], [2010, 15]], "sense_ids": ["apple_nn01-340739", "apple_nn01-340946", "apple_nn01-341016", "apple_nn01-122260836", "apple_nn01-341164", "apple_nn01-340917", "apple_nn01-343079", "apple_nn01-119186380", "apple_nn01-343199", "apple_nn01-343158", "apple_nn01-119186432", "apple_nn01-343232", "apple_nn01-341316", "apple_nn01-341407", "apple_nn01-341467", "apple_nn01-119186414", "apple_nn01-343271", "apple_nn01-343518", "apple_nn01-343442", "apple_nn01-341507"], "definition": "The round firm fruit (a pome) of any of various wild and cultivated trees of the genus Malus (see sense 4a), occurring in a wide variety of forms, colours, and flavours; esp. any of numerous cultivated kinds produced throughout the temperate zones of both hemispheres, typically having crisp white flesh and green, yellow, or red skin.", "main_entry": true, "inflections": [{"region": "British", "inflections": [{"form": "apple", "part_of_speech": "NN"}, {"form": "apples", "part_of_speech": "NNS"}]}, {"region": "US", "inflections": [{"form": "apple", "part_of_speech": "NN"}, {"form": "apples", "part_of_speech": "NNS"}]}], "frequency_id": "apple_nn01-fq", "oed_reference": "apple, n.", "pronunciations": [{"ipa": ["\u02c8apl"], "region": "British"}, {"ipa": ["\u02c8aep(\u0259)l"], "region": "US"}], "parts_of_speech": ["NN"], "primary_sense_id": "apple_nn01-340739"}]
Extracted definition.
Set definition to query object.
Now to get and set the word ID.
The wordID was grabbed as:
apple_nn01The user's input was read as:
o
Options menu selected.
In MainMenu()
The user's input was read as:
x
Exit selected.
40 changes: 40 additions & 0 deletions logs/Log_OxfordApplication_20210429-1732.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Leaving Main method.
Starting Main Menu
In MainMenu()
Automatically looking up user entered word:
cow
Found that QueryMode is set to words.
Looking up the word:
cow
Now to call the words endpoint.
Getting request keys
resetHeaders called.
App Id is:
4ebc819b
Key is:
b6b1ca0e4e766b222d56c20f43c2396f
Here are the request Headers...
Accept: application/json
app_id: 4ebc819b
app_key: b6b1ca0e4e766b222d56c20f43c2396f

Calling the API
Called callWordsAPI
Making the request
Got responses.
Set JSONResponse to the response.
Left getWords task with the JSONResponse.
Parsing JSON
We now have the data as a string.
[{"id": "cow_nn01", "band": 7, "meta": {"created": 1893, "revised": false, "updated": null}, "lemma": "cow", "oed_url": "https://www.oed.com/view/Entry/43415#eid7908383", "daterange": {"end": null, "start": 799, "obsolete": false, "rangestring": "eOE\u2014"}, "etymology": {"etymons": [], "etymology_type": "inherited", "etymon_language": [["European languages", "Germanic"]], "source_language": [["European languages", "Germanic"]], "etymology_summary": "A word inherited from Germanic."}, "first_use": "Corpus Glossary", "frequency": [[1750, 17], [1760, 19], [1770, 20], [1780, 20], [1790, 21], [1800, 21], [1810, 20], [1820, 20], [1830, 19], [1840, 18], [1850, 18], [1860, 19], [1870, 20], [1880, 22], [1890, 24], [1900, 25], [1910, 27], [1920, 29], [1930, 29], [1940, 28], [1950, 27], [1960, 23], [1970, 20], [1980, 18], [1990, 16], [2000, 16], [2010, 16]], "sense_ids": ["cow_nn01-7908386", "cow_nn01-7908508", "cow_nn01-7909013", "cow_nn01-7909037", "cow_nn01-7909135", "cow_nn01-7909205", "cow_nn01-7909242", "cow_nn01-7909298", "cow_nn01-7909341", "cow_nn01-7909415", "cow_nn01-7909516", "cow_nn01-7909550", "cow_nn01-7909552", "cow_nn01-287310942"], "definition": "The female of any bovine animal (as the ox, bison, or buffalo); most commonly applied to the female of the domestic species (Bos Taurus).", "main_entry": true, "inflections": [{"region": "British", "inflections": [{"form": "cow", "part_of_speech": "NN"}, {"form": "cows", "part_of_speech": "NNS"}]}, {"region": "US", "inflections": [{"form": "cow", "part_of_speech": "NN"}, {"form": "cows", "part_of_speech": "NNS"}]}], "frequency_id": "cow_nn01-fq", "oed_reference": "cow, n.1", "pronunciations": [{"ipa": ["ka\u028a"], "region": "British"}, {"ipa": ["ka\u028a"], "region": "US"}], "parts_of_speech": ["NN"], "primary_sense_id": "cow_nn01-7908386"}]
Extracted definition.
Set definition to query object.
Now to get and set the word ID.
The wordID was grabbed as:
cow_nn01The user's input was read as:
o
Options menu selected.
In MainMenu()
The user's input was read as:
x
Exit selected.
Loading

0 comments on commit b5b7bfb

Please sign in to comment.