Exemplo n.º 1
0
def _download_pretrained_model():
    """Downloads the pre-trained BIST model if non-existent."""
    if not path.isfile(path.join(SpacyBISTParser.dir, 'bist.model')):
        print('Downloading pre-trained BIST model...')
        zip_path = path.join(SpacyBISTParser.dir, 'bist-pretrained.zip')
        makedirs(SpacyBISTParser.dir, exist_ok=True)
        download_unlicensed_file('https://s3-us-west-1.amazonaws.com/nervana-modelzoo/parse/',
                                 'bist-pretrained.zip', zip_path)
        print('Unzipping...')
        uncompress_file(zip_path, outpath=SpacyBISTParser.dir)
        remove(zip_path)
        print('Done.')
Exemplo n.º 2
0
def _download_pretrained_model():
    """Downloads the pre-trained BIST model if non-existent."""
    if not path.isfile(SpacyBISTParser.dir / 'bist.model'):
        print('Downloading pre-trained BIST model...')
        zip_path = SpacyBISTParser.dir / 'bist-pretrained.zip'
        makedirs(SpacyBISTParser.dir, exist_ok=True)
        download_unlicensed_file(
            'https://s3-us-west-2.amazonaws.com/nlp-architect-data/models/dep_parse/',
            'bist-pretrained.zip', zip_path)
        print('Unzipping...')
        uncompress_file(zip_path, outpath=str(SpacyBISTParser.dir))
        remove(zip_path)
        print('Done.')
Exemplo n.º 3
0
 def get_file_path(self):
     """
     Return local file path of downloaded model files
     """
     for filename in self.files:
         cached_file_path, need_downloading = cached_path(
             self.base_path + filename, self.download_path)
         if filename.endswith("zip"):
             if need_downloading:
                 print("Unzipping...")
                 uncompress_file(cached_file_path,
                                 outpath=self.download_path)
                 print("Done.")
     return self.download_path
Exemplo n.º 4
0
def _download_pretrained_model():
    """Downloads the pre-trained BIST model if non-existent."""
    if not path.isfile(SpacyBISTParser.dir / "bist.model"):
        print("Downloading pre-trained BIST model...")
        zip_path = SpacyBISTParser.dir / "bist-pretrained.zip"
        makedirs(SpacyBISTParser.dir, exist_ok=True)
        download_unlicensed_file(
            "https://d2zs9tzlek599f.cloudfront.net/models/dep_parse/",
            "bist-pretrained.zip",
            zip_path,
        )
        print("Unzipping...")
        uncompress_file(zip_path, outpath=str(SpacyBISTParser.dir))
        remove(zip_path)
        print("Done.")
Exemplo n.º 5
0
 def get_model_files(self):
     """
     Return individual file names of downloaded models
     """
     for fileName in self.files:
         cached_file_path, need_downloading = cached_path(
             self.base_path + fileName, self.download_path)
         if fileName.endswith("zip"):
             if need_downloading:
                 print("Unzipping...")
                 uncompress_file(cached_file_path,
                                 outpath=self.download_path)
                 print("Done.")
             self.model_files.extend(zipfile_list(cached_file_path))
         else:
             self.model_files.extend([fileName])
     return self.model_files
parser.add_argument('--op_thresh', type=int, default=2)
parser.add_argument('--max_iter', type=int, default=3)
parser.add_argument('--large', type=str, default="no")

args = parser.parse_args()

# Download ABSA dependencies including spacy parser and glove embeddings
from spacy.cli.download import download as spacy_download
from nlp_architect.utils.io import uncompress_file
from nlp_architect.models.absa import TRAIN_OUT, LEXICONS_OUT

spacy_download('en')
GLOVE_ZIP = os.path.join(args.data_folder, 'clothing_data/glove.840B.300d.zip')
EMBEDDING_PATH = TRAIN_OUT / 'word_emb_unzipped' / 'glove.840B.300d.txt'

uncompress_file(GLOVE_ZIP, Path(EMBEDDING_PATH).parent)

clothing_train = os.path.join(args.data_folder,
                              'clothing_data/clothing_absa_train_small.csv')

if args.large == 'yes':
    print(f'Using large dataset: clothing_data/clothing_absa_train.csv')
    clothing_train = os.path.join(args.data_folder,
                                  'clothing_data/clothing_absa_train.csv')
else:
    print(f'Using small dataset: clothing_data/clothing_absa_train_small.csv')
    clothing_train = os.path.join(
        args.data_folder, 'clothing_data/clothing_absa_train_small.csv')

os.makedirs('outputs', exist_ok=True)