Code Search for Developers
 
 
  

BinaryGAF.java from Texai at Krugle


Show BinaryGAF.java syntax highlighted

/*
 * BinaryGAF.java
 *
 * Created on October 16, 2006, 12:56 AM
 *
 * Description: BinaryGAF is an ground atomic formula having two arguments in the Texai logical representation language.
 *
 * Copyright (C) 2006 Stephen L. Reed.
 *
 * This program is free software; you can redistribute it and/or modify it under the terms
 * of the GNU General Public License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program;
 * if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

package org.texai.kb.ejb.entity;

import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Transient;
import org.texai.kb.Constants;

/**
 * Entity class BinaryGAF
 *
 * @author reed
 */
@Entity
@NamedQueries({
  @NamedQuery(name=Constants.QUERY_FIND_BINARY_GAF_BY_CONSTITUENTS,
  query="SELECT g FROM BinaryGAF g, BinaryGAFInfo gi WHERE gi.arg1 = :arg1 AND "
          + "gi.arg2 = :arg2 AND gi.predicate = :predicate AND gi.context = :context AND gi.binaryGAF = g"),
          
  @NamedQuery(name=Constants.QUERY_BINARY_GAF_FIND_ARG1_TERM_IDS,
  query="SELECT gi.arg1.termId FROM BinaryGAFInfo gi WHERE gi.arg2 = :arg2 AND "
          + "gi.predicate = :predicate AND gi.context = :context"),
          
  @NamedQuery(name=Constants.QUERY_BINARY_GAF_FIND_ARG2,
  query="SELECT gi.arg2 FROM BinaryGAFInfo gi WHERE gi.arg1 = :arg1 AND "
          + "gi.predicate = :predicate AND gi.context = :context"),
          
  @NamedQuery(name=Constants.QUERY_BINARY_GAFS_BY_ARG,
  query="SELECT g FROM BinaryGAF g, BinaryGAFInfo gi WHERE (gi.arg1 = :arg OR gi.arg2 = :arg) AND gi.binaryGAF = g"),
          
  @NamedQuery(name=Constants.QUERY_BINARY_GAFS_BY_ARG1,
  query="SELECT g FROM BinaryGAF g, BinaryGAFInfo gi WHERE gi.context = :context AND gi.arg1 = :arg1 AND gi.binaryGAF = g"),
          
  @NamedQuery(name=Constants.QUERY_BINARY_GAF_TERM_ID_INFO_BY_PREDICATE,
  query="SELECT g.termId, gi.arg1.termId, gi.context.termId FROM BinaryGAF g, BinaryGAFInfo gi "
          + "WHERE gi.predicate = :predicate AND gi.binaryGAF = g ORDER BY gi.arg1.termId"),
          
  @NamedQuery(name=Constants.QUERY_BINARY_GAF_TERM_IDS_BY_PREDICATE,
  query="SELECT g.termId FROM BinaryGAF g, BinaryGAFInfo gi "
          + "WHERE gi.predicate = :predicate AND gi.binaryGAF = g"),
          
  @NamedQuery(name=Constants.QUERY_BINARY_GAF_FIND_ARG1_AND_CONTEXT,
  query="SELECT gi.arg1, gi.context FROM BinaryGAFInfo gi WHERE gi.arg2 = :arg2 AND "
          + "gi.predicate = :predicate"),
          
  @NamedQuery(name=Constants.QUERY_BINARY_GAF_FIND_ARG2_AND_CONTEXT,
  query="SELECT gi.arg2, gi.context FROM BinaryGAFInfo gi WHERE gi.arg1 = :arg1 AND "
          + "gi.predicate = :predicate"),
          
  @NamedQuery(name=Constants.QUERY_BINARY_GAF_FIND_ARG1_STRENGTH_AND_CONTEXT,
  query="SELECT gi.arg1, gi.strength, gi.context FROM BinaryGAFInfo gi WHERE gi.arg2 = :arg2 AND "
          + "gi.predicate = :predicate ORDER BY gi.arg1.termId"),
          
  @NamedQuery(name=Constants.QUERY_BINARY_GAF_FIND_ARG2_STRENGTH_AND_CONTEXT,
  query="SELECT gi.arg2, gi.strength, gi.context FROM BinaryGAFInfo gi WHERE gi.arg1 = :arg1 AND "
          + "gi.predicate = :predicate ORDER BY gi.arg2.termId"),
          
  @NamedQuery(name=Constants.QUERY_BINARY_GAF_FIND_ARG2_IN_EVERY_CONTEXT,
  query="SELECT gi.arg2 FROM BinaryGAFInfo gi WHERE gi.arg1 = :arg1 AND "
          + "gi.predicate = :predicate"),
          
  @NamedQuery(name=Constants.QUERY_FIND_WORD_SENSE_BY_SYNSET_ID_AND_WORD_ID,
  query="SELECT gi_1.arg1 FROM "
          + "BinaryGAFInfo gi_1, "
          + "BinaryGAFInfo gi_2, "
          + "BinaryGAFInfo gi_3, "
          + "BinaryGAFInfo gi_4 "
          + "WHERE "
          + "gi_1.predicate = :wnWordSenseSynset AND "
          + "gi_2.predicate = :wnWordNetSynsetId AND "
          + "gi_3.predicate = :wnWordSenseWord AND "
          + "gi_4.predicate = :wnWordId AND "
          + "gi_1.arg1 = gi_3.arg1 AND "
          + "gi_1.arg2 = gi_2.arg1 AND "
          + "gi_2.arg2 = :synsetid AND "
          + "gi_3.arg2 = gi_4.arg1 AND "
          + "gi_4.arg2 = :wordid")
})
public class BinaryGAF extends AbstractGAF {
  
  /**
   * Determines if a de-serialized file is compatible with this class.
   *
   * Maintainers must change this value if and only if the new version
   * of this class is not compatible with old versions. See Sun docs
   * for <a href=http://java.sun.com/products/jdk/1.1/docs/guide
   * /serialization/spec/version.doc.html> details. </a>
   *
   * Not necessary to include in first version of the class, but
   * included here as a reminder of its importance.
   */
  @Transient
  private static final long serialVersionUID = 1L;
  
  /** the binary ground atomic formula information */
  @OneToOne(fetch=FetchType.LAZY, mappedBy = "binaryGAF", cascade=CascadeType.ALL)
  private BinaryGAFInfo binaryGAFInfo;          // NOPMD
  
  /** Creates a new instance of BinaryGAF */
  public BinaryGAF() {
    super();
  }
  
  /**
   * Creates a new instance of BinaryGAF.
   *
   * @param predicate the predicate
   * @param args the arguments
   * @param context the context
   * @param strength the assertion strength
   * @param generatedPhrase the generated phrase for this ground atomic formula
   * @param creatorTermId the creator 
   * @param creationPurposeTermId the creation purpose
   * @param creationTimePoint the creation time point
   */
  public BinaryGAF(
          final AtomicTerm predicate,
          final List<AbstractTerm> args,
          final AbstractReifiedTerm context,
          final Double strength,
          final String generatedPhrase,
          final AbstractReifiedTerm creatorTermId,
          final AbstractReifiedTerm creationPurposeTermId,
          final TimePoint creationTimePoint) {
    super();
    //Preconditions
    assert args != null : "args must not be null";
    assert args.size() == Constants.BINARY_ARGS_SIZE : "binary GAF must have two arguments " + args.toString();
    
    binaryGAFInfo = new BinaryGAFInfo(
            this, 
            predicate, 
            args, 
            context, 
            strength, 
            generatedPhrase, 
            creatorTermId, 
            creationPurposeTermId, 
            creationTimePoint);
  }
  
  /** Gets the binary ground atomic formula information.
   *
   * @return binary ground atomic formula information
   */
  public BinaryGAFInfo getBinaryGAFInfo() {
    return binaryGAFInfo;
  }
  
  /** Gets the first argument
   *
   * @return the first argument
   */
  public AbstractTerm getArg1() {
    return getBinaryGAFInfo().getArg1();
  }
  
  /** Gets the second argument
   *
   * @return the second argument
   */
  public AbstractTerm getArg2() {
    return getBinaryGAFInfo().getArg2();
  }
  
  /** Gets the predicate.
   *
   * @return the predicate
   */
  public AtomicTerm getPredicate() {
    return getBinaryGAFInfo().getPredicate();
  }
  
  /** Sets the predicate.
   *
   * @param predicate the predicate
   */
  public void setPredicate(final AtomicTerm predicate) {
    getBinaryGAFInfo().setPredicate(predicate);
  }
  
  /** Returns the arguments.
   *
   * @return the arguments
   */
  public List<AbstractTerm> getArgs() {
    return getBinaryGAFInfo().getArgs();
  }
  
  /** Sets the arguments.
   *
   * @param args the arguments
   */
  public void setArgs(final List<AbstractTerm> args) {
    getBinaryGAFInfo().setArgs(args);
  }
  
  /** Returns the assertion context (i.e. Cyc microtheory).
   *
   * @return the assertion context (i.e. Cyc microtheory)
   */
  public AbstractReifiedTerm getContext() {
    return getBinaryGAFInfo().getContext();
  }
  
  /** Sets the assertion context (i.e. Cyc microtheory).
   *
   * @param context the assertion context (i.e. Cyc microtheory)
   */
  public void setContext(final AbstractReifiedTerm context) {
    getBinaryGAFInfo().setContext(context);
  }
  
