Skip to content

Commit

Permalink
basic root and definition work
Browse files Browse the repository at this point in the history
  • Loading branch information
lavedon committed Apr 17, 2021
1 parent cf510d1 commit 6799748
Show file tree
Hide file tree
Showing 15 changed files with 552 additions and 3 deletions.
28 changes: 25 additions & 3 deletions API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,36 @@ public static void APICalls(CurrentQuery query)
getRoots.RunSynchronously();
Trace.WriteLine("Ran roots synchronously.");
// JsonElement apiData = JSONResponse.RootElement.GetProperty("data");
string rootInfo = JSONResponse.RootElement.GetProperty("data").ToString();
string rootDataString = JSONResponse.RootElement.GetProperty("data").ToString();
Console.WriteLine();
// Etymology_summary
//
// (?<="etymology_summary":\s")(.*?)(?="},)
var etymologySummaryRegEx = new Regex("(?<=\"etymology_summary\":\\s\")(.*?)(?=\"},)");
query.EtymologySummary = etymologySummaryRegEx.Match(rootDataString).ToString();
Console.WriteLine("Where the word \"{0}\" came from:", query.UserEnteredWord);
Console.WriteLine(query.EtymologySummary);
Console.WriteLine();


// first_use
//
// (?<="first_use":\s")(.*?)(?=",)
var firstUseRegEx = new Regex("(?<=\"first_use\":\\s\")(.*?)(?=\",)");
query.FirstUse = firstUseRegEx.Match(rootDataString).ToString();
Console.WriteLine("First Recorded Use:");
Console.WriteLine(query.FirstUse);
Console.WriteLine();


// Source Language
// (?<="source_language":\s\[\["European languages",)(.*?)(?=\])
var sourceLanguageRegEx = new Regex("(?<=\"source_language\":\\s\\[\\[\"European languages\",)(.*?)(?=\\])");
query.SourceLanguage = sourceLanguageRegEx.Match(rootDataString).ToString();
Console.WriteLine("The word \"{0}\" has origins in these European languages: ", query.UserEnteredWord);
Console.WriteLine(query.SourceLanguage);
Console.WriteLine("-----------");
Console.WriteLine("Please Press Enter...");
Console.ReadLine();


}
}
Expand Down
5 changes: 5 additions & 0 deletions CurrentQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class CurrentQuery : IDisposable
public string Definition { get; set; }
public string[] SenseIDs { get; set; }
public string Lamma { get; set; }

public string EtymologySummary { get; set; }
public string FirstUse { get; set; }
public string SourceLanguage { get; set; }

public Modes QueryMode { get; set; }

