Skip to content

Commit

Permalink
add logger
Browse files Browse the repository at this point in the history
  • Loading branch information
jxhe committed Jun 7, 2019
1 parent 4223e8d commit 0e2ed4a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -29,7 +29,7 @@ rm ud-treebanks-v2.2.tgz

## Prepare Embeddings
### fastText
The fastText embeddings can be downloaded on the Facebook fastText [repo](https://github.com/facebookresearch/fastText/blob/master/docs/pretrained-vectors.md) (Note that there are different versions of pretrained fastText embeddings in the fastText repo, but the embeddings must be downloaded from the given link since the alignment matrices (from [here](https://github.com/Babylonpartners/fastText_multilingual)) we used are learned on this specific version of fastText embeddings. Download the fastText model `bin` file and put it into the `fastText_data` folder.
The fastText embeddings can be downloaded in the Facebook fastText [repo](https://github.com/facebookresearch/fastText/blob/master/docs/pretrained-vectors.md) (Note that there are different versions of pretrained fastText embeddings in the fastText repo, but the embeddings must be downloaded from the given link since the alignment matrices (from [here](https://github.com/Babylonpartners/fastText_multilingual)) we used are learned on this specific version of fastText embeddings). Download the fastText model `bin` file and put it into the `fastText_data` folder.

Take English language as an example to preprocess the fastText embeddings:
```
Expand Down
26 changes: 26 additions & 0 deletions modules/logger.py
@@ -0,0 +1,26 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2019-05-29 Junxian <He>
#
# Distributed under terms of the MIT license.

"""
Logger class files
"""
import sys

class Logger(object):
def __init__(self, output_file):
self.terminal = sys.stdout
self.log = open(output_file, "w")

def write(self, message):
print(message, end="", file=self.terminal, flush=True)
print(message, end="", file=self.log, flush=True)

def flush(self):
self.terminal.flush()
self.log.flush()

0 comments on commit 0e2ed4a

Please sign in to comment.