Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion corpustools/adder.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def update_parallel_data(none_dupe_path, parallelpath):
)
)
this_para_corpuspath.metadata.set_parallel_text(
none_dupe_path.lang, none_dupe_path.filename.name
none_dupe_path.lang, none_dupe_path.filepath.name
)
this_para_corpuspath.metadata.write_file()
none_dupe_path.metadata.set_parallel_text(
Expand Down
12 changes: 8 additions & 4 deletions corpustools/crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import os
import sys
from pathlib import Path

from corpustools import adder, namechanger, util

Expand All @@ -30,7 +31,7 @@ class Crawler:

def __init__(self):
"""Initialise the Crawler class."""
self.goaldir = str(os.getenv("GTFREE"))
self.goaldir = Path(os.getenv("GTLANGS"))
self.unvisited_links = set()
self.visited_links = set()
self.download_links = set()
Expand All @@ -39,7 +40,7 @@ def __init__(self):

def __del__(self):
"""Add all files to the corpus."""
for (_, corpus_adder) in self.corpus_adders.items():
for _, corpus_adder in self.corpus_adders.items():
corpus_adder.add_files_to_working_copy()

def save_pages(self, pages):
Expand All @@ -49,7 +50,7 @@ def save_pages(self, pages):
"""
parallelpath = ""

for (url, lang) in pages:
for url, lang in pages:
try:
(_, tmpname) = self.downloader.download(url)
except adder.AdderError as error:
Expand All @@ -59,7 +60,7 @@ def save_pages(self, pages):
os.path.basename(tmpname)
)
normalised_path = os.path.join(
self.corpus_adders[lang].goaldir, normalised_name
self.corpus_adders[lang].goalpath, normalised_name
)

if not os.path.exists(normalised_path):
Expand All @@ -70,3 +71,6 @@ def save_pages(self, pages):
else:
parallelpath = normalised_path
print(file=sys.stderr)

def name_from_url(self, url):
os.path.basename(url)
10 changes: 5 additions & 5 deletions corpustools/saami_crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

from corpustools import (
argparse_version,
nrk_no_crawler,
samas_crawler,
# nrk_no_crawler,
# samas_crawler,
samediggi_fi_crawler,
samediggi_no_crawler,
)
Expand All @@ -38,7 +38,7 @@ def parse_options():
"""
parser = argparse.ArgumentParser(
parents=[argparse_version.parser],
description="Crawl saami sites (for now, only www.samediggi.fi).",
description="Crawl saami sites (for now, only samediggi.no and www.samediggi.fi).",
)

parser.add_argument("sites", nargs="+", help="The sites to crawl")
Expand All @@ -54,8 +54,8 @@ def main():
crawlers = {
"www.samediggi.fi": samediggi_fi_crawler.SamediggiFiCrawler(),
"samediggi.no": samediggi_no_crawler.SamediggiNoCrawler(),
"nrk.no": nrk_no_crawler.NrkSmeCrawler(),
"samas.no": samas_crawler.SamasCrawler(),
# "nrk.no": nrk_no_crawler.NrkSmeCrawler(),
# "samas.no": samas_crawler.SamasCrawler(),
}

for site in args.sites:
Expand Down
Loading