Skip to content

Generate SV names#641

Merged
vish-cs merged 7 commits into
datacommonsorg:masterfrom
n-h-diaz:name
Jul 16, 2026
Merged

Generate SV names#641
vish-cs merged 7 commits into
datacommonsorg:masterfrom
n-h-diaz:name

Conversation

@n-h-diaz

@n-h-diaz n-h-diaz commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Description: This PR introduces StatVarNameGenerator to automatically construct human-readable display names for StatisticalVariable nodes that are missing a name property during MCF mutation.

Changes:

  • Added StatVarNameGenerator: Parses the properties of a StatisticalVariable and generates a consistent display string using the format: [Prefix] [MeasureAndPop] [Qualifiers]: [Constraints] [Denominator].
  • Resolves redundancies (e.g., handles when the population type already contains the measured property).
  • Normalizes boolean constraints (e.g. outputs Is Urban (False) for isUrban: false).
  • Simplifies common human denominators like Count_Person to (Per capita).
  • Updated McfMutator: Hooked up StatVarNameGenerator.generateName to automatically inject the name field into StatisticalVariable entities if it hasn't been explicitly defined.

Added/Updated Tests:

  • Added unit tests for StatVarNameGeneratorTest covering token formatting and constraint combinations.
  • Updated expected outputs in McfMutatorTest and GraphTransformerTest to include the newly generated name values.

@codacy-production

codacy-production Bot commented Jul 14, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 72 complexity

Metric Results
Complexity 72

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces StatVarNameGenerator, a utility class designed to generate readable names for StatisticalVariable nodes when their name property is missing, and integrates it into McfMutator. The review feedback focuses on performance optimizations and code cleanup within the new utility class. Key recommendations include defining thread-safe, static final constants for Pattern, Splitter, and Joiner instances to avoid overhead, removing redundant namespace stripping and condition checks, and eliminating the unused nodeId parameter from generateName along with updating its callers and tests.

Comment thread util/src/main/java/org/datacommons/util/StatVarNameGenerator.java
Comment thread util/src/main/java/org/datacommons/util/StatVarNameGenerator.java
Comment thread util/src/main/java/org/datacommons/util/StatVarNameGenerator.java
Comment thread util/src/main/java/org/datacommons/util/StatVarNameGenerator.java
Comment thread util/src/main/java/org/datacommons/util/StatVarNameGenerator.java Outdated
Comment thread util/src/main/java/org/datacommons/util/StatVarNameGenerator.java Outdated
Comment thread util/src/main/java/org/datacommons/util/StatVarNameGenerator.java
Comment thread util/src/main/java/org/datacommons/util/StatVarNameGenerator.java Outdated
Comment thread util/src/main/java/org/datacommons/util/McfMutator.java Outdated
Comment thread util/src/test/java/org/datacommons/util/StatVarNameGeneratorTest.java Outdated

@vish-cs vish-cs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the change! It would be good to get this in before the final ingestion so please go ahead and merge.

@vish-cs
vish-cs merged commit 1a33ad8 into datacommonsorg:master Jul 16, 2026
11 checks passed
@n-h-diaz
n-h-diaz deleted the name branch July 16, 2026 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants