Exemplo n.º 1
0
 def max_idea_density(self):
     """
     Returns the Max Idea Density.
     Idea Density is the ratio of propositions to total word count.
     """
     if self.__max_idensity is None:
         if self.__treestrings is None:
             self.__treestrings = self.treestrings()
         self.__idensity, self.__min_idensity, self.__max_idensity = cUtil.calc_idea_density(self.treestrings())
     return self.__max_idensity
Exemplo n.º 2
0
 def max_idea_density(self):
     """
     Returns the Max Idea Density.
     Idea Density is the ratio of propositions to total word count.
     """
     if self.__max_idensity is None:
         if self.__treestrings is None:
             self.__treestrings = self.treestrings()
         self.__idensity, self.__min_idensity, self.__max_idensity = cUtil.calc_idea_density(
             self.treestrings())
     return self.__max_idensity
Exemplo n.º 3
0
 def run(self, data):
     results = []
     try:
         for corpus in data:
             split_string = corpus.contents.split(" ")
             temp_corpus = list(filter("{SL}".__ne__, split_string))
             temp_corpus = list(filter("{sl}".__ne__, temp_corpus))
             temp_corpus_contents = " ".join(temp_corpus)
             # print(corpus.contents)
             temp_bubble = SPLAT(temp_corpus_contents)
             temp_trees = TreeStringParser().get_parse_trees(
                 temp_bubble.sents())
             # print(temp_bubble.splat())
             # cdensity = temp_bubble.content_density()
             cdensity = cUtil.calc_content_density(temp_trees)
             print(cdensity)
             # print(temp_bubble.treestrings())
             # idensity = temp_bubble.idea_density()
             idensity = cUtil.calc_idea_density(temp_trees)[0]
             # print(idensity)
             flesch_score = temp_bubble.flesch_readability()
             # print(flesch_score)
             kincaid_score = temp_bubble.kincaid_grade_level()
             # print(kincaid_score)
             types = len(temp_bubble.types())
             tokens = len(temp_bubble.tokens())
             type_token_ratio = float(float(types) / float(tokens))
             results.append({
                 'corpus_id': corpus.id,
                 'content_density': cdensity,
                 'idea_density': idensity,
                 'flesch_score': flesch_score,
                 'kincaid_score': kincaid_score,
                 'types': types,
                 'tokens': tokens,
                 'type_token_ratio': type_token_ratio
             })
         results = json.dumps(results)
         # print(results)
         return results
     except TypeError as e:
         print(e)
         raise TransactionException('Corpus contents does not exist.')