001package conexp.fx.gui.graph.option;
002
003/*
004 * #%L
005 * Concept Explorer FX
006 * %%
007 * Copyright (C) 2010 - 2023 Francesco Kriegel
008 * %%
009 * This program is free software: you can redistribute it and/or modify
010 * it under the terms of the GNU General Public License as
011 * published by the Free Software Foundation, either version 3 of the
012 * License, or (at your option) any later version.
013 * 
014 * This program is distributed in the hope that it will be useful,
015 * but WITHOUT ANY WARRANTY; without even the implied warranty of
016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
017 * GNU General Public License for more details.
018 * 
019 * You should have received a copy of the GNU General Public
020 * License along with this program.  If not, see
021 * <http://www.gnu.org/licenses/gpl-3.0.html>.
022 * #L%
023 */
024
025import conexp.fx.core.context.Concept;
026import conexp.fx.core.context.ConceptLattice;
027import conexp.fx.core.context.Context;
028
029public enum AttributeLabelText {
030  NONE("None") {
031
032    public <G, M> String get(
033        final Context<G, M> context,
034        final ConceptLattice<G, M> lattice,
035        final Concept<G, M> concept) {
036      return null;
037    }
038  },
039  ATTRIBUTE_LABELS("Attribute Labels") {
040
041    public <G, M> String get(
042        final Context<G, M> context,
043        final ConceptLattice<G, M> lattice,
044        final Concept<G, M> concept) {
045      return null;
046    }
047  },
048  SEED_LABELS("Attribute Seed Labels") {
049
050    public <G, M> String get(Context<G, M> context, ConceptLattice<G, M> lattice, Concept<G, M> concept) {
051      return null;
052    }
053  },
054  INTENT_SIZE("Intent Size") {
055
056    public <G, M> String get(
057        final Context<G, M> context,
058        final ConceptLattice<G, M> lattice,
059        final Concept<G, M> concept) {
060      return concept.intent().size() + "";
061    }
062  },
063  INTENT_PERCENTAGE("Intent Ratio") {
064
065    public <G, M> String get(
066        final Context<G, M> context,
067        final ConceptLattice<G, M> lattice,
068        final Concept<G, M> concept) {
069      return (int) Math.rint(100d * ((double) concept.intent().size()) / ((double) lattice.context.colHeads().size()))
070          + "%";
071    }
072  },
073  ATTRIBUTE_LABELS_SIZE("Attribute Labels Size") {
074
075    public <G, M> String get(
076        final Context<G, M> context,
077        final ConceptLattice<G, M> lattice,
078        final Concept<G, M> concept) {
079      return lattice.attributeLabels(concept).size() + "";
080    }
081  },
082  ATTRIBUTE_LABELS_PERCENTAGE("Attribute Labels Ratio") {
083
084    public <G, M> String get(
085        final Context<G, M> context,
086        final ConceptLattice<G, M> lattice,
087        final Concept<G, M> concept) {
088      return (int) Math.rint(100d * ((double) lattice.attributeLabels(concept).size())
089          / ((double) lattice.context.colHeads().size()))
090          + "%";
091    }
092  };
093
094  private final String name;
095
096  private AttributeLabelText(final String name) {
097    this.name = name;
098  }
099
100  public abstract <G, M> String get(
101      final Context<G, M> context,
102      final ConceptLattice<G, M> lattice,
103      final Concept<G, M> concept);
104
105  public final String toString() {
106    return name;
107  }
108}