本文整理汇总了Java中org.apache.lucene.util.AttributeReflector类的典型用法代码示例。如果您正苦于以下问题:Java AttributeReflector类的具体用法?Java AttributeReflector怎么用?Java AttributeReflector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AttributeReflector类属于org.apache.lucene.util包,在下文中一共展示了AttributeReflector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reflectWith
import org.apache.lucene.util.AttributeReflector; //导入依赖的package包/类
@Override
public void reflectWith(AttributeReflector reflector) {
super.reflectWith(reflector);
reflector.reflect(OffsetAttribute.class, "startOffset", startOffset);
reflector.reflect(OffsetAttribute.class, "endOffset", endOffset);
reflector.reflect(PositionIncrementAttribute.class, "positionIncrement", positionIncrement);
reflector.reflect(PositionLengthAttribute.class, "positionLength", positionLength);
reflector.reflect(TypeAttribute.class, "type", type);
}
示例2: reflectWith
import org.apache.lucene.util.AttributeReflector; //导入依赖的package包/类
@Override
public void reflectWith(AttributeReflector reflector) {
fillBytesRef();
reflector.reflect(TermToBytesRefAttribute.class, "bytes", bytes.toBytesRef());
reflector.reflect(NumericTermAttribute.class, "shift", shift);
reflector.reflect(NumericTermAttribute.class, "rawValue", getRawValue());
reflector.reflect(NumericTermAttribute.class, "valueSize", valueSize);
}
示例3: extractExtendedAttributes
import org.apache.lucene.util.AttributeReflector; //导入依赖的package包/类
/**
* other attribute extract object.
* Extracted object group by AttributeClassName
*
* @param stream current TokenStream
* @param includeAttributes filtering attributes
* @return Map<key value>
*/
private static Map<String, Object> extractExtendedAttributes(TokenStream stream, final Set<String> includeAttributes) {
final Map<String, Object> extendedAttributes = new TreeMap<>();
stream.reflectWith(new AttributeReflector() {
@Override
public void reflect(Class<? extends Attribute> attClass, String key, Object value) {
if (CharTermAttribute.class.isAssignableFrom(attClass))
return;
if (PositionIncrementAttribute.class.isAssignableFrom(attClass))
return;
if (OffsetAttribute.class.isAssignableFrom(attClass))
return;
if (TypeAttribute.class.isAssignableFrom(attClass))
return;
if (includeAttributes == null || includeAttributes.isEmpty() || includeAttributes.contains(key.toLowerCase(Locale.ROOT))) {
if (value instanceof BytesRef) {
final BytesRef p = (BytesRef) value;
value = p.toString();
}
extendedAttributes.put(key, value);
}
}
});
return extendedAttributes;
}
示例4: reflectWith
import org.apache.lucene.util.AttributeReflector; //导入依赖的package包/类
@Override
public void reflectWith(AttributeReflector reflector) {
super.reflectWith(reflector);
reflector.reflect(OffsetAttribute.class, "startOffset", startOffset);
reflector.reflect(OffsetAttribute.class, "endOffset", endOffset);
reflector.reflect(PositionIncrementAttribute.class, "positionIncrement", positionIncrement);
reflector.reflect(PayloadAttribute.class, "payload", payload);
reflector.reflect(FlagsAttribute.class, "flags", flags);
reflector.reflect(TypeAttribute.class, "type", type);
}
示例5: reflectWith
import org.apache.lucene.util.AttributeReflector; //导入依赖的package包/类
@Override
public void reflectWith(AttributeReflector reflector) {
reflector.reflect(StemmingBufferAttribute.class, "stemmedToken", stemmedToken);
reflector.reflect(StemmingBufferAttribute.class, "stemmedTokenLength", stemmedTokenLength);
reflector.reflect(StemmingBufferAttribute.class, "originalToken", originalToken);
reflector.reflect(StemmingBufferAttribute.class, "originalTokenLength", originalTokenLength);
}
示例6: reflectWith
import org.apache.lucene.util.AttributeReflector; //导入依赖的package包/类
@Override
public void reflectWith(AttributeReflector reflector) {
String reading = getReading();
String readingEN = reading == null ? null : ToStringUtil.getRomanization(reading);
String pronunciation = getPronunciation();
String pronunciationEN = pronunciation == null ? null : ToStringUtil.getRomanization(pronunciation);
reflector.reflect(ReadingAttribute.class, "reading", reading);
reflector.reflect(ReadingAttribute.class, "reading (en)", readingEN);
reflector.reflect(ReadingAttribute.class, "pronunciation", pronunciation);
reflector.reflect(ReadingAttribute.class, "pronunciation (en)", pronunciationEN);
}
示例7: reflectWith
import org.apache.lucene.util.AttributeReflector; //导入依赖的package包/类
@Override
public void reflectWith(AttributeReflector reflector) {
String partOfSpeech = getPartOfSpeech();
String partOfSpeechEN = partOfSpeech == null ? null : ToStringUtil.getPOSTranslation(partOfSpeech);
reflector.reflect(PartOfSpeechAttribute.class, "partOfSpeech", partOfSpeech);
reflector.reflect(PartOfSpeechAttribute.class, "partOfSpeech (en)", partOfSpeechEN);
}
示例8: reflectWith
import org.apache.lucene.util.AttributeReflector; //导入依赖的package包/类
@Override
public void reflectWith(AttributeReflector reflector) {
String type = getInflectionType();
String typeEN = type == null ? null : ToStringUtil.getInflectionTypeTranslation(type);
reflector.reflect(InflectionAttribute.class, "inflectionType", type);
reflector.reflect(InflectionAttribute.class, "inflectionType (en)", typeEN);
String form = getInflectionForm();
String formEN = form == null ? null : ToStringUtil.getInflectedFormTranslation(form);
reflector.reflect(InflectionAttribute.class, "inflectionForm", form);
reflector.reflect(InflectionAttribute.class, "inflectionForm (en)", formEN);
}
示例9: reflectWith
import org.apache.lucene.util.AttributeReflector; //导入依赖的package包/类
@Override
public void reflectWith(AttributeReflector reflector) {
// when wordbreaking CJK, we use the 15924 code Japanese (Han+Hiragana+Katakana) to
// mark runs of Chinese/Japanese. our use is correct (as for chinese Han is a subset),
// but this is just to help prevent confusion.
String name = code == UScript.JAPANESE ? "Chinese/Japanese" : getName();
reflector.reflect(ScriptAttribute.class, "script", name);
}
示例10: reflectWith
import org.apache.lucene.util.AttributeReflector; //导入依赖的package包/类
@Override
public void reflectWith(AttributeReflector reflector) {
List<String> readings = getReadings();
List<String> enReadings = null;
if (readings != null) {
enReadings = new ArrayList<String>(readings.size());
for (String kana : readings) {
enReadings.add(ToStringUtil.getRomanization(kana));
}
}
reflector.reflect(ReadingsAttribute.class, "readings", readings);
reflector.reflect(ReadingsAttribute.class, "readings (en)", enReadings);
}
示例11: reflectWith
import org.apache.lucene.util.AttributeReflector; //导入依赖的package包/类
@Override
public void reflectWith(AttributeReflector reflector) {
String partOfSpeech = getPartOfSpeech();
String en = partOfSpeech == null ? null : ToStringUtil.getPOSTranslation(partOfSpeech);
reflector.reflect(PartOfSpeechAttribute.class, "partOfSpeech", partOfSpeech);
reflector.reflect(PartOfSpeechAttribute.class, "partOfSpeech (en)", en);
}
示例12: reflectWith
import org.apache.lucene.util.AttributeReflector; //导入依赖的package包/类
@Override
public void reflectWith(AttributeReflector reflector) {
final List<String> pronunciations = getPronunciations();
List<String> enPronunciations = null;
if (pronunciations != null) {
final String[] p = new String[pronunciations.size()];
int i = 0;
for (String kana : pronunciations) {
p[i++] = ToStringUtil.getRomanization(kana);
}
enPronunciations = Arrays.asList(p);
}
reflector.reflect(PronunciationsAttribute.class, "pronunciations", pronunciations);
reflector.reflect(PronunciationsAttribute.class, "pronunciations (en)", enPronunciations);
}
示例13: reflectWith
import org.apache.lucene.util.AttributeReflector; //导入依赖的package包/类
@Override
public void reflectWith(AttributeReflector reflector) {
String conjugationalForm = getConjugationalForm();
String conjugationalType = getConjugationalType();
String enForm = conjugationalForm == null ? null : ToStringUtil.getConjFormTranslation(conjugationalForm);
String enType = conjugationalType == null ? null : ToStringUtil.getConjTypeTranslation(conjugationalType);
reflector.reflect(ConjugationAttribute.class, "conjugationalForm", conjugationalForm);
reflector.reflect(ConjugationAttribute.class, "conjugationalForm (en)", enForm);
reflector.reflect(ConjugationAttribute.class, "conjugationalType", conjugationalType);
reflector.reflect(ConjugationAttribute.class, "conjugationalType (en)", enType);
}
示例14: reflectWith
import org.apache.lucene.util.AttributeReflector; //导入依赖的package包/类
@Override
public void reflectWith(AttributeReflector reflector) {
fillBytesRef();
reflector.reflect(TermToBytesRefAttribute.class, "bytes", BytesRef.deepCopyOf(bytes));
reflector.reflect(NumericTermAttribute.class, "shift", shift);
reflector.reflect(NumericTermAttribute.class, "rawValue", getRawValue());
reflector.reflect(NumericTermAttribute.class, "valueSize", valueSize);
}
示例15: extractExtendedAttributes
import org.apache.lucene.util.AttributeReflector; //导入依赖的package包/类
/**
* other attribute extract object.<br/>
* Extracted object group by AttributeClassName
*
* @param stream current TokenStream
* @param includeAttributes filtering attributes
* @param shortAttrName if true, return short attribute name
* @return Nested Object : Map<attrClass, Map<key, value>>
*/
private Map<String, Map<String, Object>> extractExtendedAttributes(TokenStream stream, final Set<String> includeAttributes, final boolean shortAttrName) {
final Map<String, Map<String, Object>> extendedAttributes = new TreeMap<>();
stream.reflectWith(new AttributeReflector() {
@Override
public void reflect(Class<? extends Attribute> attClass, String key, Object value) {
if (CharTermAttribute.class.isAssignableFrom(attClass))
return;
if (PositionIncrementAttribute.class.isAssignableFrom(attClass))
return;
if (OffsetAttribute.class.isAssignableFrom(attClass))
return;
if (TypeAttribute.class.isAssignableFrom(attClass))
return;
if (includeAttributes == null || includeAttributes.isEmpty() || includeAttributes.contains(attClass.getSimpleName().toLowerCase())) {
Map<String, Object> currentAttributes = extendedAttributes.get(attClass.getName());
if (currentAttributes == null) {
currentAttributes = new HashMap<>();
}
if (value instanceof BytesRef) {
final BytesRef p = (BytesRef) value;
value = p.toString();
}
currentAttributes.put(key, value);
if (shortAttrName) {
extendedAttributes.put(attClass.getName().substring(attClass.getName().lastIndexOf(".")+1), currentAttributes);
} else {
extendedAttributes.put(attClass.getName(), currentAttributes);
}
}
}
});
return extendedAttributes;
}