1
package org.apache.lucene.facet.example.simple;
3
import java.util.ArrayList;
6
import org.apache.lucene.analysis.Analyzer;
7
import org.apache.lucene.analysis.WhitespaceAnalyzer;
9
import org.apache.lucene.facet.example.ExampleUtils;
10
import org.apache.lucene.facet.taxonomy.CategoryPath;
13
* Licensed to the Apache Software Foundation (ASF) under one or more
14
* contributor license agreements. See the NOTICE file distributed with
15
* this work for additional information regarding copyright ownership.
16
* The ASF licenses this file to You under the Apache License, Version 2.0
17
* (the "License"); you may not use this file except in compliance with
18
* the License. You may obtain a copy of the License at
20
* http://www.apache.org/licenses/LICENSE-2.0
22
* Unless required by applicable law or agreed to in writing, software
23
* distributed under the License is distributed on an "AS IS" BASIS,
24
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
* See the License for the specific language governing permissions and
26
* limitations under the License.
30
* Some definitions for the Simple Sample.
32
* @lucene.experimental
34
public class SimpleUtils {
37
* Documents text field.
39
public static final String TEXT = "text";
42
* Documents title field.
44
public static final String TITLE = "title";
47
* sample documents text (for the text field).
49
public static String[] docTexts = {
50
"the white car is the one I want.",
51
"the white dog does not belong to anyone.",
55
* sample documents titles (for the title field).
57
public static String[] docTitles = {
63
* Categories: categories[D][N] == category-path no. N for document no. D.
65
public static CategoryPath[][] categories = {
66
{ new CategoryPath("root","a","f1"), new CategoryPath("root","a","f2") },
67
{ new CategoryPath("root","a","f1"), new CategoryPath("root","a","f3") },
71
* Analyzer used in the simple sample.
73
public static final Analyzer analyzer = new WhitespaceAnalyzer(ExampleUtils.EXAMPLE_VER);
76
* Utility method: List of category paths out of an array of them...
77
* @param categoryPaths input array of category paths.
79
public static List<CategoryPath> categoryPathArrayToList (CategoryPath...categoryPaths) {
80
ArrayList<CategoryPath> res = new ArrayList<CategoryPath>();
81
for (CategoryPath categoryPath : categoryPaths) {
82
res.add(categoryPath);