Code Search for Developers
 
 
  

AbstractGAF.java from Texai at Krugle


Show AbstractGAF.java syntax highlighted

/*
 * GAF.java
 *
 * Created on April 6, 2007, 2:00 PM
 *
 * Description: Defines the inferface for ground atomic formula terms.
 *
 * Copyright (C) 2007 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.entity;

import com.sleepycat.persist.model.Persistent;
import com.sleepycat.persist.model.Relationship;
import com.sleepycat.persist.model.SecondaryKey;
import java.util.Date;
import java.util.List;
import org.texai.kb.ejb.session.shared.KBPartitionFacadeLocal;
import org.texai.util.TexaiException;

/**
 *
 * @author reed
 */
@Persistent
public abstract class AbstractGAF extends AbstractBookkeepingTerm {
  
  /** the predicate term type */
  private byte predicateTermType;                          // NOPMD

  /** the predicate term id */
  @SecondaryKey(relate=Relationship.MANY_TO_ONE)
  private int predicateTermId;                             // NOPMD

  /** the assertion context (i.e. Cyc microtheory) term type */
  private byte contextTermType;

  /** the assertion context (i.e. Cyc microtheory) term id */
  private int contextTermId;

  /** the assertion strength */
  private double strength;

  /** the generated phrase for this ground atomic formula */
  private String generatedPhrase;

  /** Creates a new instance of AbstractGAF. */
  public AbstractGAF() {
    super();
  }
  
  /** Creates a new instance of AbstractGAF. 
   *
   * @param termId the database term ID
   * @param predicate the predicate
   * @param args the argument terms
   * @param context the assertion context (i.e. Cyc microtheory)
   * @param strength the assertion strength
   * @param generatedPhrase the generated phrase for this ground atomic formula
   * @param creator the creator
   * @param creationPurpose the creation purpose
   * @param creationDate the creation date
   */
  public AbstractGAF(
          final int termId,
          final AbstractReifiedTerm predicate,
          final AbstractReifiedTerm context,
          final double strength,
          final String generatedPhrase,
          final AbstractReifiedTerm creator,
          final AbstractReifiedTerm creationPurpose,
          final Date creationDate) {
    this(
            termId,
            predicate.getTermType(),
            predicate.getTermId(),
            context.getTermType(),
            context.getTermId(),
            strength,
            generatedPhrase,
            creator == null ? (byte) 0 : creator.getTermType(),
            creator == null ? 0 : creator.getTermId(),
            creationPurpose == null ? (byte) 0 : creationPurpose.getTermType(),
            creationPurpose == null ? 0 : creationPurpose.getTermId(),
            creationDate);
  }
  
  /** Creates a new instance of AbstractGAF. 
   *
   * @param termId the database term ID
   * @param predicateTermType the predicate term type
   * @param predicateTermId the predicate term id
   * @param arg1TermType the first argument term type 
   * @param arg1TermId the first argument term id
   * @param contextTermType the assertion context (i.e. Cyc microtheory) term type
   * @param contextTermId the assertion context (i.e. Cyc microtheory) term id
   * @param strength the assertion strength
   * @param generatedPhrase the generated phrase for this ground atomic formula
   * @param creatorTermType the creator term type of this ground atomic formula
   * @param creatorTermId the creator term id of this ground atomic formula
   * @param creationPurposeTermType the creation purpose term type of this ground atomic formula
   * @param creationPurposeTermId the creation purpose term id of this ground atomic formula
   * @param creationDate the creation date
   */
  public AbstractGAF(
          final int termId,
          final byte predicateTermType,
          final int predicateTermId,
          final byte contextTermType,
          final int contextTermId,
          final double strength,
          final String generatedPhrase,
          final byte creatorTermType,
          final int creatorTermId,
          final byte creationPurposeTermType,
          final int creationPurposeTermId,
          final Date creationDate) {
    super(
            termId,
            creatorTermType,
            creatorTermId,
            creationPurposeTermType,
            creationPurposeTermId,
            creationDate);
    //Preconditions
    assert predicateTermType != 0 : "predicateTermType must not be zero";
    assert predicateTermId != 0 : "predicateTermId must not be zero";
    assert contextTermType != 0 : "contextTermType must not be zero";
    assert contextTermId != 0 : "contextTermId must not be zero";

    this.predicateTermType = predicateTermType;
    this.predicateTermId = predicateTermId;
    this.contextTermType = contextTermType;
    this.contextTermId = contextTermId;
    this.strength = strength;
    this.generatedPhrase = generatedPhrase;
  }
  
  /** Returns the arguments.
   *
   * @param kbPartitionFacade the KB partition facade
   * @return the arguments
   */
  public abstract List<AbstractTerm> getArgs(KBPartitionFacadeLocal kbPartitionFacade);

  /** Gets the predicate term type.
   *
   * @return the predicate term type
   */
  public byte getPredicateTermType() {
    return predicateTermType;
  }

  /** Gets the predicate term id.
   *
   * @return the predicate term id
   */
  public int getPredicateTermId() {
    return predicateTermId;
  }

  /** Gets the predicate
   *
   * @param kbPartitionFacade the KB partition facade
   * @return the predicate
   */
  public AbstractReifiedTerm getPredicate(final KBPartitionFacadeLocal kbPartitionFacade) {
    if (kbPartitionFacade == null) {
      throw new TexaiException("kbPartitionFacade must not be null");
    }
    return (AbstractReifiedTerm) kbPartitionFacade.findTermByTermTypeAndId(predicateTermType, predicateTermId);
  }

  /** Sets the predicate
   *
   * @param predicate the predicate
   */
  public void setPredicate(final AbstractReifiedTerm predicate) {
    //Preconditions
    assert predicate != null : "predicate must not be null";
    
    this.predicateTermType = predicate.getTermType();
    this.predicateTermId = predicate.getTermId();
  }

  /** Gets the context term type.
   *
   * @return the context term type
   */
  public byte getContextTermType() {
    return contextTermType;
  }

  /** Sets the context term type.
   *
   * @param contextTermType the context term type
   */
  public void setContextTermType(final byte contextTermType) {
    this.contextTermType = contextTermType;
  }

  /** Gets the context term id.
   *
   * @return the context term id
   */
  public int getContextTermId() {
    return contextTermId;
  }

  /** Sets the context term id.
   *
   * @param contextTermId the context term id
   */
  public void setContextTermId(final int contextTermId) {
    //Preconditions
    assert contextTermId != 0 : "contextTermId must not be zero";
    
    this.contextTermId = contextTermId;
  }

  /** Gets the context
   *
   * @param kbPartitionFacade the KB partition facade
   * @return the context
   */
  public AbstractReifiedTerm getContext(final KBPartitionFacadeLocal kbPartitionFacade) {
    if (kbPartitionFacade == null) {
      throw new TexaiException("kbPartitionFacade must not be null");
    }
    return (AbstractReifiedTerm) kbPartitionFacade.findTermByTermTypeAndId(contextTermType, contextTermId);
  }

  /** Sets the context.
   *
   * @param context the context
   */
  public void setContext(final AbstractReifiedTerm context) {
    //Preconditions
    assert context != null : "context must not be null";
    
    contextTermType = context.getTermType();
    contextTermId = context.getTermId();
  }
  
  /** Gets the strength.
   *
   * @return the strength
   */
  public Double getStrength() {
    return strength;
  }

  /** Sets the strength.
   *
   * @param strength the strength
   */
  public void setStrength(final Double strength) {
    this.strength = strength;
  }

  /** Gets the generated phrase.
   *
   * @return the generated phrase
   */
  public String getGeneratedPhrase() {
    return generatedPhrase;
  }

  public void setGeneratedPhrase(final String generatedPhrase) {
    this.generatedPhrase = generatedPhrase;
  }

}




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

  AbstractBookkeepingTerm.java
  AbstractGAF.java
  AbstractReifiedTerm.java
  AbstractTerm.java
  AtomicTerm.java
  BinaryGAF.java
  Formula.java
  LocalTermIdReference.java
  NonAtomicTerm.java
  PByteArray.java
  PDate.java
  PDouble.java
  PLong.java
  PString.java
  PVariable.java
  QuaternaryGAF.java
  QuintaryGAF.java
  RemoteTermIdReference.java
  Rule.java
  StubReifiedTerm.java
  StubTerm.java
  Symbol.java
  TermIdSequence.java
  TernaryGAF.java
  UnaryGAF.java