public CurrentQuery() {
Expand Down
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.
63 changes: 63 additions & 0 deletions logs/Log_OxfordApplication_20210416-2043.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
Leaving Main method.
Starting Main Menu
In MainMenu()
The user's input was read as:
d
Word look up selected
Found that QueryMode is set to words.
Looking up the word:
chair
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": "chair_nn01", "band": 6, "meta": {"created": 1889, "revised": false, "updated": null}, "lemma": "chair", "oed_url": "https://www.oed.com/view/Entry/30215#eid9765745", "daterange": {"end": null, "start": 1297, "obsolete": false, "rangestring": "1297\u2014"}, "etymology": {"etymons": [{"word": "cha\u00ebre", "language": "French"}, {"word": "chaiere", "language": "French"}], "etymology_type": "borrowingHybrid", "etymon_language": [["European languages", "Italic", "Romance", "Italo-Western", "Gallo-Romance", "French"]], "source_language": [["European languages", "Italic", "Romance", "Italo-Western", "Gallo-Romance", "French"], ["European languages", "Greek"]], "etymology_summary": "A borrowing from French, combined with an English element."}, "first_use": "Chronicle of Robert of Gloucester", "frequency": [[1750, 17], [1760, 19], [1770, 20], [1780, 20], [1790, 23], [1800, 24], [1810, 26], [1820, 29], [1830, 30], [1840, 33], [1850, 35], [1860, 38], [1870, 41], [1880, 43], [1890, 45], [1900, 47], [1910, 48], [1920, 47], [1930, 45], [1940, 41], [1950, 37], [1960, 33], [1970, 33], [1980, 38], [1990, 45], [2000, 49], [2010, 52]], "sense_ids": ["chair_nn01-9765748", "chair_nn01-9765918", "chair_nn01-9766034", "chair_nn01-9766086", "chair_nn01-9766128", "chair_nn01-9766167", "chair_nn01-9766191", "chair_nn01-9766261", "chair_nn01-9766309", "chair_nn01-9766353", "chair_nn01-9766415", "chair_nn01-9766435", "chair_nn01-9766456", "chair_nn01-9766508", "chair_nn01-9766538", "chair_nn01-9766562", "chair_nn01-9766607", "chair_nn01-9766670", "chair_nn01-9766761", "chair_nn01-9766784", "chair_nn01-9766861", "chair_nn01-9766921", "chair_nn01-9766962", "chair_nn01-9766979", "chair_nn01-128025765", "chair_nn01-218565101"], "definition": "A seat for one person (always implying more or less of comfort and ease); now the common name for the movable four-legged seat with a rest for the back, which constitutes, in many forms of rudeness or elegance, an ordinary article of household furniture, and is also used in gardens or wherever it is usual to sit. to take a chair: to take a seat, be seated.", "main_entry": true, "inflections": [{"region": "British", "inflections": [{"form": "chair", "part_of_speech": "NN"}, {"form": "chairs", "part_of_speech": "NNS"}]}, {"region": "US", "inflections": [{"form": "chair", "part_of_speech": "NN"}, {"form": "chairs", "part_of_speech": "NNS"}]}], "frequency_id": "chair_nn01-fq", "oed_reference": "chair, n.1", "pronunciations": [{"ipa": ["t\u0283\u025b\u02d0"], "region": "British"}, {"ipa": ["t\u0283\u025b(\u0259)r"], "region": "US"}], "parts_of_speech": ["NN"], "primary_sense_id": "chair_nn01-9765748"}]
Extracted definition.
Set definition to query object.
Now to get and set the word ID.
The wordID was grabbed as:
chair_nn01In MainMenu()
The user's input was read as:
r
Root selected.
Now to call the root endpoint.
Going to look up roots
API call URL is:
https://oed-researcher-api.oxfordlanguages.com/oed/api/v0.2/
Making the request:
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 to get ROOTS. Bloody Roots!!
Called callRootsAPI
Making the request
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[System.String,System.Net.Http.HttpClient+<GetStringAsyncCore>d__41]
Ran roots synchronously.
In MainMenu()
The user's input was read as:
x
Exit selected.
63 changes: 63 additions & 0 deletions logs/Log_OxfordApplication_20210416-2045.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
Leaving Main method.
Starting Main Menu
In MainMenu()
The user's input was read as:
d
Word look up selected
Found that QueryMode is set to words.
Looking up the word:
chair
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": "chair_nn01", "band": 6, "meta": {"created": 1889, "revised": false, "updated": null}, "lemma": "chair", "oed_url": "https://www.oed.com/view/Entry/30215#eid9765745", "daterange": {"end": null, "start": 1297, "obsolete": false, "rangestring": "1297\u2014"}, "etymology": {"etymons": [{"word": "cha\u00ebre", "language": "French"}, {"word": "chaiere", "language": "French"}], "etymology_type": "borrowingHybrid", "etymon_language": [["European languages", "Italic", "Romance", "Italo-Western", "Gallo-Romance", "French"]], "source_language": [["European languages", "Italic", "Romance", "Italo-Western", "Gallo-Romance", "French"], ["European languages", "Greek"]], "etymology_summary": "A borrowing from French, combined with an English element."}, "first_use": "Chronicle of Robert of Gloucester", "frequency": [[1750, 17], [1760, 19], [1770, 20], [1780, 20], [1790, 23], [1800, 24], [1810, 26], [1820, 29], [1830, 30], [1840, 33], [1850, 35], [1860, 38], [1870, 41], [1880, 43], [1890, 45], [1900, 47], [1910, 48], [1920, 47], [1930, 45], [1940, 41], [1950, 37], [1960, 33], [1970, 33], [1980, 38], [1990, 45], [2000, 49], [2010, 52]], "sense_ids": ["chair_nn01-9765748", "chair_nn01-9765918", "chair_nn01-9766034", "chair_nn01-9766086", "chair_nn01-9766128", "chair_nn01-9766167", "chair_nn01-9766191", "chair_nn01-9766261", "chair_nn01-9766309", "chair_nn01-9766353", "chair_nn01-9766415", "chair_nn01-9766435", "chair_nn01-9766456", "chair_nn01-9766508", "chair_nn01-9766538", "chair_nn01-9766562", "chair_nn01-9766607", "chair_nn01-9766670", "chair_nn01-9766761", "chair_nn01-9766784", "chair_nn01-9766861", "chair_nn01-9766921", "chair_nn01-9766962", "chair_nn01-9766979", "chair_nn01-128025765", "chair_nn01-218565101"], "definition": "A seat for one person (always implying more or less of comfort and ease); now the common name for the movable four-legged seat with a rest for the back, which constitutes, in many forms of rudeness or elegance, an ordinary article of household furniture, and is also used in gardens or wherever it is usual to sit. to take a chair: to take a seat, be seated.", "main_entry": true, "inflections": [{"region": "British", "inflections": [{"form": "chair", "part_of_speech": "NN"}, {"form": "chairs", "part_of_speech": "NNS"}]}, {"region": "US", "inflections": [{"form": "chair", "part_of_speech": "NN"}, {"form": "chairs", "part_of_speech": "NNS"}]}], "frequency_id": "chair_nn01-fq", "oed_reference": "chair, n.1", "pronunciations": [{"ipa": ["t\u0283\u025b\u02d0"], "region": "British"}, {"ipa": ["t\u0283\u025b(\u0259)r"], "region": "US"}], "parts_of_speech": ["NN"], "primary_sense_id": "chair_nn01-9765748"}]
Extracted definition.
Set definition to query object.
Now to get and set the word ID.
The wordID was grabbed as:
chair_nn01In MainMenu()
The user's input was read as:
r
Root selected.
Now to call the root endpoint.
Going to look up roots
API call URL is:
https://oed-researcher-api.oxfordlanguages.com/oed/api/v0.2/
Making the request:
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 to get ROOTS. Bloody Roots!!
Called callRootsAPI
Making the request
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[System.String,System.Net.Http.HttpClient+<GetStringAsyncCore>d__41]
Ran roots synchronously.
In MainMenu()
The user's input was read as:
x
Exit selected.
68 changes: 68 additions & 0 deletions logs/Log_OxfordApplication_20210416-2046.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Leaving Main method.
Starting Main Menu
In MainMenu()
The user's input was read as:
r
Root selected.
Now to call the root endpoint.
In MainMenu()
The user's input was read as:
d
Word look up selected
Found that QueryMode is set to words.
Looking up the word:
chair
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": "chair_nn01", "band": 6, "meta": {"created": 1889, "revised": false, "updated": null}, "lemma": "chair", "oed_url": "https://www.oed.com/view/Entry/30215#eid9765745", "daterange": {"end": null, "start": 1297, "obsolete": false, "rangestring": "1297\u2014"}, "etymology": {"etymons": [{"word": "cha\u00ebre", "language": "French"}, {"word": "chaiere", "language": "French"}], "etymology_type": "borrowingHybrid", "etymon_language": [["European languages", "Italic", "Romance", "Italo-Western", "Gallo-Romance", "French"]], "source_language": [["European languages", "Italic", "Romance", "Italo-Western", "Gallo-Romance", "French"], ["European languages", "Greek"]], "etymology_summary": "A borrowing from French, combined with an English element."}, "first_use": "Chronicle of Robert of Gloucester", "frequency": [[1750, 17], [1760, 19], [1770, 20], [1780, 20], [1790, 23], [1800, 24], [1810, 26], [1820, 29], [1830, 30], [1840, 33], [1850, 35], [1860, 38], [1870, 41], [1880, 43], [1890, 45], [1900, 47], [1910, 48], [1920, 47], [1930, 45], [1940, 41], [1950, 37], [1960, 33], [1970, 33], [1980, 38], [1990, 45], [2000, 49], [2010, 52]], "sense_ids": ["chair_nn01-9765748", "chair_nn01-9765918", "chair_nn01-9766034", "chair_nn01-9766086", "chair_nn01-9766128", "chair_nn01-9766167", "chair_nn01-9766191", "chair_nn01-9766261", "chair_nn01-9766309", "chair_nn01-9766353", "chair_nn01-9766415", "chair_nn01-9766435", "chair_nn01-9766456", "chair_nn01-9766508", "chair_nn01-9766538", "chair_nn01-9766562", "chair_nn01-9766607", "chair_nn01-9766670", "chair_nn01-9766761", "chair_nn01-9766784", "chair_nn01-9766861", "chair_nn01-9766921", "chair_nn01-9766962", "chair_nn01-9766979", "chair_nn01-128025765", "chair_nn01-218565101"], "definition": "A seat for one person (always implying more or less of comfort and ease); now the common name for the movable four-legged seat with a rest for the back, which constitutes, in many forms of rudeness or elegance, an ordinary article of household furniture, and is also used in gardens or wherever it is usual to sit. to take a chair: to take a seat, be seated.", "main_entry": true, "inflections": [{"region": "British", "inflections": [{"form": "chair", "part_of_speech": "NN"}, {"form": "chairs", "part_of_speech": "NNS"}]}, {"region": "US", "inflections": [{"form": "chair", "part_of_speech": "NN"}, {"form": "chairs", "part_of_speech": "NNS"}]}], "frequency_id": "chair_nn01-fq", "oed_reference": "chair, n.1", "pronunciations": [{"ipa": ["t\u0283\u025b\u02d0"], "region": "British"}, {"ipa": ["t\u0283\u025b(\u0259)r"], "region": "US"}], "parts_of_speech": ["NN"], "primary_sense_id": "chair_nn01-9765748"}]
Extracted definition.
Set definition to query object.
Now to get and set the word ID.
The wordID was grabbed as:
chair_nn01In MainMenu()
The user's input was read as:
r
Root selected.
Now to call the root endpoint.
Going to look up roots
API call URL is:
https://oed-researcher-api.oxfordlanguages.com/oed/api/v0.2/
Making the request:
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 to get ROOTS. Bloody Roots!!
Called callRootsAPI
Making the request
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[System.String,System.Net.Http.HttpClient+<GetStringAsyncCore>d__41]
Ran roots synchronously.
In MainMenu()
The user's input was read as:
x
Exit selected.
Loading

0 comments on commit 6799748

Please sign in to comment.