rmuir commented on a change in pull request #1262: LUCENE-9220: regenerate all 
stemmers/stopwords/test data from snowball 2.0
URL: https://github.com/apache/lucene-solr/pull/1262#discussion_r380173659
 
 

 ##########
 File path: gradle/generation/snowball.gradle
 ##########
 @@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+apply plugin: "de.undercouch.download"
+
+configure(rootProject) {
+  ext {
+    snowballWorkDir    = file("${buildDir}/snowball")
+    snowballStemmerDir = file("${buildDir}/snowball/stemmers")
+    snowballPatchedDir = file("${buildDir}/snowball/patched")
+    snowballWebsiteDir = file("${buildDir}/snowball/website")
+    snowballDataDir    = file("${buildDir}/snowball/data")
+  }
+
+  task snowball()  {
+    description "Regenerate snowball-based sources, stopwords, and tests for 
...lucene/analysis."
+    group "generation"
+
+    dependsOn ":lucene:analysis:common:snowballGen"
+  }
+
+  task downloadSnowballStemmers(type: Download) {
+    def stemmerZip = file("${snowballWorkDir}/stemmers.zip")
+
+    src 
"https://github.com/snowballstem/snowball/archive/53739a805cfa6c77ff8496dc711dc1c106d987c1.zip";
+    dest stemmerZip
+    onlyIfModified true
+    useETag "all"
+    cachedETagsFile file("${snowballWorkDir}/stemmers.json")
+
+    doLast {
+      ant.unzip(src: stemmerZip, dest: snowballStemmerDir, overwrite: "true") {
+        ant.cutdirsmapper(dirs: "1")
+      }
+    }
+  }
+
+  task downloadSnowballWebsite(type: Download) {
+    def websiteZip = file("${snowballWorkDir}/website.zip")
+
+    src 
"https://github.com/snowballstem/snowball-website/archive/ff891e74f08e7315523ee3c0cad55bb1b7831b9d.zip";
+    dest websiteZip
+    onlyIfModified true
+    useETag "all"
+    cachedETagsFile file("${snowballWorkDir}/website.json")
+
+    doLast {
+      ant.unzip(src: websiteZip, dest: snowballWebsiteDir, overwrite: "true") {
+        ant.cutdirsmapper(dirs: "1")
+      }
+    }
+  }
+
+  task downloadSnowballData(type: Download) {
+    def dataZip = file("${snowballWorkDir}/data.zip")
+
+    src 
"https://github.com/snowballstem/snowball-data/archive/9145f8732ec952c8a3d1066be251da198a8bc792.zip";
+    dest dataZip
+    onlyIfModified true
+    useETag "all"
+    cachedETagsFile file("${snowballWorkDir}/data.json")
+
+    doLast {
+      ant.unzip(src: dataZip, dest: snowballDataDir, overwrite: "true") {
+        ant.cutdirsmapper(dirs: "1")
+      }
+    }
+  }
+
+  task cleanSnowballCheckout(type: Delete) {
+    dependsOn downloadSnowballStemmers
+    delete snowballPatchedDir
+  }
+
+  task patchSnowball(type: Copy) {
+    dependsOn cleanSnowballCheckout
+
+    from fileTree(snowballStemmerDir) {
+      include '**/*'
+    }
+    into snowballPatchedDir
+
+    doLast {
+      ant.patch(patchfile: 
rootProject.file("gradle/generation/snowball.patch"), dir: snowballPatchedDir, 
strip: "1")
 
 Review comment:
   @dweiss I can assure you it does not download again. Please look at the PR, 
maybe the names are confusing and we can clean it up? I think logic is correct.
   
   Here is what happens (first run):
   * download `github.com/snowball/xyz.zip` to `snowball.zip`. It extracts this 
to `stemmers/`. It saves Etag to `stemmers.json`.
   * create a clean copy of `stemmers/` named `patched/`.
   * apply patch to `patched/`.
   
   Second run:
   * Tries to download, but sends request with `If-None-Match: a4gk4k4...`. 
Remote server returns a HTTP 304 (Not Modified). This would not be the case if, 
e.g. someone bumped the snowball commit hash locally.
   * create a clean copy of `stemmers/` named `patched/`.
   * apply patch to `patched/`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to