How to use abspaths method in fMBT

Best Python code snippet using fMBT_python

dependencycorpusreader.py

Source:dependencycorpusreader.py Github

copy

Full Screen

...23 :return: the given file(s) as a single string.24 :rtype: str25 """26 result = []27 for fileid, encoding in self.abspaths(fileids, include_encoding=True):28 if isinstance(fileid, PathPointer):29 result.append(fileid.open(encoding=encoding).read())30 else:31 with codecs.open(fileid, "r", encoding) as fp:32 result.append(fp.read())33 return concat(result)34 def words(self, fileids=None):35 return concat([DependencyCorpusView(fileid, False, False, False, encoding=enc)36 for fileid, enc in self.abspaths(fileids, include_encoding=True)])37 def tagged_words(self, fileids=None):38 return concat([DependencyCorpusView(fileid, True, False, False, encoding=enc)39 for fileid, enc in self.abspaths(fileids, include_encoding=True)])40 def sents(self, fileids=None):41 return concat([DependencyCorpusView(fileid, False, True, False, encoding=enc)42 for fileid, enc in self.abspaths(fileids, include_encoding=True)])43 def tagged_sents(self, fileids=None):44 return concat([DependencyCorpusView(fileid, True, True, False, encoding=enc)45 for fileid, enc in self.abspaths(fileids, include_encoding=True)])46 def parsed_sents(self, fileids=None):47 sents=concat([DependencyCorpusView(fileid, False, True, True, encoding=enc)48 for fileid, enc in self.abspaths(fileids, include_encoding=True)])49 return [DependencyGraph(sent) for sent in sents]50class DependencyCorpusView(StreamBackedCorpusView):51 _DOCSTART = '-DOCSTART- -DOCSTART- O\n' #dokumentu hasiera definitzen da52 def __init__(self, corpus_file, tagged, group_by_sent, dependencies,53 chunk_types=None, encoding='utf8'):54 self._tagged = tagged55 self._dependencies = dependencies56 self._group_by_sent = group_by_sent57 self._chunk_types = chunk_types58 StreamBackedCorpusView.__init__(self, corpus_file, encoding=encoding)59 def read_block(self, stream):60 # Read the next sentence.61 sent = read_blankline_block(stream)[0].strip()62 # Strip off the docstart marker, if present....

Full Screen

Full Screen

files.py

Source:files.py Github

copy

Full Screen

1#!/bin/env/python2import os3# ------------------------------- Filesystem4def ls():5 return os.listdir('.')6def isHidden(path):7 filename = os.path.basename(path)8 return filename.startswith('.')9def isVisible(path):10 return not isHidden(path)11def joinPaths(dir, contents):12 return map(lambda f: os.path.join(dir, f), contents)13def filesInDirMatching(dir, prefix=None, suffix=None, absPaths=False,14 onlyFiles=False, onlyDirs=False):15 files = os.listdir(dir)16 if prefix:17 files = filter(lambda f: f.startswith(prefix), files)18 if suffix:19 files = filter(lambda f: f.endswith(suffix), files)20 if onlyFiles or onlyDirs:21 paths = joinPaths(dir, files)22 if onlyFiles:23 newFiles = []24 for f, path in zip(files, paths):25 if os.path.isfile(path):26 newFiles.append(f)27 files = newFiles28 if onlyDirs:29 newFiles = []30 for f, path in zip(files, paths):31 if os.path.isdir(path):32 newFiles.append(f)33 files = newFiles34 if absPaths:35 files = joinPaths(dir, files)36 return files37def listSubdirs(dir, startswith=None, endswith=None, absPaths=False):38 return filesInDirMatching(dir, startswith, endswith, absPaths,39 onlyDirs=True)40def listFilesInDir(dir, startswith=None, endswith=None, absPaths=False):41 return filesInDirMatching(dir, startswith, endswith, absPaths,42 onlyFiles=True)43def listHiddenFilesInDir(dir, startswith=None, endswith=None, absPaths=False):44 contents = filesInDirMatching(dir, startswith, endswith, absPaths,45 onlyFiles=True)46 return filter(isHidden, contents)47def listVisibleFilesInDir(dir, startswith=None, endswith=None, absPaths=False):48 contents = filesInDirMatching(dir, startswith, endswith, absPaths,49 onlyFiles=True)50 return filter(isVisible, contents)51def ensureDirExists(dir):52 if not os.path.exists(dir):53 os.makedirs(dir)54def basename(f, noexts=False):55 name = os.path.basename(f)56 if noexts:57 name = name.split('.')[0]...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful