Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Carlos-Francisco Méndez-Cruz
/
conditional-random-fields
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Carlos-Francisco Méndez-Cruz
2019-02-14 12:46:15 -0600
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
00631690844438233c209804a910be6c7674de76
00631690
1 parent
a7cccc5f
Conditional Random Fields
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
training-validation-v1.py
training-validation-v1.py
View file @
0063169
...
...
@@ -39,7 +39,7 @@ from nltk.corpus import stopwords
# 1) Best model
# Examples
# python
3.4
training-validation-v1.py
# python training-validation-v1.py
# --inputPath /export/space1/users/compu2/bionlp/conditional-random-fields/data-sets
# --trainingFile training-data-set-35.txt
# --testFile test-data-set-30.txt
...
...
@@ -58,29 +58,29 @@ def word2features(sent, i):
postag
=
listElem
[
2
]
features
=
{
'word'
:
word
,
#
'lemma': lemma,
#
'word': word,
'lemma'
:
lemma
,
#'postag': postag,
}
if
i
>
0
:
listElem
=
sent
[
i
-
1
]
.
split
(
'|'
)
word1
=
listElem
[
0
]
#
word1 = listElem[0]
lemma1
=
listElem
[
1
]
postag1
=
listElem
[
2
]
features
.
update
({
'-1:word'
:
word1
,
#
'-1:lemma': lemma1,
#
'-1:word': word1,
'-1:lemma'
:
lemma1
,
#'-1:postag': postag1,
})
if
i
<
len
(
sent
)
-
1
:
listElem
=
sent
[
i
+
1
]
.
split
(
'|'
)
word1
=
listElem
[
0
]
#
word1 = listElem[0]
lemma1
=
listElem
[
1
]
postag1
=
listElem
[
2
]
features
.
update
({
'+1:word'
:
word1
,
#
'+1:lemma': lemma1,
#
'+1:word': word1,
'+1:lemma'
:
lemma1
,
#'+1:postag': postag1,
})
return
features
...
...
@@ -234,7 +234,7 @@ if __name__ == "__main__":
# crf = rs.best_estimator_
nameReport
=
options
.
trainingFile
.
replace
(
'.txt'
,
'.fStopWords_'
+
str
(
options
.
excludeStopWords
)
+
'.fSymbols_'
+
str
(
options
.
excludeSymbols
)
+
'.txt'
)
with
open
(
os
.
path
.
join
(
options
.
outputPath
,
"reports"
,
"report_"
+
nameReport
),
mode
=
"w"
)
as
oFile
:
with
open
(
os
.
path
.
join
(
options
.
outputPath
,
"reports
-l
"
,
"report_"
+
nameReport
),
mode
=
"w"
)
as
oFile
:
oFile
.
write
(
"********** TRAINING **********
\n
"
)
oFile
.
write
(
"Training file: "
+
options
.
trainingFile
+
'
\n
'
)
oFile
.
write
(
'
\n
'
)
...
...
Please
register
or
login
to post a comment