def parse(sentences, weights): results = [] edge_feats_list, featdict = c.extract(sentences) size = len(sentences) count = 0 correct = 0 total = 0 for sentence, edge_feats in zip(sentences, edge_feats_list): count = count + 1 Log.i("Parsing sentence: %d of %d" % (count, size)) result = [] heads = eisner.parse(sentence, weights, edge_feats) for index, word in enumerate(sentence): if index == 0: continue token = [ str(word.id), word.form, word.lemma, word.cpostag, word.postag, word.feats, str(heads[index]), word.deprel ] line = "\t".join(token) if heads[index] == word.head: correct = correct + 1 total = total + 1 result.append(line) results.append(result) return results, float(correct / total)
def downloadQtPackge(): qt_version_dotless = qt_version.replace('.', '') base_url = 'https://download.qt.io/online/qtsdkrepository/{}/{}/qt5_{}' \ .format(os_url, target_platform ,qt_version_dotless) updates_file = 'Updates-{}-{}.xml'.format(qt_version, os_name) c.download(base_url + '/Updates.xml', updates_file) updates = ET.parse(updates_file) updates_root = updates.getroot() all_modules = {} for i in updates_root.iter('PackageUpdate'): name = i.find('Name').text if 'debug' in name or not kit_arch in name: continue archives = i.find('DownloadableArchives') if archives.text is None: continue archives_parts = archives.text.split(',') version = i.find('Version').text for archive in archives_parts: archive = archive.strip() parts = archive.split('-') module_name = parts[0] all_modules[module_name] = { 'package': name, 'file': version + archive } if len(sys.argv) > 1: # handle subcommand if sys.argv[1] == 'list': c.print('Available modules:') for k in iter(sorted(all_modules.keys())): c.print(k, '---', all_modules[k]['file']) exit(0) for module in qt_modules_list: if module not in all_modules: c.print('>> Required module {} not available'.format(module)) continue file_name = all_modules[module]['file'] package = all_modules[module]['package'] c.download(base_url + '/' + package + '/' + file_name, file_name) c.extract(file_name, '.')
def download_mingw_tool(): qt_version_dotless = qt_version.replace('.', '') base_url = 'https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/tools_mingw/' updates_file = 'Updates-{}-{}-{}.xml'.format(qt_version, os_name, 'qttool') c.download(base_url + '/Updates.xml', updates_file) updates = ET.parse(updates_file) updates_root = updates.getroot() all_modules = {} for i in updates_root.iter('PackageUpdate'): name = i.find('Name').text if 'debug' in name or not kit_arch in name: continue archives = i.find('DownloadableArchives') if archives.text is None: continue c.print(' archives: {}'.format(archives)) archives_parts = archives.text.split(',') version = i.find('Version').text c.print(' version: {}'.format(version)) for archive in archives_parts: archive = archive.strip() parts = archive.split('-') module_name = parts[0] all_modules[module_name] = { 'package': name, 'file': version + archive } if len(sys.argv) > 1: # handle subcommand if sys.argv[1] == 'list': c.print('Available modules:') for k in iter(sorted(all_modules.keys())): c.print(k, '---', all_modules[k]['file']) exit(0) file_name = all_modules[module_name]['file'] package = all_modules[module_name]['package'] c.print('download url: {}'.format(base_url + '/' + package + '/' + file_name)) c.download(base_url + '/' + package + '/' + file_name, file_name) c.extract(file_name, '.')
def train(sentences, iteration=10): edge_feats_list, featdict = c.extract(sentences) weights = np.zeros(len(featdict)) size = len(sentences) for i in range(1, iteration + 1): Log.i("Training iteration: %d of %d" % (i, iteration)) count = 0 for sentence, edge_feats in zip(sentences, edge_feats_list): count = count + 1 Log.i("\tTraining sentence: %d of %d" % (count, size)) predicts = eisner.parse(sentence, weights, edge_feats) weights = update(weights, predicts, sentence, edge_feats) """ print(predicts) for feat, index in featdict.items(): print(index, feat, weights[index]) """ return featdict, weights
includes_path = install_dir + '/include/tesseract' if len(c.get_folder_files(includes_path)) == 0: return False return True if check_existing() and not 'FORCE' in os.environ: c.print('>> Using cached') exit(0) archive = 'tesseract-' + os.path.basename(url) c.download(url, archive) src_dir = os.path.abspath('tesseract_src') c.extract(archive, '.') c.symlink(c.get_archive_top_dir(archive), src_dir) c.ensure_got_path(install_dir) c.recreate_dir(build_dir) os.chdir(build_dir) cmake_args = '"{0}" -DCMAKE_INSTALL_PREFIX="{1}" -DLeptonica_DIR="{1}/cmake" \ -DBUILD_TRAINING_TOOLS=OFF -DBUILD_TESTS=OFF'.format(src_dir, install_dir) if platform.system() == "Windows": env_cmd = c.get_msvc_env_cmd(bitness=bitness, msvc_version=msvc_version) c.apply_cmd_env(env_cmd) cmake_args += ' ' + c.get_cmake_arch_args(bitness=bitness)
def main(): extract(get_info, 'gendriver.tpl')
result_str = '{}'.format(url_table.get(ver, "")) c.print('>>> linux url: {}'.format(result_str)) return result_str src_base = 'qt-creator-opensource-src-' + qtc_version qtc_dir = src_base qtc_main_version = qtc_version[:qtc_version.rindex('.')] base_url = 'https://download.qt.io/official_releases/qtcreator/{}/{}'\ .format(qtc_main_version, qtc_version) src_ext = 'zip' if os_name.startswith('win') else 'tar.xz' src_archive = src_base + '.' + src_ext c.download(base_url + '/' + src_archive, src_archive) c.extract(src_archive, '.') if os_name == 'linux': os_url = get_linux_url(qtc_main_version) elif os_name == 'win32_msvc': os_url = get_windows_url(32, qtc_main_version) elif os_name == 'win64_msvc': os_url = get_windows_url(64, qtc_main_version) elif os_name == 'macos': os_url = 'mac_x64' if os_name == 'macos': c.print('>> Workaround') shutil.rmtree( qtc_dir + '/src/shared/qbs/examples/cocoa-application/CocoaApplication/en_US.lproj',
from bs4 import BeautifulSoup from urllib.request import urlopen import re from common import extract, openBS, trimBio actorName = input("Enter actor name to find:\t").strip() actorName = actorName.replace(" ", "+") # we extract the actual actor's url (finalUrl) from this url below url = "https://www.imdb.com/find?ref_=nv_sr_fn&q=" + actorName + "&s=all" pageSoup = openBS(url) strng = str(pageSoup.find( "table", {"class": "findList" })) # findAll returns a list. find returns first element uri = re.findall(r'<a href="\/name[^>]*>', strng)[0] finalUrl = "http://imdb.com" + extract(uri) pageSoup = openBS(finalUrl) bio = str(pageSoup.find("div", {"class": "name-trivia-bio-text"}).div) print(trimBio(bio))
if len(sys.argv) > 1: # handle subcommand if sys.argv[1] == 'list': c.print('Available modules:') for k in iter(sorted(all_modules.keys())): c.print(k, '---', all_modules[k]['file']) exit(0) for module in qt_modules: if module not in all_modules: c.print('>> Required module {} not available'.format(module)) continue file_name = all_modules[module]['file'] package = all_modules[module]['package'] c.download(base_url + '/' + package + '/' + file_name, file_name) c.extract(file_name, '.') c.symlink(qt_dir_prefix, qt_dir) c.print('>> Updating license') config_name = qt_dir + '/mkspecs/qconfig.pri' config = '' with open(config_name, 'r') as f: config = f.read() config = config.replace('Enterprise', 'OpenSource') config = config.replace('licheck.exe', '') config = config.replace('licheck64', '') config = config.replace('licheck_mac', '') with open(config_name, 'w') as f:
import common as c from config import qtc_version, os_name import os c.print('>> Downloading Qt Creator {} for {}'.format(qtc_version, os_name)) if os_name == 'linux': os_url = 'linux_gcc_64_rhel72' elif os_name == 'win32': os_url = 'windows_msvc2017_x86' elif os_name == 'win64': os_url = 'windows_msvc2017_x64' elif os_name == 'macos': os_url = 'mac_x64' qtc_main_version = qtc_version[:qtc_version.rindex('.')] base_url = 'https://download.qt.io/official_releases/qtcreator/{}/{}/installer_source/{}'\ .format(qtc_main_version, qtc_version, os_url) qtc_dir = 'qtcreator-{}'.format(qtc_version) for archive in ['qtcreator.7z', 'qtcreator_dev.7z']: c.download(base_url + '/' + archive, archive) c.extract(archive, qtc_dir) c.symlink(qtc_dir, 'qtcreator') if os_name == 'macos': os.makedirs('qtcreator/bin', exist_ok=True) c.symlink(os.path.abspath('qtcreator/Qt Creator.app'), 'qtcreator/bin/Qt Creator.app')
def main(): extract(get_info, 'genvmi.tpl')