Skip to content

Commit

Permalink
bugfix + version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
drupchen committed Nov 19, 2019
1 parent e10214e commit 97d7a85
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 51 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.1.2](https://github.com/Esukhia/bordr/releases/tag/v0.1.2) - 20191119
### Changed
* remove error catching in rdr()

## [0.1.1](https://github.com/Esukhia/bordr/releases/tag/v0.1.1) - 20191119
### Fixed
* bad parse didn't trigger error
Expand Down
2 changes: 1 addition & 1 deletion bordr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
from .Utility.Eval import evaluate
from .Utility.Config import NUMBER_OF_PROCESSES, THRESHOLD

__version__ = "0.1.1"
__version__ = "0.1.2"
94 changes: 44 additions & 50 deletions bordr/pSCRDRtagger/RDRPOSTagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,55 +72,49 @@ def rdr(to_process, mode=None, model=None, lexicon=None, string=False, verbose=F
raise SyntaxError("mode should either be train or tag.")

if mode == "train":
try:
log = []
log.append("\n====== Start ======")
log.append(
"\nGenerate from the gold standard training corpus a lexicon "
+ to_process
+ ".DICT"
)
log.append(createLexicon(to_process, "full"))
log.append(createLexicon(to_process, "short"))
log.append(
"\nExtract from the gold standard training corpus a raw text corpus "
+ to_process
+ ".RAW"
)
getRawText(to_process, to_process + ".RAW")
log.append(
"\nPerform initially POS tagging on the raw text corpus, to generate "
+ to_process
+ ".INIT"
)
DICT = readDictionary(to_process + ".sDict")
initializeCorpus(DICT, to_process + ".RAW", to_process + ".INIT")
log.append(
"\nLearn a tree model of rules for POS tagging from %s and %s"
% (to_process, to_process + ".INIT")
)
rdrTree = SCRDRTreeLearner(THRESHOLD[0], THRESHOLD[1])
rdrTree.learnRDRTree(to_process + ".INIT", to_process)
log.append("\nWrite the learned tree model to file " + to_process + ".RDR")
rdrTree.writeToFile(to_process + ".RDR")
log.append("\nDone!")
return "".join(log) if verbose else 0
except Exception as e:
return "ERROR ==> " + str(e)
log = []
log.append("\n====== Start ======")
log.append(
"\nGenerate from the gold standard training corpus a lexicon "
+ to_process
+ ".DICT"
)
log.append(createLexicon(to_process, "full"))
log.append(createLexicon(to_process, "short"))
log.append(
"\nExtract from the gold standard training corpus a raw text corpus "
+ to_process
+ ".RAW"
)
getRawText(to_process, to_process + ".RAW")
log.append(
"\nPerform initially POS tagging on the raw text corpus, to generate "
+ to_process
+ ".INIT"
)
DICT = readDictionary(to_process + ".sDict")
initializeCorpus(DICT, to_process + ".RAW", to_process + ".INIT")
log.append(
"\nLearn a tree model of rules for POS tagging from %s and %s"
% (to_process, to_process + ".INIT")
)
rdrTree = SCRDRTreeLearner(THRESHOLD[0], THRESHOLD[1])
rdrTree.learnRDRTree(to_process + ".INIT", to_process)
log.append("\nWrite the learned tree model to file " + to_process + ".RDR")
rdrTree.writeToFile(to_process + ".RDR")
log.append("\nDone!")
return "".join(log) if verbose else 0

if mode == "tag":
try:
log = []
r = RDRPOSTagger()
log.append("\n=> Read a POS tagging model from " + model)
r.constructSCRDRtreeFromRDRfile(model)
log.append("\n=> Read a lexicon from " + lexicon)
DICT = readDictionary(lexicon)
log.append("\n=> Perform POS tagging on " + to_process)
if string:
r.tagRawSentence(DICT, to_process)
else:
r.tagRawCorpus(DICT, to_process)
return "".join(log) if verbose else 0
except Exception as e:
return "ERROR ==> " + str(e)
log = []
r = RDRPOSTagger()
log.append("\n=> Read a POS tagging model from " + model)
r.constructSCRDRtreeFromRDRfile(model)
log.append("\n=> Read a lexicon from " + lexicon)
DICT = readDictionary(lexicon)
log.append("\n=> Perform POS tagging on " + to_process)
if string:
r.tagRawSentence(DICT, to_process)
else:
r.tagRawCorpus(DICT, to_process)
return "".join(log) if verbose else 0

0 comments on commit 97d7a85

Please sign in to comment.