  /** Returns the generated phrase for this ground atomic formula.
   *
   * @return the generated phrase for this ground atomic formula
   */
  public String getGeneratedPhrase() {
    return getBinaryGAFInfo().getGeneratedPhrase();
  }
  
  /** Sets the generated phrase for this ground atomic formula.
   *
   * @param generatedPhrase the generated natural language phrase
   */
  public void setGeneratedPhrase(final String generatedPhrase) {
    getBinaryGAFInfo().setGeneratedPhrase(generatedPhrase);
  }
  
  /** Gets the assertion strength
   *
   * @return the assertion strength
   */
  public Double getStrength() {
    return getBinaryGAFInfo().getStrength();
  }
  
  /** Sets the assertion strength.
   *
   * @param strength the assertion strength
   */
  public void setStrength(final Double strength) {
    getBinaryGAFInfo().setStrength(strength);
  }
  
  /** Gets the creator.
   *
   * @return the creator
   */
  public AbstractReifiedTerm getCreator() {
    return getBinaryGAFInfo().getCreator();
  }

  /** Sets the creator.
   *
   * @param creator the creator
   */
  public void setCreator(final AbstractReifiedTerm creator) {
    getBinaryGAFInfo().setCreator(creator);
  }

  /** Gets the creation purpose.
   *
   * @return the creation purpose
   */
  public AbstractReifiedTerm getCreationPurpose() {
    return getBinaryGAFInfo().getCreationPurpose();
  }

  /** Sets the creation purpose.
   *
   * @param creationPurpose the creation purpose
   */
  public void setCreationPurpose(final AbstractReifiedTerm creationPurpose) {
    getBinaryGAFInfo().setCreationPurpose(creationPurpose);
  }

  /** Gets the creation time point.
   *
   * @return the creation time point
   */
  public TimePoint getCreationTimePoint() {
    return getBinaryGAFInfo().getCreationTimePoint();
  }

  /** Sets the creation time point.
   *
   * @param creationTimePoint the creation time point
   */
  public void setCreationTimePoint(final TimePoint creationTimePoint) {
    getBinaryGAFInfo().setCreationTimePoint(creationTimePoint);
  }

  /** Returns a hash code value for the object.
   *
   * @return a hash code value for this object
   */
  @Override
  public int hashCode() {
    return getBinaryGAFInfo().hashCode();
  }
  
  /**
   * Determines whether another object is equal to this object.
   *
   * @param object the reference object with which to compare
   * @return <code>true</code> if this object is the same as the argument;
   * <code>false</code> otherwise.
   */
  @Override
  public boolean equals(final Object object) {
    if (!(object instanceof BinaryGAF)) {
      return false;
    }
    final BinaryGAF that = (BinaryGAF) object;
    return this.getBinaryGAFInfo().equals(that.getBinaryGAFInfo());
  }
  
  /** Returns a string representation of this object.
   *
   * @return a string representation of this object
   */
  @Override
  public String toString() {
    return getBinaryGAFInfo().toString();
  }
  
  /** Returns a CycL representation of this object.
   *
   * @return a CycL representation of this object
   */
  public String toCycLString() {
    return getBinaryGAFInfo().toCycLString();
  }
}




See more files for this project here

Texai

Texai is an chatbot that intelligently seeks to acquire knowledge and friendly behaviors.

Project homepage: http://sourceforge.net/projects/texai
Programming language(s): Java,Shell Script,XML
License: other

  AbstractGAF.java
  AbstractGAFInfo.java
  AbstractReifiedTerm.java
  AbstractTerm.java
  AtomicTerm.java
  AtomicTermInfo.java
  BinaryGAF.java
  BinaryGAFInfo.java
  Formula.java
  FormulaArgument.java
  FormulaInfo.java
  NonAtomicTerm.java
  NonAtomicTermInfo.java
  PBlob.java
  PBlobInfo.java
  PCharacter.java
  PCharacterInfo.java
  PClob.java
  PClobInfo.java
  PDate.java
  PDateInfo.java
  PDouble.java
  PDoubleInfo.java
  PLong.java
  PLongInfo.java
  PString.java
  PStringInfo.java
  PVariable.java
  PVariableInfo.java
  QuaternaryGAF.java
  QuaternaryGAFInfo.java
  QuintaryGAF.java
  QuintaryGAFInfo.java
  Rule.java
  RuleInfo.java
  Symbol.java
  SymbolInfo.java
  TernaryGAF.java
  TernaryGAFInfo.java
  TimePoint.java
  TimePointInfo.java
  UnaryGAF.java
  UnaryGAFInfo.java
  package.html