本文整理汇总了Python中nl_lib.Concepts.Concepts类的典型用法代码示例。如果您正苦于以下问题:Python Concepts类的具体用法?Python Concepts怎么用?Python Concepts使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Concepts类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: collectDependancyAnalysisNodes
def collectDependancyAnalysisNodes(self):
count = 0
listTSort = list()
for x in self.al.dictEdges.keys():
logger.debug(u"[%s]=%s" % (self.al.dictEdges[x][u"id"], x))
if u"source" in self.al.dictEdges[x]:
source = self.al.dictEdges[x][u"source"]
target = self.al.dictEdges[x][u"target"]
logger.debug(u" Rel : %s" % (self.al.dictEdges[x][ARCHI_TYPE]))
if self.al.dictEdges[x][ARCHI_TYPE] in (u"archimate:FlowRelationship"):
# al.countNodeType(al.dictNodes[source][ARCHI_TYPE])
# al.countNodeType(al.dictNodes[target][ARCHI_TYPE])
# al.countNodeType(al.dictEdges[x][ARCHI_TYPE])
if (self.al.dictNodes[source][ARCHI_TYPE] == u"archimate:BusinessProcess") and \
self.al.dictNodes[target][ARCHI_TYPE] == u"archimate:BusinessProcess":
sourceName = self.al.getNodeName(source)
targetName = self.al.getNodeName(target)
if sourceName[0].isdigit() or targetName[0].isdigit():
continue
logger.debug(u" %s:%s" % (sourceName, targetName))
l = list()
sc = self.findConcept(self.concepts, sourceName)
if sc is None:
logger.debug(u"New Target - %s" % sourceName)
sc = self.concepts.addConceptKeyType(self.al.getNodeName(source), u"Source")
self.getWords(sourceName, sc)
else:
logger.debug(u"Prior Target %s" % sourceName)
tc = self.findConcept(self.concepts, targetName)
if tc is None:
logger.debug(u"New Target %s" % targetName)
tc = sc.addConceptKeyType(self.al.getNodeName(target), u"Target")
self.getWords(sourceName, tc)
else:
logger.debug(u"Prior Target %s" % targetName)
sc.addConcept(tc)
l.append(target)
l.append(source)
listTSort.append(l)
logger.debug(u"Edges = %s" % listTSort)
Concepts.saveConcepts(self.concepts, fileConceptsTraversal)
self.dependancyAnalysis(listTSort)
return self.concepts, listTSort
开发者ID:Darth-Neo,项目名称:al_lib,代码行数:60,代码来源:DependencyAnalysis.py
示例2: exportNeo4JToConcepts
def exportNeo4JToConcepts(self, concepts, fileNodes=u"nodes.p"):
qs = u"Match n return n"
lq, qd = self.cypherQuery(qs)
for x in lq:
if len(x) == 2:
logger.info(u"%s[%s]" % (x[0], x[1]))
concepts.addConceptKeyType(x[0], x[1])
else:
logger.warn(u"Not a standard node : %d : %s" % (len(x), x))
# Match r relations
qs = u"match n-[r]-m return n, r, m"
lq, qd = self.cypherQuery(qs)
for x in lq:
if len(x) == 6:
logger.info(u"%s[%s]" % (x[0], x[1]))
concepts.addConceptKeyType(x[0], x[1])
else:
logger.warn(u"Not a standard node : %d : %s" % (len(x), x))
Concepts.saveConcepts(concepts, fileNodes)
return concepts
开发者ID:Darth-Neo,项目名称:al_lib,代码行数:27,代码来源:Neo4JLib.py
示例3: requirementAnalysis
def requirementAnalysis(fileArchimate=None):
if fileArchimate is None:
fileArchimate = u"/Users/morrj140/Documents/SolutionEngineering/Archimate Models/DVC v38.archimate"
al = ArchiLib(fileArchimate)
conceptsFile = fileConceptsRequirements
searchTypes = list()
searchTypes.append(u"archimate:Requirement")
nl = al.getTypeNodes(searchTypes)
logger.info(u"Find Words in Requirements...")
concepts = Concepts(u"Requirement", u"Requirements")
n = 0
for sentence in nl:
n += 1
logger.debug(u"%s" % sentence)
c = concepts.addConceptKeyType(u"Document" + str(n), u"Document")
d = c.addConceptKeyType(sentence, u"Sentence" + str(n))
if True and sentence is not None:
cleanSentence = ' '.join([word for word in sentence.split(u" ") if word not in stop])
for word, pos in nltk.pos_tag(nltk.wordpunct_tokenize(cleanSentence)):
if len(word) > 1 and pos[0] == u"N":
e = d.addConceptKeyType(word, u"Word")
f = e.addConceptKeyType(pos, u"POS")
Concepts.saveConcepts(concepts, conceptsFile)
logger.info(u"Saved : %s" % conceptsFile)
chunks = Chunks(concepts)
chunks.createChunks()
开发者ID:Darth-Neo,项目名称:ArchiConcepts,代码行数:35,代码来源:al_RequirementAnalysis.py
示例4: test_ExportArchiFolderModels
def test_ExportArchiFolderModels(cleandir):
if __name__ == u"__main__":
cleandir()
assert (os.path.isfile(fileArchimateTest) is True)
al = ArchiLib(fileArchimateTest)
folder = u"Scenarios"
logger.info(u"Exporting Folder : %s" % folder)
listMTE = al.getModelsInFolder(folder)
assert (listMTE is not None)
logger.info(u"len(listMTE) = %d" % len(listMTE))
assert (len(listMTE) == 2)
concepts = Concepts(u"Export", u"Pickle")
for ModelToExport in listMTE:
logger.info(u" Model : %s" % ModelToExport)
d = concepts.addConceptKeyType(ModelToExport, u"Model")
al.recurseModel(ModelToExport)
al.outputCSVtoFile(concepts, fileExport=fileCSVExport)
assert (os.path.isfile(fileCSVExport) is True)
Concepts.saveConcepts(concepts, fileConceptsExport)
logger.info(u"Save Concepts : %s" % fileConceptsExport)
assert (os.path.isfile(fileConceptsExport) is True)
开发者ID:Darth-Neo,项目名称:al_lib,代码行数:31,代码来源:test_ArchiLib.py
示例5: findSimilarties
def findSimilarties(self):
logger.info(u"Compute Similarity")
self.conceptsSimilarity = Concepts(u"ConceptsSimilarity", u"Similarities")
# Compute similarity between documents / concepts
similarityThreshold = self.similarity
for document in self.documentsList:
indexNum = self.documentsList.index(document)
self.df = self.concepts.getConcepts().keys()
logger.info(u"++conceptsDoc %s" % (self.df[indexNum]))
logger.info(u" documentsList[" + str(indexNum) + u"]=" + u"".join(x + u" " for x in document))
# Show common topics
d = [unicode(x).strip().replace(u"'", u"") for x in document]
e = [unicode(y).strip().replace(u"\"", u"") for y in self.listTopics]
s1 = set(e)
s2 = set(d)
common = s1 & s2
lc = [x for x in common]
logger.info(u" Common Topics : %s{%s}" % (lc, self.al.dictName[document][ARCHI_TYPE]))
self.doComputation(indexNum, similarityThreshold, tfAddWords=True)
Concepts.saveConcepts(self.conceptsSimilarity, conceptsSimilarityFile)
logger.info(u"Saved Concepts : %s" % conceptsSimilarityFile)
return self.conceptsSimilarity
开发者ID:RichDijk,项目名称:ArchiConcepts,代码行数:34,代码来源:al_GapSimilarity.py
示例6: saveTopics
def saveTopics(self, topics):
wordConcepts = Concepts(u"TopicConcepts", u"Topics")
for topic in topics:
logger.debug(u"Topic:" + topic[0])
w = wordConcepts.addConceptKeyType(topic[0], u"Topic")
w.count = topic[1]
Concepts.saveConcepts(wordConcepts, self.topicsFile)
return wordConcepts
开发者ID:Darth-Neo,项目名称:nl_lib,代码行数:8,代码来源:TopicsModel.py
示例7: _saveConcepts
def _saveConcepts(self):
logger.info(u"Saving %s" % self.documentsConceptsFile)
Concepts.saveConcepts(self.documentsConcepts, self.documentsConceptsFile)
logger.info(u"Saving %s" % self.wordsConceptsFile)
Concepts.saveConcepts(self.wordsConcepts, self.wordsConceptsFile)
logger.info(u"Saving Documents %s" % os.getcwd() + os.sep + self.documentsConceptsFile)
logger.info(u"Saving Words%s" % os.getcwd() + os.sep + self.wordsConceptsFile)
开发者ID:Darth-Neo,项目名称:DirCrawler,代码行数:8,代码来源:nl_phase_a_DirCrawl.py
示例8: exportArchi
def exportArchi(self):
m = hashlib.md5()
concepts = Concepts(u"Node", u"Nodes")
logger.info(u"Found %d Nodes" % len(self.al.dictNodes))
logger.info(u"Found %d Edges" % len(self.al.dictEdges))
count = 0
listTSort = list()
for x in self.al.dictEdges.keys():
logger.debug(u"Edge [%s]=%s" % (self.al.dictEdges[x], x))
if self.al.dictEdges[x].has_key(u"source") and self.al.dictEdges[x].has_key(u"target"):
typeEdge = self.al.dictEdges[x][ARCHI_TYPE]
logger.debug(u"Edge : %s" % typeEdge)
source = self.al.dictEdges[x][u"source"]
logger.debug(u"Source : %s" % source)
target = self.al.dictEdges[x][u"target"]
logger.debug(u"Target : %s" % target)
logger.debug(u" Rel : %s" % (self.al.dictEdges[x][ARCHI_TYPE]))
sourceName = self.al.getNodeName(source)
targetName = self.al.getNodeName(target)
logger.debug(u" %s--%s--%s" % (sourceName, self.al.dictEdges[x][ARCHI_TYPE][10:], targetName))
if source in self.al.dictNodes:
l = list()
sc = concepts.addConceptKeyType(sourceName, self.al.dictNodes[source][ARCHI_TYPE][10:])
# getWords(sourceName, sc)
nameEdge = u"(" + sourceName + u"," + targetName + u")"
logger.debug(u"nameEdge : %s[%d]" % (nameEdge, len(nameEdge)))
logger.debug(u"typeEdge : %s" % typeEdge[10:])
ne = str(self.al.cleanString(nameEdge))
hl = hashlib.sha224(str(ne)).hexdigest()
logger.debug(u"hash : %s" % hl)
nh = u"%s-%s" % (typeEdge[10:], hl)
rc = sc.addConceptKeyType(nh, typeEdge[10:])
if self.al.dictNodes.has_key(target):
tc = rc.addConceptKeyType(targetName, self.al.dictNodes[target][ARCHI_TYPE][10:])
# getWords(sourceName, tc)
Concepts.saveConcepts(concepts, self.fileConceptsExport)
return concepts
开发者ID:Darth-Neo,项目名称:al_lib,代码行数:57,代码来源:ExportArchi.py
示例9: __init__
def __init__(self, concepts=None):
if concepts is None:
logger.info(u"Loading : %s" % self.conceptFile)
self.concepts = Concepts.loadConcepts(self.conceptFile)
else:
logger.info(u"Using : %s" % concepts.name)
self.concepts = concepts
self.chunkConcepts = Concepts(u"Chunk", u"Chunks")
开发者ID:Darth-Neo,项目名称:ArchiConcepts,代码行数:9,代码来源:al_RequirementAnalysis.py
示例10: test_ExportArchi
def test_ExportArchi(cleandir):
if __name__ == u"__main__":
cleandir()
logger.info(u"Using : %s" % fileArchimateTest)
assert (os.path.isfile(fileArchimateTest) is True)
al = None
concepts = None
al = ArchiLib(fileArchimateTest)
assert (al is not None)
concepts = Concepts(u"Node", u"Nodes")
assert (concepts is not None)
logger.info(u"Found %d Nodes" % len(al.dictNodes))
logger.info(u"Found %d Edges" % len(al.dictEdges))
assert (len(al.dictNodes) == 45)
assert (len(al.dictEdges) == 36)
count = 0
listTSort = list()
for x in al.dictEdges.keys():
logger.info(u"[%s]=%s" % (al.dictEdges[x][u"id"], x))
if u"source" in al.dictEdges[x]:
source = al.dictEdges[x][u"source"]
target = al.dictEdges[x][u"target"]
logger.info(u" Rel : %s" % (al.dictEdges[x][ARCHI_TYPE]))
sourceName = al.getNodeName(source)
targetName = al.getNodeName(target)
logger.info(u" %s--%s--%s" % (sourceName, al.dictEdges[x][ARCHI_TYPE][10:], targetName))
sc = concepts.addConceptKeyType(sourceName, al.dictNodes[source][ARCHI_TYPE][10:])
# getWords(sourceName, sc)
tc = sc.addConceptKeyType(targetName, al.dictNodes[target][ARCHI_TYPE][10:])
# getWords(sourceName, tc)
Concepts.saveConcepts(concepts, fileConceptsExport)
assert(len(concepts.cd) == 17)
assert (os.path.isfile(fileConceptsExport) is True)
assert(concepts.typeName == u"Nodes")
开发者ID:Darth-Neo,项目名称:al_lib,代码行数:55,代码来源:test_ArchiLib.py
示例11: PPTXCrawl
def PPTXCrawl(filePPTX):
logger.info(u"Using : %s" % filePPTX)
cpptx = PPTXCreateArchil(filePPTX)
c = cpptx.crawlPPTX()
c.logConcepts()
Concepts.saveConcepts(c, fileConceptsPPTX)
开发者ID:Darth-Neo,项目名称:ArchiConcepts,代码行数:11,代码来源:al_PPTXCrawl.py
示例12: __init__
def __init__(self, conceptFile=None):
if conceptFile == None:
conceptFile = u"documents.p"
logger.info(u"Load Concepts from %s " % (conceptFile))
self.concepts = Concepts.loadConcepts(conceptFile)
logger.info(u"Loaded Concepts")
self.conceptsNGram = Concepts(u"n-gram", u"NGRAM")
self.conceptsNGramScore = Concepts(u"NGram_Score", u"Score")
self.conceptsNGramSubject = Concepts(u"Subject", u"Subjects")
开发者ID:Darth-Neo,项目名称:DirCrawler,代码行数:11,代码来源:nl_phase_d_find_collocations.py
示例13: test_PPTXCrawl
def test_PPTXCrawl(fileArchimate):
assert (os.path.isfile(filePPTXIn) is True)
logger.info(u"Using : %s" % filePPTXIn)
cpptx = PPTXCreateArchil(filePPTXIn, fileArchimate)
c = cpptx.crawlPPTX()
Concepts.saveConcepts(c, fileConceptsPPTX)
assert (os.path.isfile(fileConceptsPPTX) is True)
开发者ID:RichDijk,项目名称:ArchiConcepts,代码行数:13,代码来源:test_all_phases.py
示例14: PPTXCreateArchi
def PPTXCreateArchi():
start_time = ArchiLib.startTimer()
logger.info(u"Using : %s" % filePPTXIn)
cpptx = PPTXCreateArchil(filePPTXIn, fileArchimateTest)
c = cpptx.crawlPPTX()
c.logConcepts()
Concepts.saveConcepts(c, fileConceptsPPTX)
ArchiLib.stopTimer(start_time)
开发者ID:Darth-Neo,项目名称:al_lib,代码行数:15,代码来源:PPTXCreateArchi.py
示例15: importConceptsIntoNeo4J
def importConceptsIntoNeo4J(fileArchimate, gdb, ClearNeo4J=True):
icnj = ConceptsImportNeo4J(fileArchimate, gdb, ClearNeo4J=ClearNeo4J)
importConcepts = Concepts.loadConcepts(fileConceptsExport)
icnj.importNeo4J(importConcepts)
开发者ID:RichDijk,项目名称:ArchiConcepts,代码行数:7,代码来源:al_ImportConceptsIntoNeo4J.py
示例16: createArchimateConcepts
def createArchimateConcepts(fileArchimate, fileConceptsArch):
logger.info(u"Using : %s" % fileArchimate)
concepts = Concepts(fileArchimateModel, u"Archimate")
al = ArchiLib(fileArchimate)
al.logTypeCounts()
#
# Create Concepts from Archimate
#
al.folderConcepts(concepts)
Concepts.saveConcepts(concepts, fileConceptsArch)
logger.info(u"Saved concepts to : %s" % fileConceptsArch)
开发者ID:Darth-Neo,项目名称:ArchiConcepts,代码行数:16,代码来源:al_CreateArchimateConcepts.py
示例17: importConceptsIntoArchi
def importConceptsIntoArchi():
logger.info(u"Using : %s" % fileArchimateTest)
conceptFile = fileConceptsBatches
logger.info(u"Loading :" + conceptFile)
concepts = Concepts.loadConcepts(conceptFile)
al = ArchiLib()
# Create Subfolder
folder = u"Implementation & Migration"
subfolder = u"Dependancy Analysis - %s" % time.strftime(u"%Y%d%m_%H%M%S")
attrib = dict()
attrib[u"id"] = al.getID()
attrib[u"name"] = subfolder
al.insertNode(u"folder", folder, attrib)
logger.info(u"--- Insert Nodes ---")
insertConceptNode(al, concepts, subfolder)
logger.info(u"--- Insert Relations ---")
insertConceptRelation(al, concepts)
al.outputXMLtoFile(filename=u"import_concepts.archimate")
开发者ID:RichDijk,项目名称:ArchiConcepts,代码行数:26,代码来源:al_ImportConceptsIntoArchi.py
示例18: exportArchiFolderModels
def exportArchiFolderModels(self, folder):
logger.info(u"Exporting Folder : %s" % folder)
listMTE = self.al.getModelsInFolder(folder)
concepts = Concepts(u"Export", u"Pickle")
for ModelToExport in listMTE:
logger.info(u" Model : %s" % ModelToExport)
d = concepts.addConceptKeyType(ModelToExport, u"Model")
self.al.recurseModel(ModelToExport, d)
self.al.outputCSVtoFile(concepts, fileCSVExport)
Concepts.saveConcepts(concepts, self.conceptsFile)
logger.info(u"Save Concepts : %s" % self.conceptsFile)
开发者ID:Darth-Neo,项目名称:al_lib,代码行数:18,代码来源:ExportFolderModels.py
示例19: __init__
def __init__(self, fileArchimate):
self.fileArchimate = fileArchimate
logger.info(u"Using : %s" % self.fileArchimate)
self.al = ArchiLib(fileArchimate)
self.concepts = Concepts(u"BusinessProcess", u"archimate:BusinessProcess")
开发者ID:Darth-Neo,项目名称:al_lib,代码行数:9,代码来源:DependencyAnalysis.py
示例20: test_importConceptsIntoNeo4J
def test_importConceptsIntoNeo4J(fileArchimate, gdb):
assert (os.path.isfile(fileArchimate) is True)
icnj = ConceptsImportNeo4J(fileArchimate, gdb, ClearNeo4J=True)
assert (os.path.isfile(fileConceptsExport) is True)
importConcepts = Concepts.loadConcepts(fileConceptsExport)
icnj.importNeo4J(importConcepts)
开发者ID:RichDijk,项目名称:ArchiConcepts,代码行数:9,代码来源:test_all_phases.py
注:本文中的nl_lib.Concepts.Concepts类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论