当前位置: 首页>>代码示例>>Python>>正文


Python utils.FileHelper类代码示例

本文整理汇总了Python中goose.utils.FileHelper的典型用法代码示例。如果您正苦于以下问题:Python FileHelper类的具体用法?Python FileHelper怎么用?Python FileHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FileHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, language="en"):
     # TODO replace 'x' with class
     # to generate dynamic path for file to load
     if not language in self._cached_stop_words:
         path = "text/stopwords-%s.txt" % language
         try:
             self._cached_stop_words[language] = set(FileHelper.loadResourceFile(path).splitlines())
         except:
             self._cached_stop_words[language] = set(
                 FileHelper.loadResourceFile("text/stopwords-en.txt").splitlines()
             )
     self.STOP_WORDS = self._cached_stop_words[language]
开发者ID:albertian,项目名称:python-goose,代码行数:12,代码来源:text.py

示例2: loadCustomSiteMapping

 def loadCustomSiteMapping(self):
     # TODO
     dataFile = FileHelper.loadResourceFile("images/known-image-css.txt", "xx")
     lines = dataFile.splitlines()
     for line in lines:
         domain, css = line.split('^')
         self.customSiteMapping.update({domain:css})
开发者ID:AnthonyNystrom,项目名称:python-goose,代码行数:7,代码来源:UpgradedImageExtractor.py

示例3: html_content

 def html_content(self, req):
     current_test = self.cls._get_current_testname()
     path = os.path.join(
         os.path.dirname(CURRENT_PATH), "data", "extractors", "images", current_test, "%s.html" % current_test
     )
     path = os.path.abspath(path)
     return FileHelper.loadResourceFile(path)
开发者ID:rooterkyberian,项目名称:python-goose,代码行数:7,代码来源:images.py

示例4: __init__

 def __init__(self, language='en'):
     # TODO replace 'x' with class
     # to generate dynamic path for file to load
     if not language in self._cached_stop_words:
         path = os.path.join('text', 'stopwords-%s.txt' % language)
         self._cached_stop_words[language] = set(FileHelper.loadResourceFile(path).splitlines())
     self.STOP_WORDS = self._cached_stop_words[language]
开发者ID:Cipherwraith,项目名称:PyTeaser,代码行数:7,代码来源:text.py

示例5: __init__

 def __init__(self, language="zh"):
     # force zh languahe code
     language = "zh"
     if not language in self._cached_stop_words:
         path = "text/stopwords-%s.txt" % language
         self._cached_stop_words[language] = set(FileHelper.loadResourceFile(path).splitlines())
     self.STOP_WORDS = self._cached_stop_words[language]
开发者ID:palyan,项目名称:python-goose,代码行数:7,代码来源:text.py

示例6: content

 def content(self, req):
     current_test = self.cls._get_current_testname()
     path = os.path.join(CURRENT_PATH, "data", "extractors",
                         "%s.html" % current_test)
     path = os.path.abspath(path)
     content = FileHelper.loadResourceFile(path)
     return content
开发者ID:eledata,项目名称:python-goose,代码行数:7,代码来源:extractors.py

示例7: load_test_file

 def load_test_file(self, suffix):
     suite, module, cls, func = self.id().split('.')
     path = os.path.join(CURRENT_PATH, "data", module, "%s%s" % (func, suffix))
     path = os.path.abspath(path)
     try:
         return FileHelper.loadResourceFile(path)
     except IOError:
         print "No File"
开发者ID:tanzaho,项目名称:python-goose,代码行数:8,代码来源:extractors.py

示例8: content

 def content(self, req):
     current_test = self.cls._get_current_testname()
     path = os.path.join(CURRENT_PATH, "data", "extractors", "%s.html" % current_test)
     path = os.path.abspath(path)
     content = FileHelper.loadResourceFile(path)
     if content is None:
         raise Exception ("Test could not be found")
     return content
开发者ID:tanzaho,项目名称:python-goose,代码行数:8,代码来源:extractors.py

示例9: load_customesite_mapping

 def load_customesite_mapping(self):
     # TODO
     path = os.path.join('images', 'known-image-css.txt')
     data_file = FileHelper.loadResourceFile(path)
     lines = data_file.splitlines()
     for line in lines:
         domain, css = line.split('^')
         self.custom_site_mapping.update({domain: css})
开发者ID:askrht,项目名称:python-goose,代码行数:8,代码来源:extractors.py

示例10: loadData

    def loadData(self):
        """\

        """
        suite, module, cls, func = self.id().split('.')
        path = os.path.join(CURRENT_PATH, "data", module, "%s.json" % func)
        path = os.path.abspath(path)
        content = FileHelper.loadResourceFile(path)
        self.data = json.loads(content)
开发者ID:bgruszka,项目名称:python-goose,代码行数:9,代码来源:extractors.py

示例11: loadData

    def loadData(self):
        """\

        """
        test, suite, module, cls, func = self.id().split(".")
        path = os.path.join(os.path.dirname(CURRENT_PATH), "data", suite, module, func, "%s.json" % func)

        path = os.path.abspath(path)
        content = FileHelper.loadResourceFile(path)
        self.data = json.loads(content)
开发者ID:rooterkyberian,项目名称:python-goose,代码行数:10,代码来源:images.py

示例12: getRawHtml

 def getRawHtml(self):
     test, suite, module, cls, func = self.id().split('.')
     path = os.path.join(
             os.path.dirname(CURRENT_PATH),
             "data",
             suite,
             module,
             "%s.html" % func)
     path = os.path.abspath(path)
     content = FileHelper.loadResourceFile(path)
     return content
开发者ID:437072341,项目名称:python-goose,代码行数:11,代码来源:base.py

示例13: __init__

 def __init__(self, language='en'):
     # TODO replace 'x' with class
     # to generate dynamic path for file to load
     if not language in self._cached_stop_words:
         path = os.path.join('text', 'stopwords-%s.txt' % language)
         try:
             content = FileHelper.loadResourceFile(path)
             word_list = content.splitlines()
         except IOError:
             word_list = []
         self._cached_stop_words[language] = set(word_list)
     self.STOP_WORDS = self._cached_stop_words[language]
开发者ID:437072341,项目名称:python-goose,代码行数:12,代码来源:text.py

示例14: __init__

 def __init__(self, language='en'):
     # TODO replace 'x' with class
     # to generate dynamic path for file to load
     if isinstance(language,str): language = [language]
     language = set(language)
     self.char_split = False
     if 'zh' in language or 'ko' in language or 'ja' in language: self.char_split = True
     self.STOP_WORDS = None
     for l in language:
         if not l in StopWords._cached_stop_words:
             path = 'text/stopwords-%s.txt' % l
             try:
                 _stop_list = FileHelper.loadResourceFile(path)
                 if l in ['zh','ko','ja']: _stop_list = _stop_list.decode('utf-8')
                 StopWords._cached_stop_words[l] = set(_stop_list.splitlines())
             except:
                 StopWords._cached_stop_words[l] = set()
         if self.STOP_WORDS is None: self.STOP_WORDS = StopWords._cached_stop_words[l]
         else: self.STOP_WORDS |= StopWords._cached_stop_words[l]
开发者ID:iKalin,项目名称:python-goose,代码行数:19,代码来源:text.py

示例15: __init__

 def __init__(self, language='en'):
     self.PUNCTUATION = re.compile("[^\\p{Ll}\\p{Lu}\\p{Lt}\\p{Lo}\\p{Nd}\\p{Pc}\\s]")
     # TODO replace 'x' with class
     # to generate dynamic path for file to load
     path = 'text/stopwords-%s.txt' % language
     self.STOP_WORDS = set(FileHelper.loadResourceFile(path, 'x').splitlines())
开发者ID:AnthonyNystrom,项目名称:python-goose,代码行数:6,代码来源:__init__.py


注:本文中的goose.utils.FileHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。