How joseias/strmeanlib works
Project type and purpose
• StrMeanLib is a Java command-line library/tool that implements several heuristic algorithms to compute the median of a set of strings.
• It exposes a CLI entry point (Main.java) and a set of algorithms behind a common interface, configurable via conf.properties and external scoring-matrix files.
File structure
• Top-level:
• build.xml – Ant build script
• StrMean.jar – packaged artifact
• conf.properties – runtime configuration
• scoring_matrix_* – editable resource files
• src/strmean – main Java packages
• nbproject – NetBeans project metadata (not part of runtime)
• Key Java packages under src/strmean:
• main – utilities, constants, entry point (Main.java)
• data – data models (Operation, OpInfo, EDResult, MAResult, Example) and comparators
• distances – implementations of EditDistance (Levenshtein, Damerau-Levenshtein, restricted variants)
• malgorithms – MAlgorithm interface + concrete median-string heuristics (MAJRStatistical, MACardenas, etc.)
• opstateval – operation-state evaluators (OpStats*, used by some heuristics)
README for additional insights
• Describes two main algorithms and how to switch between them via OPS_STAT_EVALUATOR in conf.properties.
• Shows the runtime invocation:
java –cp StrMean.jar strmean.malgorithms.MAJRStatistical test.in test.out
a. Main components
• CLI/Entry Point (Main.java)
• Configuration Loader (reads conf.properties and matrix files)
• Algorithm Manager
– MAlgorithm interface
– Concrete algorithms in malgorithms/
• Distance Engine
– EditDistance interface
– Implementations in distances/
• Operation Evaluator
– OpStats* classes in opstateval/
• Data Model
– DTOs: Example, Operation, EDResult, MAResult, OpInfo
• I/O Layer
– Input parser (reads test.in)
– Output writer (writes to test.out)
b. Relationships and interactions
1. User invokes Main → Configuration Loader populates algorithm parameters
2. Main instantiates the chosen MAlgorithm
3. MAlgorithm orchestrates iterations:
– Requests distances from Distance Engine
– Uses Operation Evaluator (if required by the heuristic)
– Posts intermediate results into Data Model objects
4. After convergence, results are passed to I/O Layer for writing
c. Architectural patterns and design principles
• Strategy pattern (MAlgorithm vs. concrete classes; EditDistance vs. implementations; OpStats evaluators)
• Separation of concerns:
– CLI & config reading
– Core algorithm logic
– Distance computation
– Data representation
– I/O handling
• Plugin-style extensibility: new median algorithms, new distance metrics, new evaluators can be added without modifying Main.
d. Key technologies and libraries
• Java SE (no external dependencies)
• Ant build (build.xml)
• Configuration via plain properties files
• NetBeans project metadata (nbproject/)