Verified Owner
Top Description Inners Fields Constructors Methods
org.jabref.logic.journals.ltwa

public Class LtwaRepository

extends Object
Class Inheritance
Imports
java.nio.file.Path, java.util.Arrays, .Comparator, .List, .Optional, java.util.regex.Matcher, .Pattern, java.util.stream.IntStream, .Stream, org.antlr.v4.runtime.CharStream, .CharStreams, .CommonTokenStream, .ParserRuleContext, org.antlr.v4.runtime.tree.ParseTreeWalker, org.h2.mvstore.MVMap, .MVStore, org.slf4j.Logger, .LoggerFactory

A repository for LTWA (List of Title Word Abbreviations) entries. Provides methods for retrieving and applying abbreviations based on LTWA rules.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
LtwaRepository.AbbreviationListener

Listener to apply abbreviation rules to the parsed title

Field Summary

Modifier and TypeField and Description
private static final Pattern
private static final Pattern
private static final Logger
private final PrefixTree<LtwaEntry>
private static final String
private final PrefixTree<LtwaEntry>
private static final String

Constructor Summary

AccessConstructor and Description
public
LtwaRepository()

Creates an empty LtwaRepository.

public
LtwaRepository(Path
Path to the LTWA MVStore file
ltwaListFile
)

Creates a new LtwaRepository from an MV store file.

Method Summary

Modifier and TypeMethod and Description
public Optional<String>

Returns:

The abbreviated title
abbreviate
(String
The title to be abbreviated
title
)

Abbreviates a given title using the ISO4 rules.

private static boolean
handleRemainingText(String title, int titlePosition)

Handle remaining text after initial match

private static boolean
matches(String title, LtwaEntry entry)

Determines if a title matches an LTWA entry

private static boolean
matchesInternal(String title, String word)

Internal matching logic after handling special cases

private static void
preserveOriginalCharacterProperties(int normalizedChar, int originalChar, int[] resultCodePoints, int index)

Helper method to preserve original character properties (case, diacritics)

private static Optional<String>
restoreCapitalizationAndDiacritics(String abbreviation, String original)

Restore capitalization and diacritics from the original text to the abbreviation

private static String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BOUNDARYback to summary
private static final Pattern BOUNDARY
INFLECTIONback to summary
private static final Pattern INFLECTION
LOGGERback to summary
private static final Logger LOGGER
prefixback to summary
private final PrefixTree<LtwaEntry> prefix
PREFIX_MAP_NAMEback to summary
private static final String PREFIX_MAP_NAME
suffixback to summary
private final PrefixTree<LtwaEntry> suffix
SUFFIX_MAP_NAMEback to summary
private static final String SUFFIX_MAP_NAME

Constructor Detail

LtwaRepositoryback to summary
public LtwaRepository()

Creates an empty LtwaRepository.

LtwaRepositoryback to summary
public LtwaRepository(Path ltwaListFile)

Creates a new LtwaRepository from an MV store file.

Parameters
ltwaListFile:Path

Path to the LTWA MVStore file

Method Detail

abbreviateback to summary
public Optional<String> abbreviate(String title)

Abbreviates a given title using the ISO4 rules.

Parameters
title:String

The title to be abbreviated

Returns:Optional<String>

The abbreviated title

handleRemainingTextback to summary
private static boolean handleRemainingText(String title, int titlePosition)

Handle remaining text after initial match

matchesback to summary
private static boolean matches(String title, LtwaEntry entry)

Determines if a title matches an LTWA entry

matchesInternalback to summary
private static boolean matchesInternal(String title, String word)

Internal matching logic after handling special cases

preserveOriginalCharacterPropertiesback to summary
private static void preserveOriginalCharacterProperties(int normalizedChar, int originalChar, int[] resultCodePoints, int index)

Helper method to preserve original character properties (case, diacritics)

restoreCapitalizationAndDiacriticsback to summary
private static Optional<String> restoreCapitalizationAndDiacritics(String abbreviation, String original)

Restore capitalization and diacritics from the original text to the abbreviation

reverseback to summary
private static String reverse(String str)
org.jabref.logic.journals.ltwa back to summary

private Class LtwaRepository.AbbreviationListener

extends LtwaBaseListener
Class Inheritance

Listener to apply abbreviation rules to the parsed title

Field Summary

Modifier and TypeField and Description
private int
private boolean
private boolean
private boolean
private int
private final String
private final PrefixTree<LtwaEntry>
private final StringBuilder
private final PrefixTree<LtwaEntry>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
addAbbreviation(int position, String initialText)

private void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
private Optional<LtwaEntry>
findBestEntry(List<LtwaEntry> entries)

Find the best entry based on prioritization criteria

private List<LtwaEntry>
findMatchingEntries(String normalizedText)

Find matching entries from prefix and suffix trees

public Optional<String>
Inherited from org.jabref.logic.journals.ltwa.LtwaBaseListener:
enterAbbreviationenterAbbreviationElemententerAnyPlusSymbolsenterAnyPlusSymbolsFullenterArticleenterArticleElemententerEveryRuleenterHyphenenterHyphenElemententerNormalTitleenterNormalTitleFullenterOrdinalenterOrdinalElemententerPartenterPartElemententerSingleWordTitleenterSingleWordTitleFullenterStopwordenterStopwordElemententerStopwordPlusAnyenterStopwordPlusTitleFullenterSymbolsenterSymbolsElemententerWordenterWordElementexitAbbreviationexitAnyPlusSymbolsexitArticleexitHyphenexitNormalTitleexitNormalTitleFullexitOrdinalexitPartexitSingleWordTitleexitStopwordexitStopwordPlusAnyexitSymbolsexitWordvisitErrorNodevisitTerminal

Field Detail

abbreviatedTitlePositionback to summary
private int abbreviatedTitlePosition
addSpaceback to summary
private boolean addSpace
errorback to summary
private boolean error
isFirstElementback to summary
private boolean isFirstElement
lastPartPositionback to summary
private int lastPartPosition
originalTitleback to summary
private final String originalTitle
prefixback to summary
private final PrefixTree<LtwaEntry> prefix
resultback to summary
private final StringBuilder result
suffixback to summary
private final PrefixTree<LtwaEntry> suffix

Constructor Detail

AbbreviationListenerback to summary
public AbbreviationListener(String originalTitle, PrefixTree<LtwaEntry> prefix, PrefixTree<LtwaEntry> suffix)

Method Detail

addAbbreviationback to summary
private void addAbbreviation(int position, String initialText)
appendWithSpaceback to summary
private void appendWithSpace(String text)
exitAbbreviationElementback to summary
public void exitAbbreviationElement(LtwaParser.AbbreviationElementContext ctx)

Overrides org.jabref.logic.journals.ltwa.LtwaBaseListener.exitAbbreviationElement.

Implements org.jabref.logic.journals.ltwa.LtwaListener.exitAbbreviationElement.

Doc from org.jabref.logic.journals.ltwa.LtwaBaseListener.exitAbbreviationElement.

Exit a parse tree produced by the AbbreviationElement labeled alternative in LtwaParser#titleElement.

The default implementation does nothing.

Annotations
@Override
exitAnyPlusSymbolsFullback to summary
public void exitAnyPlusSymbolsFull(LtwaParser.AnyPlusSymbolsFullContext ctx)

Overrides org.jabref.logic.journals.ltwa.LtwaBaseListener.exitAnyPlusSymbolsFull.

Implements org.jabref.logic.journals.ltwa.LtwaListener.exitAnyPlusSymbolsFull.

Doc from org.jabref.logic.journals.ltwa.LtwaBaseListener.exitAnyPlusSymbolsFull.

Exit a parse tree produced by the AnyPlusSymbolsFull labeled alternative in LtwaParser#title.

The default implementation does nothing.

Annotations
@Override
exitArticleElementback to summary
public void exitArticleElement(LtwaParser.ArticleElementContext ctx)

Overrides org.jabref.logic.journals.ltwa.LtwaBaseListener.exitArticleElement.

Implements org.jabref.logic.journals.ltwa.LtwaListener.exitArticleElement.

Doc from org.jabref.logic.journals.ltwa.LtwaBaseListener.exitArticleElement.

Exit a parse tree produced by the ArticleElement labeled alternative in LtwaParser#titleElement.

The default implementation does nothing.

Annotations
@Override
exitEveryRuleback to summary
public void exitEveryRule(ParserRuleContext ctx)

Overrides org.jabref.logic.journals.ltwa.LtwaBaseListener.exitEveryRule.

Implements org.antlr.v4.runtime.tree.ParseTreeListener.exitEveryRule.

Doc from org.jabref.logic.journals.ltwa.LtwaBaseListener.exitEveryRule.

The default implementation does nothing.

Annotations
@Override
exitHyphenElementback to summary
public void exitHyphenElement(LtwaParser.HyphenElementContext ctx)

Overrides org.jabref.logic.journals.ltwa.LtwaBaseListener.exitHyphenElement.

Implements org.jabref.logic.journals.ltwa.LtwaListener.exitHyphenElement.

Doc from org.jabref.logic.journals.ltwa.LtwaBaseListener.exitHyphenElement.

Exit a parse tree produced by the HyphenElement labeled alternative in LtwaParser#titleElement.

The default implementation does nothing.

Annotations
@Override
exitOrdinalElementback to summary
public void exitOrdinalElement(LtwaParser.OrdinalElementContext ctx)

Overrides org.jabref.logic.journals.ltwa.LtwaBaseListener.exitOrdinalElement.

Implements org.jabref.logic.journals.ltwa.LtwaListener.exitOrdinalElement.

Doc from org.jabref.logic.journals.ltwa.LtwaBaseListener.exitOrdinalElement.

Exit a parse tree produced by the OrdinalElement labeled alternative in LtwaParser#titleElement.

The default implementation does nothing.

Annotations
@Override
exitPartElementback to summary
public void exitPartElement(LtwaParser.PartElementContext ctx)

Overrides org.jabref.logic.journals.ltwa.LtwaBaseListener.exitPartElement.

Implements org.jabref.logic.journals.ltwa.LtwaListener.exitPartElement.

Doc from org.jabref.logic.journals.ltwa.LtwaBaseListener.exitPartElement.

Exit a parse tree produced by the PartElement labeled alternative in LtwaParser#titleElement.

The default implementation does nothing.

Annotations
@Override
exitSingleWordTitleFullback to summary
public void exitSingleWordTitleFull(LtwaParser.SingleWordTitleFullContext ctx)

Overrides org.jabref.logic.journals.ltwa.LtwaBaseListener.exitSingleWordTitleFull.

Implements org.jabref.logic.journals.ltwa.LtwaListener.exitSingleWordTitleFull.

Doc from org.jabref.logic.journals.ltwa.LtwaBaseListener.exitSingleWordTitleFull.

Exit a parse tree produced by the SingleWordTitleFull labeled alternative in LtwaParser#title.

The default implementation does nothing.

Annotations
@Override
exitStopwordElementback to summary
public void exitStopwordElement(LtwaParser.StopwordElementContext ctx)

Overrides org.jabref.logic.journals.ltwa.LtwaBaseListener.exitStopwordElement.

Implements org.jabref.logic.journals.ltwa.LtwaListener.exitStopwordElement.

Doc from org.jabref.logic.journals.ltwa.LtwaBaseListener.exitStopwordElement.

Exit a parse tree produced by the StopwordElement labeled alternative in LtwaParser#titleElement.

The default implementation does nothing.

Annotations
@Override
exitStopwordPlusTitleFullback to summary
public void exitStopwordPlusTitleFull(LtwaParser.StopwordPlusTitleFullContext ctx)

Overrides org.jabref.logic.journals.ltwa.LtwaBaseListener.exitStopwordPlusTitleFull.

Implements org.jabref.logic.journals.ltwa.LtwaListener.exitStopwordPlusTitleFull.

Doc from org.jabref.logic.journals.ltwa.LtwaBaseListener.exitStopwordPlusTitleFull.

Exit a parse tree produced by the StopwordPlusTitleFull labeled alternative in LtwaParser#title.

The default implementation does nothing.

Annotations
@Override
exitSymbolsElementback to summary
public void exitSymbolsElement(LtwaParser.SymbolsElementContext ctx)

Overrides org.jabref.logic.journals.ltwa.LtwaBaseListener.exitSymbolsElement.

Implements org.jabref.logic.journals.ltwa.LtwaListener.exitSymbolsElement.

Doc from org.jabref.logic.journals.ltwa.LtwaBaseListener.exitSymbolsElement.

Exit a parse tree produced by the SymbolsElement labeled alternative in LtwaParser#titleElement.

The default implementation does nothing.

Annotations
@Override
exitWordElementback to summary
public void exitWordElement(LtwaParser.WordElementContext ctx)

Overrides org.jabref.logic.journals.ltwa.LtwaBaseListener.exitWordElement.

Implements org.jabref.logic.journals.ltwa.LtwaListener.exitWordElement.

Doc from org.jabref.logic.journals.ltwa.LtwaBaseListener.exitWordElement.

Exit a parse tree produced by the WordElement labeled alternative in LtwaParser#titleElement.

The default implementation does nothing.

Annotations
@Override
findBestEntryback to summary
private Optional<LtwaEntry> findBestEntry(List<LtwaEntry> entries)

Find the best entry based on prioritization criteria

findMatchingEntriesback to summary
private List<LtwaEntry> findMatchingEntries(String normalizedText)

Find matching entries from prefix and suffix trees

getResultback to summary
public Optional<String> getResult()