-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
78 changed files
with
1,720 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<SuperMemoCollection> | ||
<Count>5</Count> | ||
<SuperMemoElement> | ||
<ID>1</ID> | ||
<Title>W. Turner - 1548</Title> | ||
<Type>Topic</Type> | ||
<Content> | ||
<Question>Carettes growe in al countreis in plentie. --W. Turner, 1548</Question> | ||
<SuperMemoReference>&lt;H5 dir=ltr align=left&gt;&lt;Font size=&quot;1&quot; style=&quot;color: transparent&quot;&gt; SuperMemo Reference:&lt;/font&gt;&lt;br&gt;&lt;FONT class=reference&gt;Title:&quot;My Test Quote&quot; &lt;br&gt;Source: Oxford English Dictionary</SuperMemoReference> | ||
</Content> | ||
</SuperMemoElement> | ||
<SuperMemoElement> | ||
<ID>2</ID> | ||
<Title>T. Cooper - 1565</Title> | ||
<Type>Topic</Type> | ||
<Content> | ||
<Question>Carota..the wilde caret. --T. Cooper, 1565</Question> | ||
<SuperMemoReference>&lt;H5 dir=ltr align=left&gt;&lt;Font size=&quot;1&quot; style=&quot;color: transparent&quot;&gt; SuperMemo Reference:&lt;/font&gt;&lt;br&gt;&lt;FONT class=reference&gt;Title:&quot;My Test Quote&quot; &lt;br&gt;Source: Oxford English Dictionary</SuperMemoReference> | ||
</Content> | ||
</SuperMemoElement> | ||
<SuperMemoElement> | ||
<ID>3</ID> | ||
<Title> - 1634</Title> | ||
<Type>Topic</Type> | ||
<Content> | ||
<Question>Parsenipps and carrootes. --, 1634</Question> | ||
<SuperMemoReference>&lt;H5 dir=ltr align=left&gt;&lt;Font size=&quot;1&quot; style=&quot;color: transparent&quot;&gt; SuperMemo Reference:&lt;/font&gt;&lt;br&gt;&lt;FONT class=reference&gt;Title:&quot;My Test Quote&quot; &lt;br&gt;Source: Oxford English Dictionary</SuperMemoReference> | ||
</Content> | ||
</SuperMemoElement> | ||
<SuperMemoElement> | ||
<ID>4</ID> | ||
<Title>R. Cotgrave - 1611</Title> | ||
<Type>Topic</Type> | ||
<Content> | ||
<Question>Calculateur, a reckoner, calculator. --R. Cotgrave, 1611</Question> | ||
<SuperMemoReference>&lt;H5 dir=ltr align=left&gt;&lt;Font size=&quot;1&quot; style=&quot;color: transparent&quot;&gt; SuperMemo Reference:&lt;/font&gt;&lt;br&gt;&lt;FONT class=reference&gt;Title:&quot;My Test Quote&quot; &lt;br&gt;Source: Oxford English Dictionary</SuperMemoReference> | ||
</Content> | ||
</SuperMemoElement> | ||
<SuperMemoElement> | ||
<ID>5</ID> | ||
<Title>D. Defoe - 1722</Title> | ||
<Type>Topic</Type> | ||
<Content> | ||
<Question>Calculators of Nativities. --D. Defoe, 1722</Question> | ||
<SuperMemoReference>&lt;H5 dir=ltr align=left&gt;&lt;Font size=&quot;1&quot; style=&quot;color: transparent&quot;&gt; SuperMemo Reference:&lt;/font&gt;&lt;br&gt;&lt;FONT class=reference&gt;Title:&quot;My Test Quote&quot; &lt;br&gt;Source: Oxford English Dictionary</SuperMemoReference> | ||
</Content> | ||
</SuperMemoElement> | ||
</SuperMemoCollection> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,105 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Xml; | ||
using System.Net; | ||
|
||
|
||
namespace OxfordV2 | ||
{ | ||
public class SavedQueries | ||
public static class SavedQueries | ||
{ | ||
public string WordID { get; set; } | ||
public List<Quote> Quotes { get; set; } | ||
public static bool Instance { get; set; } = false; | ||
public static bool DeleteOnExport { get; set; } = true; | ||
|
||
public static string WordID { get; set; } | ||
public static List<Quote> Quotes { get; set; } | ||
|
||
public static string ExportFileName { get; set; } = "OED-export.xml"; | ||
|
||
static SavedQueries() | ||
{ | ||
Instance=true; | ||
Quotes = new(); | ||
} | ||
|
||
public static void AddQuote(Quote quote) { | ||
Quotes.Add(quote); | ||
if (Quotes.Count == 1) { | ||
Console.WriteLine($"{Quotes.Count} quote saved for export."); | ||
} | ||
else { | ||
Console.WriteLine($"{Quotes.Count} quotes saved for export."); | ||
} | ||
} | ||
|
||
public static void RenderXML() { | ||
string xmlFile = Path.Combine(Environment.CurrentDirectory, ExportFileName); | ||
File.Delete(xmlFile); | ||
FileStream xmlFileStream = File.Create(xmlFile); | ||
|
||
XmlWriter xml = XmlWriter.Create(xmlFileStream, | ||
new XmlWriterSettings { Indent = true }); | ||
|
||
xml.WriteStartDocument(); | ||
xml.WriteStartElement("SuperMemoCollection"); | ||
int count = Quotes.Count; | ||
xml.WriteElementString("Count", $"{count}"); | ||
// @TODO Add count number and ID number | ||
for (int i = 0; i < Quotes.Count; i++) { | ||
try { | ||
xml.WriteStartElement("SuperMemoElement"); | ||
int ID = i + 1; | ||
xml.WriteElementString("ID", $"{ID}"); | ||
xml.WriteElementString("Title", $"{Quotes[i].Author} - {Quotes[i].Year}"); | ||
xml.WriteElementString("Type", "Topic"); | ||
xml.WriteStartElement("Content"); | ||
xml.WriteElementString("Question", $"{Quotes[i].Text} --{Quotes[i].Author}, {Quotes[i].Year}"); | ||
|
||
string encoded = WebUtility.HtmlEncode("<H5 dir=ltr align=left><Font size=\"1\" style=\"color: transparent\"> SuperMemo Reference:</font><br><FONT class=reference>Title:\"My Test Quote\" <br>Source: Oxford English Dictionary"); | ||
xml.WriteElementString("SuperMemoReference", encoded); | ||
|
||
xml.WriteEndElement(); | ||
xml.WriteEndElement(); | ||
|
||
} | ||
catch (AggregateException ae) | ||
{ | ||
var ex = ae.Flatten().InnerExceptions; | ||
Console.WriteLine("Error writing XML document:"); | ||
foreach (var exception in ex) | ||
{ | ||
Console.WriteLine($"{ex.ToString()}"); | ||
} | ||
} | ||
} | ||
|
||
try { | ||
xml.WriteEndElement(); | ||
xml.WriteEndDocument(); | ||
xml.Flush(); | ||
|
||
xml.Close(); | ||
xmlFileStream.Close(); | ||
|
||
Console.WriteLine("The XML file is saved here:"); | ||
Console.WriteLine(xmlFile); | ||
|
||
public string ExportFileName { get; set; } = "OED-export.txt"; | ||
|
||
Trace.WriteLine("The contents of the exported XML file are:"); | ||
Trace.WriteLine(File.ReadAllText(xmlFile)); | ||
Console.WriteLine("Please press enter:.........."); | ||
Console.ReadLine(); | ||
} | ||
catch (AggregateException ae) | ||
{ | ||
var ex = ae.Flatten().InnerExceptions; | ||
Console.WriteLine("Error exporting XML document:"); | ||
foreach (var exception in ex) | ||
{ | ||
Console.WriteLine($"{ex.ToString()}"); | ||
} | ||
} | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
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: | ||
x | ||
Exit selected. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
Leaving Main method. | ||
Starting Main Menu | ||
In MainMenu() | ||
Automatically looking up user entered word: | ||
cotton | ||
Found that QueryMode is set to words. | ||
Looking up the word: | ||
cotton | ||
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": "cotton_nn01", "band": 8, "meta": {"created": 1893, "revised": false, "updated": null}, "lemma": "cotton", "oed_url": "https://www.oed.com/view/Entry/42480#eid8039299", "daterange": {"end": null, "start": 1400, "obsolete": false, "rangestring": "c1400\u2014"}, "etymology": {"etymons": [{"word": "coton", "language": "French"}], "etymology_type": "borrowing", "etymon_language": [["European languages", "Italic", "Romance", "Italo-Western", "Gallo-Romance", "French"]], "source_language": [["European languages", "Italic", "Romance", "Italo-Western", "Ibero-Romance", "Spanish"], ["Middle Eastern and Afro-Asiatic languages", "Afro-Asiatic", "Semitic", "Arabic"]], "etymology_summary": "A borrowing from French."}, "first_use": "Mandeville's Travels", "frequency": [[1750, 9.8], [1760, 12], [1770, 13], [1780, 15], [1790, 17], [1800, 20], [1810, 22], [1820, 25], [1830, 28], [1840, 30], [1850, 31], [1860, 32], [1870, 33], [1880, 36], [1890, 39], [1900, 40], [1910, 45], [1920, 50], [1930, 51], [1940, 49], [1950, 44], [1960, 36], [1970, 30], [1980, 24], [1990, 20], [2000, 19], [2010, 18]], "sense_ids": ["cotton_nn01-8039303", "cotton_nn01-8039415", "cotton_nn01-8039448", "cotton_nn01-8039461", "cotton_nn01-8039500", "cotton_nn01-8039549", "cotton_nn01-8039616", "cotton_nn01-8039644", "cotton_nn01-8039733", "cotton_nn01-8039754", "cotton_nn01-8039812", "cotton_nn01-8039830", "cotton_nn01-8039844"], "definition": "The white fibrous substance, soft and downy like wool, which clothes the seeds of the cotton-plant (Gossypium); used (more extensively than any other material) for making cloth and thread, and for various purposes in the arts.", "main_entry": true, "inflections": [{"region": "British", "inflections": [{"form": "cotton", "part_of_speech": "NN"}, {"form": "cottons", "part_of_speech": "NNS"}]}, {"region": "US", "inflections": [{"form": "cotton", "part_of_speech": "NN"}, {"form": "cottons", "part_of_speech": "NNS"}]}], "frequency_id": "cotton_nn01-fq", "oed_reference": "cotton, n.1", "pronunciations": [{"ipa": ["\u02c8k\u0252tn"], "region": "British"}, {"ipa": ["\u02c8k\u0251tn"], "region": "US"}], "parts_of_speech": ["NN"], "primary_sense_id": "cotton_nn01-8039303"}] | ||
Extracted definition. | ||
Set definition to query object. | ||
Now to get and set the word ID. | ||
The wordID was grabbed as: | ||
cotton_nn01The user's input was read as: | ||
q | ||
Get quotaions based on word selected. | ||
API.cs is starting quotations mode. | ||
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 | ||
|
||
Called callQuotationsAPI | ||
Got quotation responses. | ||
Set JSONResponse to the response. | ||
Ran quotations synchronously. | ||
Parsing quotations JSON. | ||
First quote grabbed as: | ||
|
||
In MainMenu() | ||
The user's input was read as: | ||
x | ||
Exit selected. |
Oops, something went wrong.