Skip to content

Instantly share code, notes, and snippets.

@7shi
Created May 8, 2020 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7shi/7a7326e1d87ca2d00f984a1877650ef3 to your computer and use it in GitHub Desktop.
Save 7shi/7a7326e1d87ca2d00f984a1877650ef3 to your computer and use it in GitHub Desktop.
[F#] Volapük dictionary converter
// http://personal.southern.edu/~caviness/Volapuk/Misc/eng-vol.htm
// http://personal.southern.edu/~caviness/Volapuk/Misc/vol-eng.htm
// https://gist.github.com/7shi/de072cd867f3899aa285bc9343110bff
#load "XmlParser.fsx"
open System
open System.IO
open System.Text
open XmlParser
do
use sr = new StreamReader("eng-vol.htm")
use sw = new StreamWriter("eng-vol.txt")
let mutable src = ""
let line = ref ""
let readLine() =
line := sr.ReadLine()
not <| isNull !line
while readLine() do
if (!line).StartsWith "&nbsp;" then
use xp = new XmlParser(!line)
if xp.Read() then
let t = (fromEntity xp.Text).TrimStart()
if t.StartsWith "-" then
src <- src + " | " + t.[1..].TrimStart()
else
sw.WriteLine src
src <- t
while xp.Read() do
src <- src + fromEntity xp.Text
else
if src <> "" then
sw.WriteLine(src)
src <- ""
if (!line).StartsWith "<b>" then
use xp = new XmlParser(!line)
while xp.Read() do
src <- src + fromEntity xp.Text
do
use sr = new StreamReader("vol-eng.htm")
use sw = new StreamWriter("vol-eng.txt")
let line = ref ""
let readLine() =
line := sr.ReadLine()
not <| isNull !line
while readLine() && !line <> "</CENTER>" do ()
while readLine() && !line <> "<hr>" do
if (!line).StartsWith "<p><center>" || !line = "<br>" then () else
use xp = new XmlParser(!line)
while xp.Read() do
sw.Write(fromEntity xp.Text)
if xp.Tag = "br" then sw.WriteLine()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment