From 41faa7a375eb3462f07f43ebf2394af6a286492c Mon Sep 17 00:00:00 2001 From: maxirmx Date: Tue, 13 Oct 2015 12:03:57 +0300 Subject: [PATCH] Wordnet download fix --- .appveyor.yml | 10 ++++----- appveyor/download.ps1 | 51 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 appveyor/download.ps1 diff --git a/.appveyor.yml b/.appveyor.yml index 552d5d0c4..00a927247 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -52,12 +52,10 @@ install: build_script: # Build the compiled extension #- "%CMD_IN_ENV% python setup.py build_ext --inplace" - - "md corpora\\en" - - "cd corpora\\" - - "wget --no-check-certificate http://wordnetcode.princeton.edu/3.0/WordNet-3.0.tar.gz" - - "tar -xzf WordNet-3.0.tar.gz" - - "mv WordNet-3.0 wordnet" - - "cd ..\\..\\" + - ps: appveyor\download.ps1 + - "tar -xzf corpora\en\wordnet.tar.gz" + - "ls \"C:/projects/spacy/include/" + - "ls \"C:/projects/spacy/include/" test_script: diff --git a/appveyor/download.ps1 b/appveyor/download.ps1 new file mode 100644 index 000000000..d5af114cc --- /dev/null +++ b/appveyor/download.ps1 @@ -0,0 +1,51 @@ +# Wordnet download Windows script + +$WORDNET_URL = "http://wordnetcode.princeton.edu/3.0/WordNet-3.0.tar.gz" +$WORDNET_RELATIVE_PATH = "corpora\en" + +function Download ($filename, $url) { + $webclient = New-Object System.Net.WebClient + + $basedir = $pwd.Path + "\" + $filepath = $basedir + $filename + if (Test-Path $filename) { + Write-Host "Reusing" $filepath + return $filepath + } + NET + # Download and retry up to 3 times in case of network transient errors. + Write-Host "Downloading" $filename "from" $url + $retry_attempts = 2 + for ($i = 0; $i -lt $retry_attempts; $i++) { + try { + $webclient.DownloadFile($url, $filepath) + break + } + Catch [Exception]{ + Start-Sleep 1 + } + } + if (Test-Path $filepath) { + Write-Host "File saved at" $filepath + } else { + # Retry once to get the error message if any at the last try + $webclient.DownloadFile($url, $filepath) + } + return $filepath +} + +function InstallWordNet () { + if((Test-Path $WORDNET_RELATIVE_PATH) -eq 0) + { + mkdir $WORDNET_RELATIVE_PATH; + } + $wordnet_fname = $WORDNET_RELATIVE_PATH + "\wordnet.tar.gz" + Download $wordnet_fname $WORDNET_URL +} + + +function main () { + InstallWordNet +} + +main \ No newline at end of file