sarowe commented on a change in pull request #1965:
URL: https://github.com/apache/lucene-solr/pull/1965#discussion_r505683835



##########
File path: 
lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/TypeAsSynonymFilterFactory.java
##########
@@ -18,12 +18,15 @@
 package org.apache.lucene.analysis.miscellaneous;
 
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.TokenFilterFactory;
 
 /**
  * Factory for {@link TypeAsSynonymFilter}.
+ *
+ * <p>In Solr this might be used as such

Review comment:
       Consider adding configuration for the new features to the example Solr 
configuration.

##########
File path: 
lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestTypeAsSynonymFilter.java
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.
+ */
+package org.apache.lucene.analysis.miscellaneous;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.apache.lucene.analysis.BaseTokenStreamTestCase;
+import org.apache.lucene.analysis.CannedTokenStream;
+import org.apache.lucene.analysis.Token;
+import org.apache.lucene.analysis.TokenStream;
+
+/**
+ * Test that this filter moves the value in type to a synonym token with the 
same offsets. This is rarely
+ * useful by itself, but in combination with another filter that updates the 
type value with an appropriate
+ * synonym can be used to identify synonyms before tokens are modified by 
further analysis, and then
+ * add them at the end, ensuring that the synonym value has not ben subjected 
to the intervening analysis.

Review comment:
       typo: ben

##########
File path: 
lucene/test-framework/src/java/org/apache/lucene/analysis/BaseTokenStreamTestCase.java
##########
@@ -390,19 +406,19 @@ public static void assertAnalyzesTo(Analyzer a, String 
input, String[] output, i
   }
 
   public static void assertAnalyzesTo(Analyzer a, String input, String[] 
output, int startOffsets[], int endOffsets[], String types[], int 
posIncrements[], int posLengths[], boolean graphOffsetsAreCorrect, byte[][] 
payloads) throws IOException {
-    assertTokenStreamContents(a.tokenStream("dummy", input), output, 
startOffsets, endOffsets, types, posIncrements, posLengths, input.length(), 
null, null, graphOffsetsAreCorrect, payloads);
+    assertTokenStreamContents(a.tokenStream("dummy", input), output, 
startOffsets, endOffsets, types, posIncrements, posLengths, input.length(), 
null, null, graphOffsetsAreCorrect, payloads, null);

Review comment:
       Since you put back the original method, I think you can also revert this 
change?

##########
File path: 
lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/TypeAsSynonymFilterFactory.java
##########
@@ -46,10 +49,17 @@
   public static final String NAME = "typeAsSynonym";
 
   private final String prefix;
+  private Set<String> ignore = null;
+  private final int synFlagMask;
 
   public TypeAsSynonymFilterFactory(Map<String,String> args) {
     super(args);
     prefix = get(args, "prefix");  // default value is null
+    String ignoreList = get(args, "ignore");
+    synFlagMask = getInt(args,"synFlagsMask", ~0);
+    if (ignoreList != null) {
+      ignore = Set.of(ignoreList.split(","));
+    }

Review comment:
       There is a method `getSet()` which you could use instead of `get()` for 
the ignoreList; it does the splitting for you, and also supports mixed 
space/comma separators.




----------------------------------------------------------------
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



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

Reply via email to