- 96 All Categories
- 2 LexiStats Corner
- 3 Review my code
- 5 Tutorials and presentations
- 25 Frequently asked questions
- 3 How to get useful technical help
- 1 Member guidelines
- 5 Suggest an improvement
- 12 Report a bug
- 5 Ask the Community: Other
- 20 Ask the Community: Technical and operational questions
- 10 General
For me, I would prefer to not have to use a Lemmatron endpoint, but instead use a "Wordlist" endpoint that automatically includes all "grammatical feature" (plurals, etc) words and all forms of words.
The only filter I really need is one similar to this (from the existing Wordlist endpoint):
(exclude words that are exclusively proper nouns, abbreviations or acronyms, while including words like "Hoover", which is a proper noun AND a verb)
Not really sure if this addresses your question, but you tagged me so I thought I would reply. The above functionality is all I personally need from the API.
Hello. I am posting because I thought others may find this useful.
I have written some VB code which takes a word list (a single text file with 1 word per line: OriginalList.txt), then goes through the entire list and separates the words into different files, according to the length of the word. Ie:
Words that have symbols (apostrophe, etc) are not included in the above files, and get dumped into another file (invalid.txt). Also, words < 2 or > 6 letters also get dumped into this file.
The procedure takes a few minutes to complete, depending on how quick your PC is.
I originally wrote this code to prepare some word lists, for use in my game "Covert Word" (winner of the API competition). Covert Word
I will be using it again, once Oxford have released the new WordList endpoint that they are working on, that has all forms of words (run, runs, ran, running, etc), instead of just the base-forms.
This is the code. This deals with words 2 letters up to 6 letters in length, but could be modified for more.
Imports System.IO Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim pth As String pth = "C:\newWordLists\" Using r As StreamReader = New StreamReader(pth & "OriginalList.txt") Dim wrd As String wrd = r.ReadLine wrd = Trim(wrd) wrd = wrd.ToLower Do While (Not wrd Is Nothing) 'change this line if less than 2, or more than 6 letters is required: If wrd.Length < 2 Or wrd.Length > 6 Or Not isAlpha(wrd) Then 'if word is invalid My.Computer.FileSystem.WriteAllText(pth & "invalid.txt", Chr(13) & Chr(10) & wrd, True) Else 'word is valid If wrd.Length = 2 Then My.Computer.FileSystem.WriteAllText(pth & "2_letters.txt", Chr(13) & Chr(10) & wrd, True) ElseIf wrd.Length = 3 Then My.Computer.FileSystem.WriteAllText(pth & "3_letters.txt", Chr(13) & Chr(10) & wrd, True) ElseIf wrd.Length = 4 Then My.Computer.FileSystem.WriteAllText(pth & "4_letters.txt", Chr(13) & Chr(10) & wrd, True) ElseIf wrd.Length = 5 Then My.Computer.FileSystem.WriteAllText(pth & "5_letters.txt", Chr(13) & Chr(10) & wrd, True) ElseIf wrd.Length = 6 Then My.Computer.FileSystem.WriteAllText(pth & "6_letters.txt", Chr(13) & Chr(10) & wrd, True) 'add more of the above here if less than 2, or more than 6 letters is required End If End If wrd = r.ReadLine Loop End Using MsgBox("finished") End Sub Function isAlpha(ByVal str As String) As Boolean Dim iPos As Integer Dim bolValid As Boolean iPos = 1 bolValid = True While iPos <= Len(str) And bolValid If Asc(UCase(Mid(str, iPos, 1))) < Asc("A") Or _ Asc(UCase(Mid(str, iPos, 1))) > Asc("Z") Then _ bolValid = False iPos = iPos + 1 End While isAlpha = bolValid End Function End Class2
Sorry, forgot to mention that to use the Json objects, you might need to get the .dll and add it as a reference in your project. You can get it here:
Hello. My language of choice is VB.Net. I wrote some code to use the API's Wordlist feature and thought maybe others could benefit from this.
What I did was create a new Web Application in Visual Studio, added a "web form" to the project. The HTML in my .aspx file looks something like this...
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="OxfordAPI._Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div id="status" runat="server"></div> <div id="main" runat="server"></div> </form> </body> </html>
And my VB in my .aspx.vb file looks like this...
Imports System Imports System.Net Imports System.IO Imports Newtonsoft.Json Imports Newtonsoft.Json.Linq Public Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim app_id As String = "YourAppID" Dim app_key As String = "YourAppKey" 'the following line is the parameters for the WordList call (edit as needed) Dim params As String = "lexicalCategory=noun?exclude=grammaticalFeatures=abbreviation&word_length=%3C6&exact=false" 'Put the whole URL together Dim url = "https://od-api.oxforddictionaries.com:443/api/v1/wordlist/en/" & params ' Create a request for the URL. Dim request As WebRequest = WebRequest.Create(url) 'set the credentials. request.Headers.Add("app_id:" & app_id) request.Headers.Add("app_key:" & app_key) ' Get the response. Dim response As WebResponse = request.GetResponse() ' Display the status on the page status.InnerHtml = "STATUS: " & CType(response, HttpWebResponse).StatusDescription ' Get the stream containing content returned by the server. Dim dataStream As Stream = response.GetResponseStream() ' Open the stream using a StreamReader for easy access. Dim reader As New StreamReader(dataStream) ' Read the content. Dim responseFromServer As String = reader.ReadToEnd() 'as the results come in the form of Json, we need to extract all the words using a loop Dim rootResults = JObject.Parse(responseFromServer) Dim results As List(Of JToken) = rootResults.Children().ToList Dim newHTML As String = "" For Each item As JProperty In results item.CreateReader() Select Case item.Name Case "results" For Each subitem As JObject In item.Values newHTML = newHTML & "<br />" & subitem("word").ToString Next End Select Next ' Display the content. main.InnerHtml = newHTML ' Clean up the streams and the response. reader.Close() response.Close() End Sub End Class
Keep in mind that this code can easily be converted to C#, if that is what you prefer. If you want the VB code for other API end points, the above code could be modified to achieve it.
I hope someone finds this useful1