Skip to content

Instantly share code, notes, and snippets.

@7shi
Last active May 10, 2020 09:19
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/6a037b089eff7b14b7d8982d76ec9d08 to your computer and use it in GitHub Desktop.
Save 7shi/6a037b089eff7b14b7d8982d76ec9d08 to your computer and use it in GitHub Desktop.
[F#] Novial dictionary converter
// https://sites.google.com/site/noviallexike/novial-lexike-1930
// https://gist.github.com/7shi/de072cd867f3899aa285bc9343110bff
#load "XmlParser.fsx"
open System.IO
open XmlParser
do
use xp = new XmlParser(new StreamReader("novial.html"))
use sw = new StreamWriter("novial.txt")
let mutable prev = ""
for p in xp.SearchEach("p") do
let mutable s = ""
while xp.Read() && xp.Tag <> "/p" do
if s.Length > 0 then s <- s + " "
s <- s + xp.Text.Replace("\n", " ")
while s.IndexOf " " >= 0 do
s <- s.Replace(" ", " ")
s <- s.Replace(" \xA0 ", " ").Replace(" |", " |").Trim()
if s = "A" then
prev <- s
elif prev.Length > 0 then
sw.Write(prev)
if s.StartsWith("Pronuntiatione:") then
sw.Write(" | ")
else
sw.WriteLine()
prev <- s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment