com.articulate.sigma.DocGen Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sigma-component Show documentation
Show all versions of sigma-component Show documentation
Sigma knowledge engineering system is an system for developing, viewing and debugging theories in first
order logic. It works with Knowledge Interchange Format (KIF) and is optimized for the Suggested Upper Merged
Ontology (SUMO) www.ontologyportal.org.
The newest version!
/** This code is copyrighted by Articulate Software (c) 2007. It is
released under the GNU Public License
<http://www.gnu.org/copyleft/gpl.html>. Users of this code also
consent, by use of this code, to credit Articulate Software in any
writings, briefings, publications, presentations, or other representations
of any software which incorporates, builds on, or uses this code. Please
cite the following article in any publication with references:
Pease, A., (2003). The Sigma Ontology Development Environment, in Working
Notes of the IJCAI-2003 Workshop on Ontology and Distributed Systems,
August 9, Acapulco, Mexico. See also http://sigmakee.sourceforge.net
*/
/*************************************************************************************************/
package com.articulate.sigma;
import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.LineNumberReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import com.articulate.sigma.nlg.NLGUtils;
/** A class to generate simplified HTML-based documentation for SUO-KIF terms. */
public class DocGen {
/** *************************************************************
* This String token denotes Sigma's "simple" HTML layout, and is
* used as a flag in the HTML generation code to switch between
* full and simple modes.
*/
protected static final String F_SI = "si";
protected static List F_CONTROL_TOKENS = null;
static {
if (F_CONTROL_TOKENS == null)
F_CONTROL_TOKENS = new ArrayList();
F_CONTROL_TOKENS.add(F_SI);
}
public static List getControlTokens() {
return F_CONTROL_TOKENS;
}
public static int getControlBitValue(String token) {
int bitValue = 0;
try {
int idx = getControlTokens().indexOf(token);
if (idx > -1) {
bitValue = Double.valueOf(Math.pow(2.0d,
Integer.valueOf(idx).doubleValue())).intValue();
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return bitValue;
}
protected static final String SP2 = " ";
/** *************************************************************
* The default base plus file suffix name for the main index file
* for a set of HTML output files.
*/
protected static String INDEX_FILE_NAME = "index.html";
protected int localCounter = 0;
protected static final String DEFAULT_KEY = "docgen_default";
protected static Hashtable DOC_GEN_INSTANCES = new Hashtable();
public static DocGen getInstance() {
DocGen inst = null;
try {
inst = (DocGen) DOC_GEN_INSTANCES.get(DEFAULT_KEY);
if (inst == null) {
inst = new DocGen();
inst.setLineSeparator(StringUtil.getLineSeparator());
DOC_GEN_INSTANCES.put(DEFAULT_KEY, inst);
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return inst;
}
/** *************************************************************
*/
public static DocGen getInstance(String compositeKey) {
// System.out.println("ENTER DocGen.getInstance(" + compositeKey + ")");
DocGen inst = null;
try {
KBmanager mgr = KBmanager.getMgr();
String interned = compositeKey.intern();
inst = (DocGen) DOC_GEN_INSTANCES.get(interned);
if (inst == null) {
inst = new DocGen();
inst.setLineSeparator(StringUtil.getLineSeparator());
int idx = interned.indexOf("-");
KB kb = ((idx > -1)
? mgr.getKB(interned.substring(0, idx).trim())
: mgr.getKB(interned));
if (kb instanceof KB)
inst.setKB(kb);
String ontology = null;
if ((idx > 0) && (idx < (interned.length() - 1)))
ontology = interned.substring(idx + 1).trim();
if (StringUtil.emptyString(ontology))
ontology = inst.getOntology(kb);
if (StringUtil.isNonEmptyString(ontology)) {
inst.setOntology(ontology);
inst.setDefaultNamespace(inst.getDefaultNamespace());
inst.setDefaultPredicateNamespace(inst.getDefaultPredicateNamespace());
}
inst.setDocGenKey(interned);
DOC_GEN_INSTANCES.put(interned, inst);
}
}
catch (Exception ex) {
ex.printStackTrace();
}
// System.out.println("EXIT DocGen.getInstance(" + compositeKey + ")");
// System.out.println(" inst == " + inst.toString());
return inst;
}
/** *************************************************************
*/
public static DocGen getInstance(KB kb, String ontology) {
// System.out.println("ENTER DocGen.getInstance(" + kb.name + ", " + ontology + ")");
DocGen inst = null;
try {
inst = getInstance(kb.name + "-" + ontology);
inst.setKB(kb);
inst.setOntology(ontology);
inst.setDefaultNamespace(inst.getDefaultNamespace());
inst.setDefaultPredicateNamespace(inst.getDefaultPredicateNamespace());
}
catch (Exception ex) {
ex.printStackTrace();
}
// System.out.println("EXIT DocGen.getInstance(" + kb.name + ", " + ontology + ")");
// System.out.println(" inst == " + inst.toString());
return inst;
}
/** *************************************************************
* To obtain an instance of DocGen, use the static factory method
* getInstance().
*/
protected DocGen() {
}
protected String lineSeparator = StringUtil.getLineSeparator();
public String getLineSeparator() {
return lineSeparator;
}
public void setLineSeparator(String ls) {
lineSeparator = ls;
return;
}
/** *****************************************************************
* A int value representing the bit values that control the file
* generation process.
*/
protected int docGenControlBits = 0;
/** *****************************************************************
* Returns the int value that represents the bit values used to
* guide aspects of the document generation process for this
* DocGen instance.
*
* @return An int value representing bit values
*/
public int getDocGenControlBits() {
return docGenControlBits;
}
/** *****************************************************************
* Sets to 0 the int value that represents the bit values used to
* guide aspects of the document generation process for this
* DocGen instance.
*/
public void clearDocGenControlBits() {
docGenControlBits = 0;
return;
}
/** *****************************************************************
* Adds val via bitwise OR to the int value that represents the
* bit values used to control the document generation process for
* this DocGen instance.
*
* @param val An integer representing bit values
*
* @return An int value representing the result of the bitwise OR
* operation.
*/
public int addDocGenControlBits(int val) {
docGenControlBits = (docGenControlBits | val);
return docGenControlBits;
}
/** *****************************************************************
* Adds via bitwise OR the bit value corresponding to token to the
* int value that represents the bit values used to control the
* document generation process for this DocGen instance.
*
* @param val An integer representing bit values
*
* @return An int value representing the result of the bitwise OR
* operation.
*/
public int addDocGenControlBits(String token) {
int bitVal = getControlBitValue(token);
return addDocGenControlBits(bitVal);
}
/** *****************************************************************
* Returns true if the bit values represented by valToTest are
* among the control bits represented for this DocGen instance.
*
* @param valToTest An integer representing bit values to be tested
*
* @return true or false
*/
public boolean testDocGenControlBits(int valToTest) {
// System.out.println("ENTER DocGen.testDocGenControlBits(" + valToTest + ")");
boolean ans = false;
try {
// System.out.println(" getDocGenControlBits() == " + getDocGenControlBits());
int bitAnd = (valToTest & getDocGenControlBits());
// System.out.println(" bitAnd == " + bitAnd);
ans = (bitAnd == valToTest);
}
catch (Exception ex) {
ex.printStackTrace();
}
// System.out.println("EXIT DocGen.testDocGenControlBits(" + valToTest + ")");
// System.out.println(" ans == " + ans);
return ans;
}
/** *****************************************************************
* Returns true if the bit values corresponding to token are among
* the control bits represented for this DocGen instance.
*
* @param token A String token corresponding to a bit value
*
* @return true or false
*/
public boolean testDocGenControlBits(String token) {
int bitVal = getControlBitValue(token);
return testDocGenControlBits(bitVal);
}
/** **************************************************************
* Returns a List of String tokens that determine how the output
* should be formatted. The List could be empty.
*
* @param kb The KB in which to look for docGenOutputFormat statements
*
* @param ontology A SUO-KIF term denoting an Ontology
*
* @return a List of Strings, which could be empty
*/
public static ArrayList getOutputFormatTokens(KB kb, String ontology) {
ArrayList tokens = new ArrayList();
try {
String tkn = null;
if (StringUtil.isNonEmptyString(ontology)) {
for (Iterator it = kb.getTermsViaAskWithRestriction(0,
"docGenOutputFormat",
1,
ontology,
2).iterator();
it.hasNext();) {
tkn = StringUtil.removeEnclosingQuotes(it.next().toString().toLowerCase());
if (!tokens.contains(tkn)) tokens.add(tkn);
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return tokens;
}
/** **************************************************************
* Returns the first String token retrieved from ontology in kb
* that denotes an HTML output format. Such tokens may be the
* third element in statements for which the predicate is
* docGenOutputFormat.
*
* @param kb The KB in which to look for docGenOutputFormat statements
*
* @param ontology A SUO-KIF term denoting an Ontology
*
* @return a String token, or null.
*/
public static String getFirstHtmlFormatToken(KB kb, String ontology) {
return F_SI;
}
/** The default namespace associated with this DocGen object */
protected String defaultNamespace = "";
/** *****************************************************************
* Returns the String denoting the default namespace
* associated with this DocGen object.
*
*/
public String getDefaultNamespace() {
try {
if (StringUtil.emptyString(this.defaultNamespace)) {
// If no value has been set, check to see if a value
// is stored in the KB.
KB kb = this.getKB();
String onto = this.getOntology();
setDefaultNamespace(StringUtil.isNonEmptyString(onto)
? kb.getFirstTermViaAskWithRestriction(0,
"docGenDefaultNamespace",
1,
onto,
2)
: null);
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return this.defaultNamespace;
}
/** *****************************************************************
* Sets the default namespace for this DocGen object.
*/
public void setDefaultNamespace(String namespace) {
this.defaultNamespace = namespace;
return;
}
/** *****************************************************************
* The default namespace for predicates in the ontology associated
* with this DocGen object
*/
protected String defaultPredicateNamespace = "";
/** *****************************************************************
* Returns the String denoting the default namespace for
* predicates in the ontology associated with this DocGen
* object.
*
*/
public String getDefaultPredicateNamespace() {
try {
if (StringUtil.emptyString(this.defaultPredicateNamespace)) {
KB kb = getKB();
String onto = getOntology();
String dpn =
(StringUtil.isNonEmptyString(onto)
? kb.getFirstTermViaAskWithRestriction(0,
"docGenDefaultPredicateNamespace",
1,
onto,
2)
: null);
setDefaultPredicateNamespace(dpn);
if (StringUtil.emptyString(this.defaultPredicateNamespace)) {
setDefaultPredicateNamespace(getDefaultNamespace());
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return this.defaultPredicateNamespace;
}
/** *****************************************************************
* Sets the default namespace for predicates in the ontology
* associated with this DB object.
*
*/
public void setDefaultPredicateNamespace(String namespace) {
this.defaultPredicateNamespace = namespace;
return;
}
/** *****************************************************************
* The ontology associated with this DocGen object, and for
* which the DocGen object is used to generate files.
*/
protected String ontology = null;
/** *****************************************************************
*/
public void setOntology(String term) {
this.ontology = term;
return;
}
/** *****************************************************************
* Returns a term denoting the default Ontology for this DocGen
* object if an Ontology has been set, and tries very hard to find
* a relevant Ontology if one has not been set.
*/
public String getOntology() {
try {
String onto = this.ontology;
if (StringUtil.emptyString(onto)) {
KB kb = this.getKB();
onto = this.getOntology(kb);
if (StringUtil.isNonEmptyString(onto)) {
this.setOntology(onto);
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return this.ontology;
}
/** *****************************************************************
* Returns a term denoting the default Ontology for this DocGen
* object if an Ontology has been set, and tries very hard to find
* a relevant Ontology if one has not been set.
*/
public String getOntology(KB kb) {
String onto = null;
try {
if (StringUtil.isNonEmptyString(this.ontology))
onto = this.ontology;
else {
Set candidates = new HashSet();
if (kb == null)
kb = this.getKB();
Iterator it = null;
// First, we try to find any obvious instances of
// Ontology, using predicate subsumption to take
// advantage of any predicates that have been
// liked with SUMO's predicates.
for (it = kb.kbCache.instances.get("Ontology")
.iterator(); it.hasNext();) {
candidates.add((String) it.next());
}
if (candidates.isEmpty()) {
// Next, we check for explicit
// ontologyNamespace statements.
List formulae = kb.ask("arg", 0, "ontologyNamespace");
if ((formulae != null) && !formulae.isEmpty()) {
Formula f = null;
for (it = formulae.iterator(); it.hasNext();) {
f = (Formula) it.next();
candidates.add(f.getArgument(1));
}
}
}
if (!candidates.isEmpty()) {
// Here we try to match one of the ontologies
// to the name of the current KB, since we
// have no other obvious way to determine
// which ontology is appropriate if two or
// more are represented in the KB. This
// section probably should use some word/token
// based partial matching algorithm, but does
// not. We just accept the first fairly
// liberal regex match.
String termstr = null;
String ontoPattern = null;
String kbNamePattern = (".*(?i)" + kb.name + ".*");
for (it = candidates.iterator(); it.hasNext();) {
termstr = (String) it.next();
ontoPattern = (".*(?i)" + termstr + ".*");
if (termstr.matches(kbNamePattern) || kb.name.matches(ontoPattern)) {
onto = termstr;
break;
}
}
if (onto == null) {
// Finally, if onto is still null and
// candidates is not empty, we just grab a
// candidate and try it.
it = candidates.iterator();
if (it.hasNext())
onto = (String) it.next();
}
}
if (StringUtil.isNonEmptyString(onto))
this.setOntology(onto);
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return onto;
}
/** *****************************************************************
* The KB associated with this DocGen object.
*/
protected KB kb = null;
/** *****************************************************************
*/
public void setKB(KB kb) {
this.kb = kb;
return;
}
/** *****************************************************************
*
*/
public KB getKB() {
return this.kb;
}
/** *************************************************************
* A Set of Strings.
*/
protected Set codedIdentifiers = null;
/** **************************************************************
* Collects and returns the Set containing all known coded
* identifiers in kb, including ISO code values stated to be such.
*
* @param kb The KB in which to gather terms defined as coded
* identifiers
*
* @return A Set of all the terms that denote ISO code values and
* other coded identifiers
*/
protected Set getCodedIdentifiers(KB kb) {
try {
if (codedIdentifiers == null) {
codedIdentifiers = new TreeSet();
}
if (codedIdentifiers.isEmpty()) {
Set codes = kb.kbCache.instances.get("CodedIdentifier");
Set classNames = kb.kbCache.instances.get("CodedIdentifier");
classNames.add("CodedIdentifier");
Object[] namesArr = classNames.toArray();
if (namesArr != null) {
String className = null;
for (int i = 0; i < namesArr.length; i++) {
className = (String) namesArr[i];
codes.addAll(kb.getTermsViaPredicateSubsumption("instance",2,className,1,false));
}
}
codedIdentifiers.addAll(codes);
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return codedIdentifiers;
}
/** The document title text to be used for HTML generation */
protected String titleText = "";
/** *************************************************************
* Sets the title text to be used during HTML document generation.
*
* @param titlestr A String that will be used as the HTML document
* title
*/
public void setTitleText(String titlestr) {
titleText = titlestr;
return;
}
/** *************************************************************
* Returns the String that will be used as the title text for HTML
* document generation, else returns an empty String if no title
* text value has been set.
*/
public String getTitleText() {
return titleText;
}
/** The document footer text to be used for HTML generation */
protected String footerText = "";
//"Produced by " + "Articulate Software and its partners";
/** *************************************************************
* Sets the footer text String to be used during HTML document
* generation.
*
* @param str A String that will be used as the HTML document
* footer text
*/
public void setFooterText(String str) {
footerText = str;
return;
}
/** *************************************************************
* Returns the String that will be used as the footer text for
* HTML document generation, else returns an empty String if no
* footer text value has been set.
*/
public String getFooterText() {
return footerText;
}
/** The style sheet (CSS filename) to be referenced in HTML generation */
protected String styleSheet = "simple.css";
/** *************************************************************
* Sets the base name plus suffix filename of the Cascading Style
* Sheet file to be referenced during HTML document generation.
*
* @param filename A String that is a base filename plus a
* filename suffix
*
*/
public void setStyleSheet(String filename) {
styleSheet = filename;
return;
}
/** *************************************************************
* Returns the base filename plus filename suffix form of the
* Cascading Style Sheet file to be referenced during HTML
* document generation, else returns an empty String if no value
* has been set.
*/
public String getStyleSheet() {
return styleSheet;
}
/** The default image file (such as an organization's logo) to be
* used in HTML generation
*/
protected String defaultImageFile = "articulate_logo.gif";
/** *************************************************************
* Sets the base name plus suffix filename of the logo image file
* to be referenced during HTML document generation.
*
* @param filename A String that is a base filename plus a
* filename suffix
*
*/
public void setDefaultImageFile(String filename) {
defaultImageFile = filename;
return;
}
/** *************************************************************
* Returns the base filename plus filename suffix form of the logo
* image file to be referenced during HTML document generation,
* else returns an empty String if no value has been set.
*/
public String getDefaultImageFile() {
return defaultImageFile;
}
/** The default image file (such as an organization's logo) to be
* used in HTML generation, wrapped in any necessary additional
* markup required for proper display.
*/
protected String defaultImageFileMarkup = "articulate_logo.gif";
/** *************************************************************
* Sets the base name plus suffix filename of the logo image file
* to be referenced during HTML document generation.
*
* @param markup A String that includes the image file pathname
* plus any additional markup required for proper display of the
* image
*
*/
public void setDefaultImageFileMarkup(String markup) {
defaultImageFileMarkup = markup;
return;
}
/** *************************************************************
* Returns the base filename plus filename suffix form of the logo
* image file, wrapped in any additional markup required for the
* intended rendering of the image.
*/
public String getDefaultImageFileMarkup() {
return defaultImageFileMarkup;
}
/** The canonical pathname of the current directory in which
* output files will be (are being) saved.
*/
protected String outputDirectoryPath = "";
/** *************************************************************
* Sets the canonical pathname String of the current directory in
* which output files will be (are being) saved.
*
* @param pathname A canonical pathname String
*
*/
public void setOutputDirectoryPath(String pathname) {
outputDirectoryPath = pathname;
return;
}
/** *************************************************************
* Returns the canonical pathname String of the current directory
* in which output files will be (are being) saved.
*/
public String getOutputDirectoryPath() {
return this.outputDirectoryPath;
}
/** *************************************************************
* A Map containing String replacement pairs. This is to provide
* adequate ASCII translations for HTML character entities, in
* circumstances where occurrences of the entities might cause
* parsing or rendering problems (e.g., apparently, in XSD files).
*
*/
protected Map stringReplacementMap = null;
/** *************************************************************
* Sets the Map to be used for HTML character entity to ASCII
* replacements.
*/
public void setStringReplacementMap(Map keyValPairs) {
this.stringReplacementMap = keyValPairs;
return;
}
/** *************************************************************
* Returns the Map to be used for HTML character entity to ASCII
* replacements, attempting to build it from
* docGenCodeMapTranslation statements found in the KB if the Map
* does not already exist.
*/
public Map getStringReplacementMap() {
try {
if (stringReplacementMap == null) {
Map srMap = new HashMap();
KB kb = getKB();
if (kb != null) {
List formulae = kb.ask("arg", 0, "docGenCodeMapTranslation");
if (formulae != null) {
Formula f = null;
for (Iterator it = formulae.iterator(); it.hasNext();) {
f = (Formula) it.next();
srMap.put(StringUtil.removeEnclosingQuotes(f.getArgument(2)),
StringUtil.removeEnclosingQuotes(f.getArgument(4)));
}
}
}
else {
System.out.println("WARNING in DocGen.getStringReplacementMap()");
System.out.println(" DocGen.defaultKB is not set");
}
if (srMap.isEmpty()) {
System.out.println("WARNING in DocGen.getStringReplacementMap()");
System.out.println(" DocGen.stringReplacementMap is empty");
}
setStringReplacementMap(srMap);
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return this.stringReplacementMap;
}
/** *************************************************************
* Returns the String replacement for fromString, if one can be
* located, else just returns fromString.
*
* @param fromString A String for which a replacement is sought
*
* @return A replacement String
*/
public String getStringReplacement(String fromString) {
String toString = fromString;
try {
Map replacements = getStringReplacementMap();
if (replacements != null) {
String rep = (String) replacements.get(fromString);
if (rep != null) {
toString = rep;
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return toString;
}
/** A set of the predicates that should not be displayed to the user. */
protected Set inhibitDisplayRelations = null;
/** *************************************************************
* Sets the predicates for which diplay should be suppressed to
* those contained in relations.
*
* @param relations A Set of predicate names
*
*/
public void setInhibitDisplayRelations(Set relations) {
this.inhibitDisplayRelations = relations;
return;
}
/** *************************************************************
* Returns a Set containing the names of those predicates for
* which diplay should be suppressed, and tries to create the Set
* from docGenInhibitDisplayRelations statements found in the
* current KB if the Set does not already exist.
*
* @return a Set of predicate names
*/
public Set getInhibitDisplayRelations() {
try {
if (inhibitDisplayRelations == null) {
KB kb = getKB();
String ontology = getOntology();
Set idr = new TreeSet();
if ((kb != null) && StringUtil.isNonEmptyString(ontology)) {
idr.addAll(kb.getTermsViaAskWithRestriction(0,
"docGenInhibitDisplayRelation",
1,
ontology,
2));
}
setInhibitDisplayRelations(idr);
if (inhibitDisplayRelations.isEmpty()) {
System.out.println("WARNING in DocGen.getInhibitDisplayRelations()");
System.out.println(" DocGen.inihibitDisplayRelations is empty");
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return inhibitDisplayRelations;
}
/** *************************************************************
* The header to be used for the the table of contents (or index
* list) section during HTML generation.
*/
protected String tocHeader = "";
/** *************************************************************
* Sets the String header to be used in generated HTML files to
* header.
*/
public void setTocHeader(String header) {
this.tocHeader = header;
return;
}
/** *************************************************************
* Returns the String header to be used in generated HTML files.
*/
public String getTocHeader() {
return this.tocHeader;
}
/** A default key to identify this particular DocGen object **/
protected String docGenKey = DEFAULT_KEY;
/**
* Returns the String key that is the index for this particular
* DocGen object.
*
*/
public String getDocGenKey() {
return this.docGenKey;
}
/**
* Sets the String key that is the index for this particular
* DocGen object.
*
*/
public void setDocGenKey(String key) {
this.docGenKey = key;
return;
}
public static String getKifNamespaceDelimiter() {
return StringUtil.getKifNamespaceDelimiter();
}
public static String getW3cNamespaceDelimiter() {
return StringUtil.getW3cNamespaceDelimiter();
}
public static String getSafeNamespaceDelimiter() {
return StringUtil.getSafeNamespaceDelimiter();
}
/** *************************************************************
* If true, a termFormat value obtained for term will be displayed
* rather than the term name itself.
*/
protected boolean simplified = false;
/** *************************************************************
* Returns true if a termFormat value obtained for term will be
* displayed during HTML rendering rather than the term name
* itself.
*/
public boolean getSimplified() {
return this.simplified;
}
/** *************************************************************
* Sets this.simplified to val. If this.simplified is true, the
* statements in Sigma's KB will be rendered in a simple
* frame-like HTML format rather than as SUO-KIF Formulas.
*/
public void setSimplified(boolean val) {
this.simplified = val;
return;
}
/** *************************************************************
* A Map in which each key is a KB name and the corresponding
* value is a List of the Predicates defined in the KB.
*/
protected HashMap relationsByKB = new HashMap();
public HashMap getRelationsByKB() {
return relationsByKB;
}
/** *************************************************************
* Returns a String consisting of str concatenated indent times.
*
* @param str The String to be concatentated with itself
*
* @param indent An int indicating the number of times str should
* be concatenated
*
* @return A String
*/
public static String indentChars(String str, int indent) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < indent; i++) {
result.append(str);
}
return result.toString();
}
/** *************************************************************
* The parent directory for target subdirectories of HTML, XSD,
* and other types of files generated by this DocGen object.
*/
protected File outputParentDir = null; // new File(KBmanager.getMgr().getPref("baseDir"));
/** *************************************************************
* Sets the parent directory in which subdirectories for different
* types of output files will be created to the File obj, and
* tries to create the directory pathname if it does not already
* exist.
*
* @param obj A File object representing a directory
*/
public void setOutputParentDir(File obj) {
try {
if (obj != null) {
if (!obj.exists() || !obj.isDirectory() || !obj.canWrite()) {
System.out.println("WARNING in DocGen.setOutputParentDir(" + obj + "):");
System.out.println(" " + obj + " is not an accessible directory");
String pathname = obj.getCanonicalPath();
if (StringUtil.isNonEmptyString(pathname)) {
System.out.println(" Will try to create " + pathname);
obj.mkdirs();
}
}
if (obj.isDirectory() && obj.canWrite())
this.outputParentDir = obj;
else {
System.out.println("WARNING in DocGen.setOutputParentDir(" + obj + "):");
System.out.println(" Could not set outputParentDir");
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return;
}
/** *************************************************************
* Sets to pathname the parent directory in which subdirectories
* for different types of output files will be created, and tries
* to create the directory pathname if it does not already exist.
*
* @param pathname A String representing a directory pathname
*/
public void setOutputParentDir(String pathname) {
try {
if (StringUtil.isNonEmptyString(pathname)) {
setOutputParentDir(new File(pathname));
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return;
}
/** *************************************************************
* Sets the parent directory in which subdirectories for different
* types of output files will be created to the File obj, and
* tries to create the directory pathname if it does not already
* exist.
*
* @param pathname A String representing a directory pathname
*/
public void setOutputParentDir(List pathnameComponents) {
try {
String fs = System.getProperty("file.separator");
StringBuilder sb = new StringBuilder();
String comp = null;
boolean isFirst = true;
for (Iterator it = pathnameComponents.iterator(); it.hasNext();) {
comp = (String) it.next();
if (isFirst) {
if ((comp instanceof String) && comp.equals("")) {
comp = fs;
}
}
else {
sb.append(fs);
}
sb.append(comp);
isFirst = false;
}
String pathname = sb.toString();
if (StringUtil.isNonEmptyString(pathname)) {
setOutputParentDir(new File(pathname));
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return;
}
/** *************************************************************
* Sets the parent directory in which subdirectories for different
* types of output files will be created to the abstract pathname
* represented by a statement in kb formed with the predicate
* docGenOutputParentDirectory and the argument ontology. Tries
* to create the directory pathname if it does not already exist.
*
* @param kb The KB containing a statement formed with the
* predicate docGenOutputParentDirectory and ontology
*
* @param ontology The ontology referred to in a statement formed
* with the predicate docGenOutputParentDirectory in kb
*
*/
public void setOutputParentDir(KB kb, String ontology) {
try {
if (StringUtil.isNonEmptyString(ontology)) {
String flist = kb.getFirstTermViaAskWithRestriction(0,
"docGenOutputParentDirectory",
1,
ontology,
2);
if (StringUtil.isNonEmptyString(flist)) {
Formula f = new Formula();
f.read(flist);
if (f.listP()) {
ArrayList pathnameComponents = new ArrayList();
String comp = null;
for (int i = 0; f.listP() && !f.empty(); i++) {
comp = StringUtil.removeEnclosingQuotes(f.car());
if (!((i == 0) && comp.equals("ListFn"))) {
pathnameComponents.add(comp);
}
f.read(f.cdr());
}
setOutputParentDir(pathnameComponents);
}
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return;
}
/** *************************************************************
* Returns a File object representing the directory in which the
* subdirectories for the various types of output files will be
* located.
*/
public File getOutputParentDir() {
return this.outputParentDir;
}
public interface DisplayFilter {
/** ***************************************************************
* Returns true if suoKifTerm may be displayed or included in the
* particular UI text or other output generated by the DocGen
* object dg.
*
* @param dg The DocGen object that will use this filter to
* determine which terms should be displayed or otherwise included
* in generated output
*
* @param suoKifTerm A term in the SUO-KIF representation
* language, which could be an atomic constant, a variable, a
* quoted character string, or a list
*
* @return true or false
*/
public boolean isLegalForDisplay (DocGen dg, String suoKifTerm);
}
/** *************************************************************
* The DisplayFilter which, if present, determines if a given
* SUO-KIF object may be displayed or output by this DocGen
* object.
*/
protected DisplayFilter displayFilter = null;
/** *************************************************************
* Sets the DisplayFilter associated with this DocGen object to
* filterObj.
*
* @param filterObj An instance of DisplayFilter
*/
public void setDisplayFilter(DisplayFilter filterObj) {
this.displayFilter = filterObj;
return;
}
/** *************************************************************
* Returns the DisplayFilter object associated with this DocGen
* object, or null if no DisplayFilter has been set.
*/
public DisplayFilter getDisplayFilter() {
return this.displayFilter;
}
public class PresentationNameComparator implements Comparator {
protected DocGen docGen = null;
public DocGen getDocGen() {
return docGen;
}
public void setDocGen(DocGen gen) {
docGen = gen;
return;
}
protected KB kb = null;
public KB getKB() {
return kb;
}
public void setKB(KB kbObj) {
kb = kbObj;
return;
}
public int compare(Object o1, Object o2) {
String str1 = ((o1 == null) ? "" : StringUtil.removeEnclosingQuotes(o1.toString()));
String str2 = ((o2 == null) ? "" : StringUtil.removeEnclosingQuotes(o2.toString()));
DocGen gen = getDocGen();
if (gen != null) {
KB gKB = gen.getKB();
str1 = gen.getTermPresentationName(gKB, str1);
str2 = gen.getTermPresentationName(gKB, str2);
}
return String.CASE_INSENSITIVE_ORDER.compare(str1, str2);
}
public boolean equals(Object obj) {
boolean ans = true;
if (ans) {
PresentationNameComparator pnc = (PresentationNameComparator) obj;
KB eKB = getKB();
DocGen dg = getDocGen();
ans = ((dg != null)
&& (pnc instanceof PresentationNameComparator)
&& (pnc.getDocGen().equals(dg)));
if (ans) {
ans = (eKB == pnc.getKB());
}
}
return ans;
}
/** ***************************************************************
* should never be called so throw an error.
*/
public int hashCode() {
assert false : "DocGen.hashCode not designed";
return 0;
}
} // end of PresentationNameComparator
/** *************************************************************
* Rebuilds the TreeSet containing all terms in kb, and forces
* the new TreeSet to sort according to each term's presentation
* name.
*/
public SortedSet resortKbTerms(KB kb) {
long t1 = System.currentTimeMillis();
System.out.println("ENTER DocGen.resortKbTerms(" + kb.name + ")");
try {
PresentationNameComparator pnc = new PresentationNameComparator();
pnc.setKB(kb);
pnc.setDocGen(this);
TreeSet ts = new TreeSet(pnc);
synchronized (kb.getTerms()) {
ts.addAll(kb.getTerms());
}
kb.setTerms((SortedSet) ts);
}
catch (Exception ex) {
ex.printStackTrace();
}
System.out.println("EXIT DocGen.resortKbTerms(" + kb.name + ")");
System.out.println(" "
+ kb.getTerms().size()
+ " KB terms sorted in "
+ ((System.currentTimeMillis() - t1) / 1000.0)
+ " seconds");
return kb.getTerms();
}
/** *************************************************************
* A TreeMap of TreeMaps of ArrayLists where the keys are
* uppercase single characters (of term formats or headwords) and
* the values are TreeMaps with a key of the term formats or
* headwords and ArrayList values of the actual term names. Note
* that if "simplified" is false actual term names will be used
* instead of term formats or headwords and the interior map will
* have keys that are the same as their values.
*
* Pictorially:
*
* letter-> formattedTerm1->term11,term12...term1N
* formattedTerm2->term21,term22...term2N
*/
protected TreeMap alphaList = new TreeMap(String.CASE_INSENSITIVE_ORDER);
/** *************************************************************
* @param stringMap is a map of String keys and values
* @return a TreeMap of TreeMaps of ArrayLists where the keys
* are uppercase single characters (of term formats or
* headwords) and the values are TreeMaps with a key of
* the term formats or headwords and ArrayList values
* of the actual term names. Note that if "simplified"
* is false actual term names will be used instead of
* term formats or headwords and the interior map will
* have keys that are the same as their values.
*
* Pictorially:
* letter-> formattedTerm1->term11,term12...term1N
* formattedTerm2->term21,term22...term2N
*/
public TreeMap getAlphaList(KB kb) {
try {
if (alphaList.isEmpty()) {
synchronized (alphaList) {
createAlphaList(kb);
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return alphaList;
}
/** *************************************************************
* Clears the alphaList for this DocGen object.
*/
public void clearAlphaList() {
try {
synchronized (alphaList) {
alphaList.clear();
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return;
}
/** *************************************************************
* @param stringMap is a map of String keys and values
* @return a TreeMap of TreeMaps of ArrayLists where the keys
* are uppercase single characters (of term formats or
* headwords) and the values are TreeMaps with a key of
* the term formats or headwords and ArrayList values
* of the actual term names. Note that if "simplified"
* is false actual term names will be used instead of
* term formats or headwords and the interior map will
* have keys that are the same as their values.
*
* Pictorially:
* letter-> formattedTerm1->term11,term12...term1N
* formattedTerm2->term21,term22...term2N
*/
protected TreeMap createAlphaList(KB kb) { // , HashMap stringMap
/*
long t1 = System.currentTimeMillis();
System.out.println("ENTER DocGen.createAlphaList("
+ kb.name // + ", "
// + "[map with " + stringMap.size() + " entries]"
+ ")");
*/
try {
alphaList.clear();
Set kbterms = kb.getTerms();
synchronized (kbterms) {
for (Iterator it = kbterms.iterator(); it.hasNext();) {
String term = (String) it.next();
if (isLegalForDisplay(StringUtil.w3cToKif(term))
&& !getCodedIdentifiers(kb).contains(term)
// && !term.matches("^iso\\d+.*_.+")
) {
String formattedTerm = stripNamespacePrefix(kb, term);
if (getSimplified()) {
String smterm = // (String) stringMap.get(term);
getTermPresentationName(kb, term);
if (StringUtil.isNonEmptyString(smterm)) {
formattedTerm = stripNamespacePrefix(kb, smterm);
}
}
if (StringUtil.isNonEmptyString(formattedTerm)) {
String firstLetter =
Character.toString(Character.toUpperCase(formattedTerm.charAt(0)));
Set alset = alphaList.keySet();
if ((alset != null) && alset.contains(firstLetter)) {
TreeMap map = (TreeMap) alphaList.get(firstLetter);
ArrayList al = (ArrayList) map.get(formattedTerm);
if (al == null) {
al = new ArrayList();
map.put(formattedTerm,al);
}
al.add(term);
//System.out.println(firstLetter + " " + formattedTerm + " " + term);
}
else {
TreeMap map = new TreeMap(String.CASE_INSENSITIVE_ORDER);
ArrayList al = new ArrayList();
al.add(term);
map.put(formattedTerm,al);
alphaList.put(firstLetter,map);
//System.out.println(firstLetter + " " + formattedTerm + " " + term);
}
}
else {
// System.out.println(" term == " + term);
// System.out.println(" formattedTerm == " + formattedTerm);
}
}
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
/*
System.out.println("EXIT DocGen.createAlphaList("
+ kb.name // + ", "
// + "[map with " + stringMap.size() + " entries]"
+ ")");
System.out.println(" "
+ ((System.currentTimeMillis() - t1) / 1000.0)
+ " seconds elapsed time");
*/
return alphaList;
}
/** **************************************************************
* Returns true if term is an instance or subclass of
* CompositeContentBearingObject in kb, else returns false.
*
* @param kb The KB in which to check the definition of term
*
* @param term A SUO-KIF term
*
* @return true or false
*/
public static boolean isComposite(KB kb, String term) {
boolean ans = false;
try {
ans = (kb.isInstanceOf(term, "CompositeContentBearingObject")
|| kb.isSubclass(term, "CompositeContentBearingObject")
|| kb.isInstanceOf(term, "CompositeContentBearingObjectType"));
}
catch (Exception ex) {
ex.printStackTrace();
}
return ans;
}
/** **************************************************************
* Returns an ArrayList of Strings extracted from the range
* argument (arg2) of the first retrieved statement formed with
* predicate. If no statement can be retrieved, the ArrayList
* will be empty.
*
* @param kb The KB from which to retrieve a statement with predicate
*
* @param predicate
*
* @return An ArrayList of Strings, which could be empty.
*/
public static ArrayList getRangeValueList(KB kb, String predicate) {
ArrayList rangeList = new ArrayList();
try {
List range = kb.getTermsViaAsk(0,predicate,2);
if (!range.isEmpty()) {
String kifList = (String) range.get(0);
if (StringUtil.isNonEmptyString(kifList)) {
kifList = StringUtil.removeEnclosingQuotes(kifList);
Formula f = new Formula();
f.read(kifList);
String term = null;
for (int i = 0; f.listP() && !f.empty(); i++) {
term = StringUtil.removeEnclosingQuotes(f.car());
if (i > 0) {
rangeList.add(term);
}
f.read(f.cdr());
}
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return rangeList;
}
/** **************************************************************
* Tries to use the values obtained from kb and ontology to set
* some of the parameter values used for HTML generation.
*
* @param kb The KB from which to gather stated parameter values
*
* @param ontology The ontology from which to gather stated
* parameter values
*
* @return void
*/
public void setMetaDataFromKB(KB kb, String ontology) {
if (StringUtil.isNonEmptyString(ontology)) {
List predicates = Arrays.asList("docGenDefaultNamespace",
"docGenDefaultPredicateNamespace",
"docGenLogoImageFile",
"docGenLogoImageMarkup",
"docGenStyleSheet",
"docGenTitleText",
"docGenFooterText");
for (String pred : predicates) {
String val =
kb.getFirstTermViaAskWithRestriction(0,
pred,
1,
ontology,
2);
val = StringUtil.removeEnclosingQuotes(val);
val = StringUtil.removeQuoteEscapes(val);
if (StringUtil.isNonEmptyString(val)) {
if (pred.equals("docGenDefaultNamespace"))
setDefaultNamespace(val);
else if (pred.equals("docGenDefaultPredicateNamespace"))
setDefaultPredicateNamespace(val);
else if (pred.equals("docGenLogoImageFile"))
setDefaultImageFile(val);
else if (pred.equals("docGenLogoImageMarkup"))
setDefaultImageFileMarkup(val);
else if (pred.equals("docGenStyleSheet"))
setStyleSheet(val);
else if (pred.equals("docGenTitleText")
&& StringUtil.emptyString(getTitleText()))
setTitleText(val);
else if (pred.equals("docGenFooterText")
&& StringUtil.emptyString(getFooterText()))
setFooterText(val);
}
}
}
DisplayFilter df = new DisplayFilter() {
Map boolMap = new HashMap();
public boolean isLegalForDisplay(DocGen dg, String term) {
boolean ans = StringUtil.isNonEmptyString(term);
try {
String boolStr = (String) boolMap.get(term);
if (StringUtil.isNonEmptyString(boolStr)) {
ans = Boolean.parseBoolean(boolStr);
}
else if (ans && (dg != null)) {
KB dgkb = dg.getKB();
String dgonto =
StringUtil.removeEnclosingQuotes(dg.getOntology());
if ((dgkb != null)
&& StringUtil.isNonEmptyString(dgonto)) {
String nsd = StringUtil.getW3cNamespaceDelimiter();
ans = (getClientOntologyNames().contains(dgonto)
&& term.matches("^\\w+" + nsd + ".+")
&& !StringUtil.isLocalTermReference(term));
if (ans) {
String namespace =
dg.getTermNamespace(dgkb, term);
List ontoNamespaces =
// dg.getOntologyNamespaces(dgkb, dgonto);
dg.getNamespaces(dgkb, dgonto, false);
ans =
(ontoNamespaces.contains(namespace)
|| ontoNamespaces.contains(term));
}
}
boolMap.put(term, Boolean.toString(ans));
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return ans;
}
};
setDisplayFilter(df);
return;
}
/** *************************************************************
* Returns a List of the names of all client ontologies currently
* represented in any loaded KB.
*/
protected static List getClientOntologyNames() {
ArrayList clientOntologyNames = new ArrayList();
try {
Set ontologies = new HashSet();
for (Iterator it = KBmanager.getMgr().kbs.values().iterator(); it.hasNext();) {
KB kb = (KB) it.next();
ontologies.addAll(kb.getTermsViaAsk(0, "docGenClientOntology", 2));
}
clientOntologyNames.addAll(ontologies);
}
catch (Exception ex) {
ex.printStackTrace();
}
return clientOntologyNames;
}
/** *************************************************************
* Create an HTML page that lists information about a particular
* composite term, which is a representation of an XML
* structure.
*
* @param alphaList a TreeMap of TreeMaps of ArrayLists. @see
* createAlphaList()
*/
public String createCompositePage(KB kb,
String kbHref,
String term,
TreeMap alphaList,
int limit,
String language,
String formatToken) {
/*
System.out.println("ENTER DocGen.createCompositePage("
+ kb.name + ", "
+ kbHref + ", "
+ term + ", "
+ "[alphaList with " + alphaList.size() + " entries], "
+ limit + ", "
+ language + ", "
+ formatToken + ")");
*/
String markup = "";
try {
if (StringUtil.isNonEmptyString(term)) {
/*
if (formatToken.equalsIgnoreCase(F_SI2)) {
markup = createCompositePage(kb, kbHref, term, alphaList, limit, language);
}
else {
*/
StringBuilder result = new StringBuilder();
if (StringUtil.isNonEmptyString(kbHref))
result.append(generateDynamicTOCHeader(kbHref));
else
result.append(generateTocHeader(kb,
alphaList,
INDEX_FILE_NAME
));
result.append("");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(showTermName(kb,term,language));
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
String relevance = ""; // createTermRelevanceNotice(kb, kbHref, term, language);
if (StringUtil.isNonEmptyString(relevance)) {
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(relevance);
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
}
result.append(createDocs(kb,kbHref,term,language));
result.append("
");
result.append(StringUtil.getLineSeparator());
result.append("");
result.append(StringUtil.getLineSeparator());
result.append(createDisplayNames(kb, kbHref, term, formatToken));
result.append(StringUtil.getLineSeparator());
result.append(createSynonyms(kb, kbHref, term, formatToken));
result.append(StringUtil.getLineSeparator());
ArrayList superComposites = findContainingComposites(kb, term);
Collections.sort(superComposites, String.CASE_INSENSITIVE_ORDER);
StringBuilder sb1 = new StringBuilder();
sb1.append(createHasSameComponents(kb, kbHref, term, language));
if ((sb1.length() > 0)
|| !superComposites.isEmpty()
|| hasSubComponents(kb, term)) {
result.append("");
result.append(StringUtil.getLineSeparator());
result.append(" Component Structure ");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
if (sb1.length() > 0) {
result.append(sb1);
sb1.setLength(0);
}
if (hasSubComponents(kb, term)) {
result.append("");
result.append(StringUtil.getLineSeparator());
result.append(" Components ");
result.append(StringUtil.getLineSeparator());
result.append(" Name ");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(" Description of Element Role");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(" Cardinality ");
result.append(StringUtil.getLineSeparator());
result.append(" Data Type ");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
ArrayList attrs = new ArrayList();
ArrayList elems = new ArrayList();
// If there are shared components, add them first.
ArrayList accumulator =
new ArrayList(getSyntacticExtensionTerms(kb, term, 2, false));
ArrayList sharesComponentsWith = new ArrayList();
// System.out.println(" term == " + term);
// System.out.println(" accumulator == " + accumulator);
while (!accumulator.isEmpty()) {
sharesComponentsWith.clear();
sharesComponentsWith.addAll(accumulator);
accumulator.clear();
String nextTerm = null;
for (Iterator it = sharesComponentsWith.iterator(); it.hasNext();) {
nextTerm = (String) it.next();
ArrayList nextPair = createCompositeRecurse(kb, nextTerm, false, 0);
ArrayList nextAttrs = ((ArrayList) nextPair.get(0));
ArrayList nextElems = ((ArrayList) nextPair.get(1));
attrs.addAll(0, nextAttrs);
if (!nextElems.isEmpty()) {
nextElems.remove(0);
elems.addAll(0, nextElems);
}
accumulator.addAll(getSyntacticExtensionTerms(kb,
nextTerm,
2,
false));
// System.out.println(" nextTerm == " + nextTerm);
// System.out.println(" accumulator == " + accumulator);
}
}
// Now add the components that pertain to only this
// term.
ArrayList localPair = createCompositeRecurse(kb, term, false, 0);
// No need to show the composite itself.
ArrayList localAttrs = ((ArrayList) localPair.get(0));
ArrayList localElems = ((ArrayList) localPair.get(1));
attrs.addAll(localAttrs);
if (!localElems.isEmpty()) {
localElems.remove(0);
elems.addAll(localElems);
}
ArrayList hier = new ArrayList(attrs);
hier.addAll(elems);
result.append(formatCompositeHierarchy(kb, kbHref, hier, language));
}
if (!superComposites.isEmpty()) {
Collections.sort(superComposites, String.CASE_INSENSITIVE_ORDER);
String formattedContainingComposites =
formatContainingComposites(kb,
kbHref,
superComposites,
term,
language);
if (StringUtil.isNonEmptyString(formattedContainingComposites)) {
result.append("");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(" Is Member of Composites");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(" Composite Name");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(" Description of Element Role");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(" Cardinality");
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(formattedContainingComposites);
result.append(StringUtil.getLineSeparator());
}
}
}
sb1.append(createBelongsToClass(kb, kbHref, term, language));
sb1.append(createUsingSameComponents(kb, kbHref, term, language));
if (sb1.length() > 0) {
result.append("");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(" Relationships");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(" ");
result.append(StringUtil.getLineSeparator());
result.append(sb1);
sb1.setLength(0);
}
result.append("
");
result.append(StringUtil.getLineSeparator());
result.append(generateHtmlFooter(""));
result.append("