Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
import json
import urllib.parse
# Load lemmas
with open("bm_lemma.json") as inn:
bm_list = json.load(inn)
with open("nn_lemma.json") as inn:
nn_list = json.load(inn)
# Merge bm and nn
words = {}
for row in bm_list:
words[row[0]] = words.get(row[0], set())
words[row[0]].add(("bm", row[1]))
for row in nn_list:
words[row[0]] = words.get(row[0], set())
words[row[0]].add(("nn", row[1]))
url_counter = 0
write_start = lambda out: out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">\n")
filenum = 0
out = open(f"src/sitemap/xml/sitemap_{filenum}.xml", "w")
write_start(out)
seen_articles = set()
for word, articles in words.items():
if url_counter > 20000:
out.write("</urlset>\n")
url_counter = 0
out.close()
filenum += 1
out = open(f"src/sitemap/xml/sitemap_{filenum}.xml", "w")
write_start(out)
for article in articles:
if article[1] not in seen_articles:
out.write("\t<url>\n")
out.write(f"\t\t<loc>https://ordbokene.no/{article[0]}/{article[1]}</loc>\n")
out.write(f"\t\t<xhtml:link rel=\"alternative\" href=\"https://ordbokene.no/{article[0]}/{article[1]}/{urllib.parse.quote(word)}\"/>\n")
out.write("\t</url>\n")
url_counter += 1
seen_articles.add(article[1])
# Omit articles
if len(articles) > 1:
out.write("\t<url>\n")
out.write(f"\t\t<loc>https://ordbokene.no//bm,nn/{urllib.parse.quote(word)}</loc>\n")
out.write("\t</url>\n")
url_counter += 1
out.write("</urlset>\n")
out.close()
with open("src/sitemap/xml/sitemap_index.xml", "w") as outfile:
outfile.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n")
outfile.write("<sitemap><loc>https://ordbokene.no/sitemap.xml</loc></sitemap>\n")
for num in range(filenum+1):
outfile.write(f"<sitemap><loc>https://ordbokene.no/sitemap_{num}.xml</loc></sitemap>\n")
outfile.write("</sitemapindex>")
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://ordbokene.no</loc>
<xhtml:link rel="alternative" href="https://ordbokene.no/bm,nn"/>
</url>
<url>
<loc>https://ordbokene.no/bm</loc>
</url>
<url>
<loc>https://ordbokene.no/nn</loc>
</url>
<url>
<loc>https://ordbokene.no/om</loc>
</url>
</urlset>
\ No newline at end of file
var entities = {
'bob': {
'bm': {
},
'nob': {
'nn': {
}
}
......
var mapping = {
"bob": {
"NOUN": "Substantiv",
"VERB": "Verb",
"ADJ": "Adjektiv",
"ADP": "Preposisjon",
"PFX": "Prefiks",
"ADV": "Adverb",
"DET": "Determinativ",
"PROPN": "Egennavn",
"ABBR": "Forkortelse",
"INTJ": "Interjeksjon",
"SYM": "Symbol",
"PRON": "Pronomen",
"CCONJ": "Konjunksjon",
"SCONJ": "Subjunksjon",
"INFM": "Infinitivsmerke",
"COMPPFX": "I sammensetting",
"Masc": "hankjønn.",
"Fem": "hunkjønn.",
"Neuter": "Nøytr.",
"Uninfl": "ubøyelig"
},
"nob": {
"NOUN": "Substantiv",
"VERB": "Verb",
"ADJ": "Adjektiv",
"ADP": "Preposisjon",
"PFX": "Prefiks",
"ADV": "Adverb",
"DET": "Determinativ",
"PROPN": "Egennavn",
"ABBR": "Forkortelse",
"INTJ": "Interjeksjon",
"SYM": "Symbol",
"PRON": "Pronomen",
"CCONJ": "Konjunksjon",
"SCONJ": "Subjunksjon",
"INFM": "Infinitivsmerke",
"COMPPFX": "I sammensetting",
"Masc": "hankjønn.",
"Fem": "hokjønn",
"Neuter": "nøytr.",
"Uninfl": "ubøyd"
var fraction = function(numerator, denominator) {
var superscript = {
'0': '',
'1': '¹',
'2': '²',
'3': '³',
'4': '',
'5': '',
'6': '',
'7': '',
'8': '',
'9': '',
'+': '',
'-': '',
'=': '',
'(': '',
')': '',
'a': '',
'b': '',
'c': '',
'd': '',
'e': '',
'f': '',
'g': '',
'h': 'ʰ',
'i': '',
'j': 'ʲ',
'k': '',
'l': 'ˡ',
'm': '',
'n': '',
'o': '',
'p': '',
'r': 'ʳ',
's': 'ˢ',
't': '',
'u': '',
'v': '',
'w': 'ʷ',
'x': 'ˣ',
'y': 'ʸ',
'z': '',
' ': ' '
}
var subscript = {
'0': '',
'1': '',
'2': '',
'3': '',
'4': '',
'5': '',
'6': '',
'7': '',
'8': '',
'9': '',
'+': '',
'-': '',
'=': '',
'(': '',
')': '',
'a': '',
'e': '',
'h': '',
'i': '',
'j': '',
'k': '',
'l': '',
'm': '',
'n': '',
'o': '',
'p': '',
'r': '',
's': '',
't': '',
'u': '',
'v': '',
'x': '',
' ': ' '
};
var fractions = {
'1/2': '½',
'1/3': '',
'2/3': '',
'1/4': '¼',
'3/4': '¾',
'1/5': '',
'2/5': '',
'3/5': '',
'4/5': '',
'1/6': '',
'5/6': '',
'1/7': '',
'1/8': '',
'3/8': '',
'5/8': '',
'7/8': '',
'1/9': '',
'1/10': ''
};
let other_fraction = null
let num_sup = numerator.toString().split('').map(x => superscript[x] || '_').join('')
let den_sub = denominator.toString().split('').map(x => subscript[x] || '_').join('')
if (! num_sup.includes('_') && ! den_sub.includes('_')) {
other_fraction = num_sup + '' + den_sub
}
return fractions[numerator + '/' + denominator] && {type: 'plain', html: fractions[numerator + '/' + denominator] }
|| other_fraction && {type: 'plain', html: other_fraction }
|| {type: 'fraction', html: '', num: numerator, denom: denominator}
}
var group_list = function(grps, dictionary) {
var grp_collection = new Set()
grps.forEach(function(lemma){
lemma.paradigm_info.forEach(function(grp){
if (grp.tags){
grp_collection.add(grp.tags[0] == 'NOUN' ? mapping[dictionary][grp.tags[0]] + ', ' + mapping[dictionary][grp.tags[1]] : mapping[dictionary][grp.tags[0]])
}
})
})
if (grp_collection.has('Substantiv, Mask.') && grp_collection.has('Substantiv, Fem.')) {
grp_collection.delete('Substantiv, Mask.')
grp_collection.delete('Substantiv, Fem.')
grp_collection.add('Substantiv, Mask./Fem.')
const roman_hgno = function(lemma) {
let hgint = parseInt(lemma.hgno)
if (hgint > 0) {
return ["I","II","III","IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII", "XIII", "XIV", "XV", "XVI"][hgint-1]
}
return Array.from(grp_collection).join(' - ')
return ""
}
export default { group_list}
export default { fraction, roman_hgno }
module.exports = {
runtimeCompiler: true,
transpileDependencies: [
'vuetify'
]
],
devServer: {
https: false
},
pluginOptions: {
i18n: {
fallbackLocale: 'eng',
localeDir: 'locales',
enableInSFC: true,
includeLocales: false,
enableBridge: true
}
}
}